I learn programming through Ruby and I found the amazing Rubywarrior Ryan Bates from Railscasts. Unfortunately, I'm stuck with my code causing syntax error messages (unexpected end of $).
I do not ask for an answer, I would like to deal with it myself, but if someone can indicate where my code is getting the error from, it will be super. Thank!
class Player
def initialize
@maxhealth = 20
@dying = 7
@previoushealth = @maxhealth
@health = warrior.health
@warrior = warrior
end
def play_turn(warrior)
turn_start_check(warrior)
actions(warrior)
turn_end_check(warrior)
end
def actions(warrior)
if @damaged_since_last_turn
warrior.shoot!
elsif
@health < @maxhealth
warrior.rest!
else
warrior.walk!
end
end
def hurt?(warrior)
warrior.health < 20
end
def healthy?(warrior)
warrior.health = 20
end
def alone?(warrior)
warrior.feel.empty?
end
def should_i_move?(warrior)
if healthy? and alone?
warrior.rest!
else
warrior.walk!
end
def turn_start_check(warrior)
@damaged_since_last_turn = @previoushealth > warrior.health
end
def turn_end_check(warrior)
@previoushealth = warrior.health
end
end
source
share