Module: StudioGame::GameStats

Included in:
Printable
Defined in:
lib/studio_game/game_stats.rb

Instance Method Summary collapse

Instance Method Details



39
40
41
42
43
44
# File 'lib/studio_game/game_stats.rb', line 39

def print_high_scores
  puts "\n#{title} High Scores:"
  players.sort.each do |player|
    puts player.print_score
  end
end


4
5
6
7
8
9
10
# File 'lib/studio_game/game_stats.rb', line 4

def print_stats
  puts format_section_title("game stats")
  print_strength_stats
  print_treasure_stats
  puts total_points
  print_high_scores
end


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/studio_game/game_stats.rb', line 12

def print_strength_stats

  strong_players, wimpy_players = players.partition { |player| player.strong? }

  puts "\nThere are #{strong_players.size} strong players:"
  strong_players.each do |player|
    puts player.print_health_status
  end

  puts "\nThere are #{wimpy_players.size} wimpy players:"
  wimpy_players.each do |player|
    puts player.print_health_status
  end

end


28
29
30
31
32
# File 'lib/studio_game/game_stats.rb', line 28

def print_treasure_stats
  players.each do |player|
    player.print_treasures
  end
end

#total_pointsObject



34
35
36
# File 'lib/studio_game/game_stats.rb', line 34

def total_points
  players.reduce(0) { |sum, player| sum += player.points }
end