Skip to content

Instantly share code, notes, and snippets.

@wwkeyboard
Created September 25, 2012 00:17
Show Gist options
  • Save wwkeyboard/3779252 to your computer and use it in GitHub Desktop.
Save wwkeyboard/3779252 to your computer and use it in GitHub Desktop.
Player from the 9/24 class
class Player
attr_accessor :warrior
def initialize
@old_health = 20
end
def play_turn(warrior)
@warrior = warrior
if warrior.feel.empty?
normal_move
else
obstruction_move
end
@old_health = warrior.health
end
def obstruction_move
if warrior.feel.captive?
warrior.rescue!
else
warrior.attack!
end
end
def normal_move
if healthy? or taking_damage?
@warrior.walk!
else
@warrior.rest!
end
end
def taking_damage?
@old_health > @warrior.health
end
def healthy?
@warrior.health == 20
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment