Skip to content

Instantly share code, notes, and snippets.

@marcamillion
Last active December 20, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcamillion/6118302 to your computer and use it in GitHub Desktop.
Save marcamillion/6118302 to your computer and use it in GitHub Desktop.
class Player
def play_turn(warrior)
if warrior.feel.empty? && !taking_damage?(warrior) && warrior.health < 20
warrior.rest!
elsif warrior.feel.empty?
warrior.walk!
else
warrior.attack!
end
@health = warrior.health
end
def taking_damage?(warrior)
warrior.health < @health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment