Skip to content

Instantly share code, notes, and snippets.

@kevinnio
Created May 7, 2014 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinnio/d4dd56855054f93aad16 to your computer and use it in GitHub Desktop.
Save kevinnio/d4dd56855054f93aad16 to your computer and use it in GitHub Desktop.
Código del nivel 5, modo Beginner de RubyWarrior
class Player
def play_turn(warrior)
@health = 0 if not @health
if warrior.feel.empty?
(warrior.health < 20 and not taking_damage? warrior) ? warrior.rest! : warrior.walk!
else
warrior.feel.captive? ? warrior.rescue! : warrior.attack!
end
@health = warrior.health
end
def taking_damage?(warrior)
@health > warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment