Skip to content

Instantly share code, notes, and snippets.

@jansanchez
Created August 8, 2013 06:50
Show Gist options
  • Save jansanchez/6182139 to your computer and use it in GitHub Desktop.
Save jansanchez/6182139 to your computer and use it in GitHub Desktop.
Ruby Warrior - Level 6
# ruby warrior level 6
#
class Player
def play_turn(warrior)
@health = warrior.health
if @rescued == nil
if @ret == nil
@ret = true
warrior.walk! :backward
else
@rescued = true
warrior.rescue! :backward
end
else
if @need_health == nil
if warrior.feel.empty?
unless warrior.feel.wall?
warrior.walk!
end
else
if warrior.feel.captive?
warrior.rescue!
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! :forward
end
end
end
else
warrior.rest!
@need_health = nil
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment