Skip to content

Instantly share code, notes, and snippets.

@asecondwill
Created November 2, 2013 05:04
Show Gist options
  • Save asecondwill/7275733 to your computer and use it in GitHub Desktop.
Save asecondwill/7275733 to your computer and use it in GitHub Desktop.
Ruby Warrior Level 4
class Player
def play_turn(warrior)
if @health.nil?
@health = warrior.health
end
if warrior.feel.enemy?
warrior.attack!
else
if warrior.health > 12 or taking_damage?(warrior)
warrior.walk!
else
warrior.rest!
end
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