Class: StudioGame::BerserkPlayer
- Defined in:
- lib/studio_game/berserk_player.rb
Instance Attribute Summary
Attributes inherited from Player
#found_treasures, #health, #name
Instance Method Summary collapse
- #berserk? ⇒ Boolean
- #boost ⇒ Object
- #drain ⇒ Object
-
#initialize(name, health) ⇒ BerserkPlayer
constructor
A new instance of BerserkPlayer.
Methods inherited from Player
#found_treasure, from_csv, #points, #score, #to_s
Constructor Details
#initialize(name, health) ⇒ BerserkPlayer
Returns a new instance of BerserkPlayer.
4 5 6 7 |
# File 'lib/studio_game/berserk_player.rb', line 4 def initialize(name, health) super(name, health) @boost_count = 0 end |
Instance Method Details
#berserk? ⇒ Boolean
9 10 11 |
# File 'lib/studio_game/berserk_player.rb', line 9 def berserk? @boost_count > 5 end |
#boost ⇒ Object
13 14 15 16 17 |
# File 'lib/studio_game/berserk_player.rb', line 13 def boost super @boost_count += 1 puts "!!!#{@name} is on berserk mode!!!" if berserk? end |
#drain ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/studio_game/berserk_player.rb', line 19 def drain if berserk? boost else super end end |