Class: StudioGame::LegendaryCharacter
Instance Attribute Summary
Attributes inherited from Character
#hp, #name
Instance Method Summary
collapse
Methods inherited from Character
#<=>, #adopt_pet, #each_pet_adopted, from_csv, #pet_collection, #points, #to_s
Methods included from Playable
#strong?
Constructor Details
#initialize(name, hp = 100, track = 0) ⇒ LegendaryCharacter
Returns a new instance of LegendaryCharacter.
5
6
7
8
|
# File 'lib/studio_game/legendary_character.rb', line 5
def initialize(name, hp=100, track=0)
super(name, hp)
@track = track
end
|
Instance Method Details
#heal_damage(heal) ⇒ Object
18
19
20
21
22
|
# File 'lib/studio_game/legendary_character.rb', line 18
def heal_damage(heal)
super
@track += 1
puts "#{@name} is legendary!" if legendary?
end
|
#legendary? ⇒ Boolean
10
11
12
|
# File 'lib/studio_game/legendary_character.rb', line 10
def legendary?
@track > 5
end
|
#take_damage(damage) ⇒ Object
14
15
16
|
# File 'lib/studio_game/legendary_character.rb', line 14
def take_damage(damage)
legendary? ? heal_damage(damage) : super(damage)
end
|