class Player
def play_turn(warrior)
@record_hp ||= warrior.health
if @record_hp > warrior.health
attack_action(warrior)
else
normal_action(warrior)
end
@record_hp = warrior.health
end
def normal_action(w)
w.health < 20 ? w.rest! : attack_action(w)
end
def attack_action(w)
w.feel.empty? ? w.walk! : w.attack!
end
end
class Player
def play_turn(warrior)
@record_hp ||= warrior.health
if @record_hp > warrior.health
attack_action(warrior)
else
normal_action(warrior)
end
@record_hp = warrior.health
end
def normal_action(w)
w.health < 20 ? w.rest! : attack_action(w)
end
def attack_action(w)
w.feel.empty? ? w.walk! : w.attack!
end
end