Class: StudioGame::BerserkPlayer

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

Overview

A berserk player whose treasures are worth half the normal amount

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 = 25) ⇒ BerserkPlayer

Returns a new instance of BerserkPlayer.



6
7
8
9
10
# File 'lib/studio_game/berserk_player.rb', line 6

def initialize(name, health = 25)
  name = "#{name} 😈"
  @boost_count = 0
  super(name, health)
end

Instance Method Details

#berserk?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/studio_game/berserk_player.rb', line 12

def berserk?
  @boost_count >= 5
end

#boostObject



16
17
18
19
# File 'lib/studio_game/berserk_player.rb', line 16

def boost
  super
  berserk? ? puts('😈😈😈') : @boost_count += 1
end

#drainObject



21
22
23
# File 'lib/studio_game/berserk_player.rb', line 21

def drain
  berserk? ? boost : super
end