rampup-october-2014/ruby-warrior — pull request #5 by atulgolhar (2014-11-11 14:54:42+00:00)
Title: Level 5 code solved

11/11/14 at 9:50am - I just solved Level 5. Code is here - but I think that I killed a captive (instead of saving them). The Ruby Warrior website does not seem to notice that I killed the captive. Not sure about this and will investigate later today.

class Player
MIN_HEALTH = 18

def play_turn(warrior)
warrior.health

if warrior.feel.empty?

if warrior.health < MIN_HEALTH && (warrior.health >= @last_known_health)
warrior.rest!

if warrior.feel.captive?
warrior.rescue!
end

else
warrior.walk!
end

else
warrior.attack!
end

@last_known_health = warrior.health
end

end