Skip to content

Instantly share code, notes, and snippets.

@haeky
Last active December 20, 2015 11:19
Show Gist options
  • Save haeky/6121972 to your computer and use it in GitHub Desktop.
Save haeky/6121972 to your computer and use it in GitHub Desktop.
class Player
def play_turn(warrior)
if warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.feel.enemy?
warrior.attack!
elsif warrior.look.at(2).enemy?
warrior.shoot!
elsif warrior.health < 20
if warrior.health - @health > -1
warrior.rest!
else
warrior.walk!(:backward)
end
else
warrior.walk!
end
@health = warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment