Class: RubyWarrior::Abilities::Shoot
- Inherits:
-
Base
- Object
- Base
- RubyWarrior::Abilities::Shoot
show all
- Defined in:
- lib/ruby_warrior/abilities/shoot.rb
Instance Method Summary
collapse
Methods inherited from Base
#damage, #initialize, #offset, #pass_turn, #space, #unit, #verify_direction
Instance Method Details
#description ⇒ Object
4
5
6
|
# File 'lib/ruby_warrior/abilities/shoot.rb', line 4
def description
"Shoot your bow & arrow in given direction (forward by default)."
end
|
#multi_unit(direction, range) ⇒ Object
19
20
21
|
# File 'lib/ruby_warrior/abilities/shoot.rb', line 19
def multi_unit(direction, range)
range.map { |n| unit(direction, n) }
end
|
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/ruby_warrior/abilities/shoot.rb', line 8
def perform(direction = :forward)
verify_direction(direction)
receiver = multi_unit(direction, 1..3).compact.first
if receiver
@unit.say "shoots #{direction} and hits #{receiver}"
damage(receiver, @unit.shoot_power)
else
@unit.say "shoots and hits nothing"
end
end
|