Class: RubyWarrior::Abilities::Explode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Attribute Details

#timeObject

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#descriptionObject



6
7
8
# File 'lib/ruby_warrior/abilities/explode.rb', line 6

def description
  "Kills you and all surrounding units. You probably don't want to do this intentionally."
end

#pass_turnObject



19
20
21
22
23
24
25
# File 'lib/ruby_warrior/abilities/explode.rb', line 19

def pass_turn
  if @time && @unit.position
    @unit.say "is ticking"
    @time -= 1
    perform if @time.zero?
  end
end

#performObject



10
11
12
13
14
15
16
17
# File 'lib/ruby_warrior/abilities/explode.rb', line 10

def perform
  if @unit.position
    @unit.say "explodes, collapsing the ceiling and damanging every unit."
    @unit.position.floor.units.map do |unit|
      unit.take_damage(100)
    end
  end
end