Class: RubyWarrior::Abilities::Rescue

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_warrior/abilities/rescue.rb

Instance Method Summary collapse

Methods inherited from Base

#damage, #initialize, #offset, #pass_turn, #space, #unit, #verify_direction

Constructor Details

This class inherits a constructor from RubyWarrior::Abilities::Base

Instance Method Details

#descriptionObject



4
5
6
# File 'lib/ruby_warrior/abilities/rescue.rb', line 4

def description
  "#{R18n.t.rescue.description}"
end

#perform(direction = :forward) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby_warrior/abilities/rescue.rb', line 8

def perform(direction = :forward)
  verify_direction(direction)
  if space(direction).captive?
    recipient = unit(direction)
    @unit.say R18n.t.rescue.unbinds_and_rescues(R18n.t.direction[direction], "#{recipient}")
    recipient.unbind
    if recipient.kind_of? Units::Captive
      recipient.position = nil
      @unit.earn_points(20)
    end
  else
    @unit.say "#{R18n.t.rescue.unbinds_and_rescues_nothing(direction)}"
  end
end