Skip to content

Instantly share code, notes, and snippets.

@anagri
Created January 8, 2012 20:41
Show Gist options
  • Save anagri/1579614 to your computer and use it in GitHub Desktop.
Save anagri/1579614 to your computer and use it in GitHub Desktop.
ruby warrior
class Player
def play_turn(warrior)
if @backward.nil?
if warrior.feel(:backward).captive?
warrior.rescue!(:backward)
elsif warrior.feel(:backward).empty?
warrior.walk!(:backward)
else
@backward = true
warrior.walk!
end
else
if warrior.feel.enemy?
warrior.attack!
elsif warrior.feel.captive?
warrior.rescue!
elsif warrior.health < 13
if @health > warrior.health
warrior.walk!
else
warrior.rest!
end
else
warrior.walk!
end
end
@health = warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment