Class: StudioGame::BerserkPlayer

Inherits:
Player
  • Object
show all
Defined in:
lib/studio_game/berserk_player.rb

Instance Attribute Summary

Attributes inherited from Player

#found_treasures, #health, #name

Instance Method Summary collapse

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

Returns:

  • (Boolean)


9
10
11
# File 'lib/studio_game/berserk_player.rb', line 9

def berserk?
  @boost_count > 5
end

#boostObject



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

#drainObject



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