Class: RubyWarrior::Abilities::Explode
- Defined in:
- lib/ruby_warrior/abilities/explode.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
Returns the value of attribute time.
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
#time ⇒ Object
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
#description ⇒ Object
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_turn ⇒ Object
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 |
#perform ⇒ Object
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 |