-
Notifications
You must be signed in to change notification settings - Fork 837
LeckyBenginner
lecky edited this page Nov 21, 2010
·
9 revisions
class Player
def play_turn(warrior)
@action = false
@direction ||= :forward
# shoot_backward!
if warrior.look(:backward)[2].enemy? and !@action
warrior.shoot!(:backward)
@action = true
end
# walk_backward!
if warrior.look(:backward)[1].captive? and !@action
warrior.walk!(:backward)
@action = true
end
# rescue_backward!
if warrior.look(:backward)[0].captive? and !@action
warrior.rescue!(:backward)
@action = true
end
# pivot!
if !@action
for space in warrior.look
break if space.stairs? or space.captive?
@direction = :backward if space.wall?
end
end
# rescue!
if warrior.feel.captive? and !@action
warrior.rescue!
@action = true
end
# shoot!
if !@action
for space in warrior.look(@direction)
break if space.captive?
if space.enemy? and !@action
warrior.shoot!(@direction)
@action = true
end
end
end
# walk!
warrior.walk!(@direction) if !@action
end
end# End Class Player