Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Player
def play_turn(warrior)
if warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.feel.enemy?
warrior.attack!
@attacking = true
elsif not @health.nil? and warrior.health < @health
warrior.walk! @attacking ? :forward : :backward
elsif warrior.look[1].enemy? or
(warrior.look[1].empty? and warrior.look[2].enemy?)
warrior.shoot!
@attacking = true
elsif warrior.health == 20
warrior.walk!
@attacking = true
else
warrior.rest!
@attacking = false
end
@health = warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment