Class: StudioGame::ClumsyPlayer
- Defined in:
- lib/studiogame/clumsy_player.rb
Instance Attribute Summary
Attributes inherited from Player
Instance Method Summary collapse
-
#found_treasure(treasure) ⇒ Object
def found_treasure(treasure) points = treasure.points / 2 @found_treasures += points puts “#@name found a #treasuretreasure.name worth #Player#points points.” end.
Methods inherited from Player
#<=>, #each_found_treasure, #formatted_score, from_csv, #initialize, #points, #say_hello, #score, #to_s
Methods included from Playable
Constructor Details
This class inherits a constructor from StudioGame::Player
Instance Method Details
#found_treasure(treasure) ⇒ Object
def found_treasure(treasure)
points = treasure.points / 2
@found_treasures[treasure.name] += points
puts "#{@name} found a #{treasure.name} worth #{points} points."
end
9 10 11 12 |
# File 'lib/studiogame/clumsy_player.rb', line 9 def found_treasure(treasure) damaged_treasure = Treasure.new(treasure.name, treasure.points / 2) super(damaged_treasure) end |