Class: RubyWarrior::Units::Archer
- Inherits:
-
Base
- Object
- Base
- RubyWarrior::Units::Archer
show all
- Defined in:
- lib/ruby_warrior/units/archer.rb
Instance Attribute Summary
Attributes inherited from Base
#health, #position
Instance Method Summary
collapse
Methods inherited from Base
#abilities, #add_abilities, #alive?, #attack_power, #bind, #bound?, #earn_points, #name, #next_turn, #perform_turn, #prepare_turn, #say, #take_damage, #unbind
Constructor Details
#initialize ⇒ Archer
Returns a new instance of Archer.
4
5
6
|
# File 'lib/ruby_warrior/units/archer.rb', line 4
def initialize
add_abilities :shoot!, :look
end
|
Instance Method Details
#character ⇒ Object
29
30
31
|
# File 'lib/ruby_warrior/units/archer.rb', line 29
def character
"a"
end
|
#max_health ⇒ Object
25
26
27
|
# File 'lib/ruby_warrior/units/archer.rb', line 25
def max_health
7
end
|
#play_turn(turn) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/ruby_warrior/units/archer.rb', line 8
def play_turn(turn)
[:forward, :left, :right].each do |direction|
turn.look(direction).each do |space|
if space.warrior?
turn.shoot!(direction)
return
elsif !space.empty?
break
end
end
end
end
|
#shoot_power ⇒ Object
21
22
23
|
# File 'lib/ruby_warrior/units/archer.rb', line 21
def shoot_power
3
end
|