Skip to content

Instantly share code, notes, and snippets.

@jansanchez
Last active December 20, 2015 19:18
Show Gist options
  • Save jansanchez/6181792 to your computer and use it in GitHub Desktop.
Save jansanchez/6181792 to your computer and use it in GitHub Desktop.
Ruby Warrior - Level 5
# ruby warrior level 5
#
class Player
def play_turn(warrior)
@health = warrior.health
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 < 8
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment