Module: StudioGame::GameStats
- Included in:
- Printable
- Defined in:
- lib/studio_game/game_stats.rb
Instance Method Summary collapse
- #print_high_scores ⇒ Object
- #print_stats ⇒ Object
- #print_strength_stats ⇒ Object
- #print_treasure_stats ⇒ Object
- #total_points ⇒ Object
Instance Method Details
#print_high_scores ⇒ Object
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 |
#print_stats ⇒ Object
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 |
#print_strength_stats ⇒ Object
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 |
#print_treasure_stats ⇒ Object
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_points ⇒ Object
34 35 36 |
# File 'lib/studio_game/game_stats.rb', line 34 def total_points players.reduce(0) { |sum, player| sum += player.points } end |