Class: RubyWarrior::Units::Warrior
- Inherits:
-
Base
- Object
- Base
- RubyWarrior::Units::Warrior
show all
- Defined in:
- lib/ruby_warrior/units/warrior.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#health, #position
Instance Method Summary
collapse
Methods inherited from Base
#abilities, #add_abilities, #alive?, #bind, #bound?, #next_turn, #prepare_turn, #say, #take_damage, #unbind
Constructor Details
Returns a new instance of Warrior.
7
8
9
10
|
# File 'lib/ruby_warrior/units/warrior.rb', line 7
def initialize
@score = 0 @golem_abilities = []
end
|
Instance Attribute Details
#name ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/ruby_warrior/units/warrior.rb', line 37
def name
if @name && !@name.empty?
@name
else
"Warrior"
end
end
|
#score ⇒ Object
Returns the value of attribute score.
5
6
7
|
# File 'lib/ruby_warrior/units/warrior.rb', line 5
def score
@score
end
|
Instance Method Details
#add_golem_abilities(*abilities) ⇒ Object
58
59
60
|
# File 'lib/ruby_warrior/units/warrior.rb', line 58
def add_golem_abilities(*abilities)
@golem_abilities += abilities
end
|
#attack_power ⇒ Object
25
26
27
|
# File 'lib/ruby_warrior/units/warrior.rb', line 25
def attack_power
5
end
|
#base_golem ⇒ Object
66
67
68
69
70
|
# File 'lib/ruby_warrior/units/warrior.rb', line 66
def base_golem
golem = Golem.new
golem.add_abilities *@golem_abilities
golem
end
|
#character ⇒ Object
49
50
51
|
# File 'lib/ruby_warrior/units/warrior.rb', line 49
def character
"@"
end
|
#earn_points(points) ⇒ Object
20
21
22
23
|
# File 'lib/ruby_warrior/units/warrior.rb', line 20
def earn_points(points)
@score += points
say "earns #{points} points"
end
|
#has_golem? ⇒ Boolean
62
63
64
|
# File 'lib/ruby_warrior/units/warrior.rb', line 62
def has_golem?
!@golem_abilities.empty?
end
|
#max_health ⇒ Object
33
34
35
|
# File 'lib/ruby_warrior/units/warrior.rb', line 33
def max_health
20
end
|
53
54
55
56
|
# File 'lib/ruby_warrior/units/warrior.rb', line 53
def perform_turn
say "does nothing" if @current_turn.action.nil?
super
end
|
#play_turn(turn) ⇒ Object
12
13
14
|
# File 'lib/ruby_warrior/units/warrior.rb', line 12
def play_turn(turn)
player.play_turn(turn)
end
|
#player ⇒ Object
16
17
18
|
# File 'lib/ruby_warrior/units/warrior.rb', line 16
def player
@player ||= Player.new
end
|
#shoot_power ⇒ Object
29
30
31
|
# File 'lib/ruby_warrior/units/warrior.rb', line 29
def shoot_power
3
end
|
#to_s ⇒ Object
45
46
47
|
# File 'lib/ruby_warrior/units/warrior.rb', line 45
def to_s
name
end
|