Last active
December 30, 2015 21:09
-
-
Save Videmor/7886010 to your computer and use it in GitHub Desktop.
Ruby Warrior - Level 4 : No new abilities this time, but you must be careful not to rest while taking damage. Save a @health instance variable and compare it on each turn to see if you're taking damage.
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) | |
| # cool code goes here | |
| @health = warrior.health unless @health | |
| if warrior.feel.enemy? | |
| warrior.attack! | |
| elsif warrior.health < 8 or @health < warrior.health | |
| warrior.rest! | |
| else | |
| warrior.walk! | |
| end | |
| @health = warrior.health | |
| end | |
| end | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demo
class Player
def play_turn(warrior)
# cool code goes here
end
end