Skip to content

Instantly share code, notes, and snippets.

@F4R3LL
Last active November 23, 2017 08:42
Show Gist options
  • Save F4R3LL/03cf853d355a5e72ed50456216168058 to your computer and use it in GitHub Desktop.
Save F4R3LL/03cf853d355a5e72ed50456216168058 to your computer and use it in GitHub Desktop.
#Bloc.io - ruby-warrior - Level 6
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