-
-
Save webdev1001/04a459981d5f5ac27c62 to your computer and use it in GitHub Desktop.
Ruby Warrior Beginner Level 4 Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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