Skip to content

Instantly share code, notes, and snippets.

@ravicious
Created July 29, 2013 08:30
Show Gist options
  • Save ravicious/6102941 to your computer and use it in GitHub Desktop.
Save ravicious/6102941 to your computer and use it in GitHub Desktop.
class Player
@rescued_captive = false
def play_turn(warrior)
@current_health = warrior.health
if not @rescued_captive
if warrior.feel(:backward).captive?
warrior.rescue! :backward
@rescued_captive = true
else
warrior.walk! :backward
end
else
if warrior.feel.enemy?
warrior.attack!
elsif warrior.feel.captive?
warrior.rescue!
elsif @current_health < 15
if took_damage? # if archers are shooting you
warrior.walk! :backward
else
warrior.rest!
end
else
warrior.walk!
end
end
@previous_health = warrior.health
end
def took_damage?
@current_health < @previous_health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment