Skip to content

Instantly share code, notes, and snippets.

@jansanchez
Created August 8, 2013 07:05
Show Gist options
  • Save jansanchez/6182230 to your computer and use it in GitHub Desktop.
Save jansanchez/6182230 to your computer and use it in GitHub Desktop.
Ruby Warrior - Level 7
# ruby warrior level 7
#
class Player
def play_turn(warrior)
@health = warrior.health
if @need_health == nil
if warrior.feel.wall?
warrior.pivot! :backward
@turn = true
else
if @turn == true
if warrior.feel.empty?
warrior.walk!
else
if warrior.feel.enemy?
if @health < 13
warrior.attack!
elsif @health < 18
warrior.walk! :backward
@need_health = true
else
warrior.attack!
end
else
warrior.walk!
end
end
end
end
else
warrior.rest!
@need_health = nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment