Created
November 5, 2013 12:09
-
-
Save webcrafts/7318136 to your computer and use it in GitHub Desktop.
Ruby Warrior Level.4
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 | |
if @health.nil? then | |
@health = warrior.health | |
end | |
if @health > warrior.health then | |
if warrior.feel.empty? then | |
warrior.walk! | |
else | |
warrior.attack! | |
end | |
elsif warrior.feel.enemy? then | |
warrior.attack! | |
else | |
if warrior.health < 20 then | |
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