Class: Studio_game::ClumsyPlayer

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

Instance Attribute Summary collapse

Attributes inherited from Player

#found_treasures, #health, #name, #score, #sum

Instance Method Summary collapse

Methods inherited from Player

#clear_treasure, load_players_, #reset_health, #to_s, #treasure_total

Methods included from Playable

#drain

Constructor Details

#initialize(name, health, boost_factor = 10) ⇒ ClumsyPlayer



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

def initialize(name, health, boost_factor=10)
  super(name, health)
  @boost_factor = boost_factor
end

Instance Attribute Details

#boost_factorObject (readonly)

Returns the value of attribute boost_factor.



5
6
7
# File 'lib/studio_game/clumsy_player.rb', line 5

def boost_factor
  @boost_factor
end

Instance Method Details

#boostObject



11
# File 'lib/studio_game/clumsy_player.rb', line 11

def boost = @boost_factor.times { super }

#found_treasure(name, points) ⇒ Object



13
14
15
16
# File 'lib/studio_game/clumsy_player.rb', line 13

def found_treasure(name, points)
  points = points/2
  super(name, points)  
end


19
20
21
22
23
# File 'lib/studio_game/clumsy_player.rb', line 19

def print_treasures
  @found_treasures.each do |key, value|
    puts "found a #{key} worth #{value} points"
  end
end