Skip to content

Instantly share code, notes, and snippets.

@webdev1001
Forked from briancicutti/gist:3035155
Created October 17, 2015 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdev1001/04a459981d5f5ac27c62 to your computer and use it in GitHub Desktop.
Save webdev1001/04a459981d5f5ac27c62 to your computer and use it in GitHub Desktop.
Ruby Warrior Beginner Level 4 Solution
class Player
def play_turn(warrior)
if warrior.feel.enemy?
warrior.attack!
else
if warrior.health < 20 && !taking_damage?(warrior)
warrior.rest!
else
warrior.walk!
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