Class: RubyWarrior::Units::Captive

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_warrior/units/captive.rb

Instance Attribute Summary collapse

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

#initializeCaptive

Returns a new instance of Captive.



6
7
8
9
# File 'lib/ruby_warrior/units/captive.rb', line 6

def initialize
  add_abilities :explode!
  bind
end

Instance Attribute Details

#bomb_timeObject

Returns the value of attribute bomb_time.



4
5
6
# File 'lib/ruby_warrior/units/captive.rb', line 4

def bomb_time
  @bomb_time
end

Instance Method Details

#characterObject



15
16
17
# File 'lib/ruby_warrior/units/captive.rb', line 15

def character
  "C"
end

#max_healthObject



11
12
13
# File 'lib/ruby_warrior/units/captive.rb', line 11

def max_health
  1
end

#play_turn(turn) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/ruby_warrior/units/captive.rb', line 19

def play_turn(turn)
  if @bomb_time
    @bomb_time -= 1
    if @bomb_time.zero?
      @bound = false # unbind so it can perform an action
      turn.explode!
    end
  end
end