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
|
# File 'lib/ruby_warrior/units/warrior.rb', line 7
def initialize
@score = 0 end
|
Instance Attribute Details
#name ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/ruby_warrior/units/warrior.rb', line 36
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
#attack_power ⇒ Object
24
25
26
|
# File 'lib/ruby_warrior/units/warrior.rb', line 24
def attack_power
5
end
|
#character ⇒ Object
48
49
50
|
# File 'lib/ruby_warrior/units/warrior.rb', line 48
def character
"@"
end
|
#earn_points(points) ⇒ Object
19
20
21
22
|
# File 'lib/ruby_warrior/units/warrior.rb', line 19
def earn_points(points)
@score += points
say "earns #{points} points"
end
|
#max_health ⇒ Object
32
33
34
|
# File 'lib/ruby_warrior/units/warrior.rb', line 32
def max_health
20
end
|
52
53
54
55
|
# File 'lib/ruby_warrior/units/warrior.rb', line 52
def perform_turn
say "does nothing" if @current_turn.action.nil?
super
end
|
#play_turn(turn) ⇒ Object
11
12
13
|
# File 'lib/ruby_warrior/units/warrior.rb', line 11
def play_turn(turn)
player.play_turn(turn)
end
|
#player ⇒ Object
15
16
17
|
# File 'lib/ruby_warrior/units/warrior.rb', line 15
def player
@player ||= Player.new
end
|
#shoot_power ⇒ Object
28
29
30
|
# File 'lib/ruby_warrior/units/warrior.rb', line 28
def shoot_power
3
end
|
#to_s ⇒ Object
44
45
46
|
# File 'lib/ruby_warrior/units/warrior.rb', line 44
def to_s
name
end
|