Class: RubyWarrior::Units::Wizard

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

Instance Attribute Summary

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

#initializeWizard

Returns a new instance of Wizard.



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

def initialize
  add_abilities :shoot!, :look
end

Instance Method Details

#characterObject



29
30
31
# File 'lib/ruby_warrior/units/wizard.rb', line 29

def character
  "w"
end

#max_healthObject



25
26
27
# File 'lib/ruby_warrior/units/wizard.rb', line 25

def max_health
  3
end

#play_turn(turn) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ruby_warrior/units/wizard.rb', line 8

def play_turn(turn)
  [:forward, :left, :right].each do |direction|
    turn.look(direction).each do |space|
      if space.player?
        turn.shoot!(direction)
        return
      elsif !space.empty?
        break
      end
    end
  end
end

#shoot_powerObject



21
22
23
# File 'lib/ruby_warrior/units/wizard.rb', line 21

def shoot_power
  11
end