Skip to content

Instantly share code, notes, and snippets.

@webcrafts
Created November 5, 2013 12:09
Show Gist options
  • Save webcrafts/7318136 to your computer and use it in GitHub Desktop.
Save webcrafts/7318136 to your computer and use it in GitHub Desktop.
Ruby Warrior Level.4
class Player
def play_turn(warrior)
# cool code goes here
if @health.nil? then
@health = warrior.health
end
if @health > warrior.health then
if warrior.feel.empty? then
warrior.walk!
else
warrior.attack!
end
elsif warrior.feel.enemy? then
warrior.attack!
else
if warrior.health < 20 then
warrior.rest!
else
warrior.walk!
end
end
@health = warrior.health
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment