Last active
December 20, 2015 16:29
-
-
Save jansanchez/6161868 to your computer and use it in GitHub Desktop.
Ruby Warrior - Level 4
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
# Advertencia: este código está horrible, los métodos no me funcionan, pero sirve para pasar | |
# ruby warrior level 4 | |
# | |
class Player | |
def play_turn(warrior) | |
@health = warrior.health | |
if @needCure == nil | |
if @health < 18 | |
if @health < 15 | |
if @attack == nil | |
if @health < 3 | |
warrior.walk! :backward | |
@needCure = true | |
else | |
warrior.walk! | |
@attack = true | |
end | |
else | |
warrior.attack! | |
@attack = nil | |
end | |
else | |
warrior.walk! :backward | |
@needCure = true | |
end | |
else | |
if warrior.feel.empty? | |
warrior.walk! | |
else | |
warrior.attack! | |
end | |
end | |
else | |
warrior.rest! | |
if @health < 8 | |
@needCure = true | |
else | |
@needCure = nil | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment