Class: StudioGame::ClumsyPlayer

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

Instance Attribute Summary collapse

Attributes inherited from Player

#health, #name

Instance Method Summary collapse

Methods inherited from Player

#<=>, #each_found_treasure, from_csv, #points, #score, #time, #to_s

Methods included from Playable

#blam, #strong?

Constructor Details

#initialize(name, health = 100, boost_factor = 1) ⇒ ClumsyPlayer

Returns a new instance of ClumsyPlayer.



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

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

Instance Attribute Details

#boost_factorObject (readonly)

Returns the value of attribute boost_factor.



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

def boost_factor
  @boost_factor
end

Instance Method Details

#found_treasure(treasure) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/studio_game/clumsy_player.rb', line 13

def found_treasure(treasure)
  # NOTE: The 2.0 denominator is changing the numeric type of the points held in the treasure
  #  from an Integer to Float. (See the test within the TreasureTrove module.) This is changing
  #  the value of the total_points method on the Game automatically converts the returned sum
  #  into a Float when it comes across it in the treasures. Float must "supersede" Integer,
  #  forcing a type conversion when working between integers and decimals. I bet we could force
  #  it back with to_i...
  damaged_treasure = Treasure.new(treasure.name, treasure.points / 2.0)
  super(damaged_treasure)
end

#w00tObject



24
25
26
# File 'lib/studio_game/clumsy_player.rb', line 24

def w00t
  @boost_factor.times { super }
end