Last active
August 29, 2015 14:03
-
-
Save ktym/754f4bf5477859efe15b to your computer and use it in GitHub Desktop.
Ruby Warrior Level 5 https://www.bloc.io/ruby-warrior
This file contains 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 | |
if warrior.feel.captive? | |
warrior.rescue! | |
elsif warrior.feel.enemy? | |
warrior.attack! | |
else | |
if warrior.health < 20 and !(warrior.health < @health) | |
warrior.rest! | |
else | |
warrior.walk! | |
end | |
end | |
@health = warrior.health | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment