Last active
November 23, 2017 08:42
-
-
Save F4R3LL/03cf853d355a5e72ed50456216168058 to your computer and use it in GitHub Desktop.
#Bloc.io - ruby-warrior - Level 6
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) | |
if warrior.feel.stairs? && !warrior.feel.captive? && !warrior.feel.enemy? | |
warrior.walk! | |
elsif warrior.feel(:backward).captive? | |
warrior.rescue!:backward | |
elsif !warrior.feel(:backward).wall? && @hitWall != 1 | |
warrior.walk!:backward | |
@hitWall = 1 | |
elsif warrior.feel.enemy? | |
warrior.attack! | |
elsif damageTaken(warrior) && !warrior.feel(:backward).wall? | |
if @rush == 1 && @hitWall == 1 | |
warrior.walk! | |
else | |
warrior.walk!:backward | |
end | |
elsif warrior.health < 20 | |
warrior.rest! | |
else | |
warrior.walk! | |
end | |
@health = warrior.health | |
end | |
def damageTaken(warrior) | |
@health > warrior.health #return state of health$ | |
if @health == 20 | |
@rush = 1 | |
else | |
@rush = 0 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment