So I've been going through the "Learn Ruby the Hard Way" and I'm essentially done and just putting the finishing touches on my text RPG game they have you make. Mad props to Mattseh for helping me understand key part about passing and receiving variables. But I have a bug that I cannot figure out. Here is the error:
This code is 500 lines, so I'm only to post the relevant part. Below is how I'm running the program to start:
Then it all starts in the "reincarnation" function, which is below:
I have a feeling that I'm messing up somewhere with passing the variable through the symbol, into the hash, and into the method, and into the function. I'm new so I don't even know if I'm communicating this well. I'm hoping someone can set me straight on this! Haaaalp!
I appreciate it.
Code:
game.rb:429: syntax error, unexpected '(', expecting ')'
game.rb:429: syntax error, unexpected ')', expecting '='
This code is 500 lines, so I'm only to post the relevant part. Below is how I'm running the program to start:
Code:
ROOMS = {
:death => method(:death),
:reincarnation => method(:reincarnation(reincarnate, jewel_hallway, jewel_cavern, jewel_stairway)),
:beginning_room => method(:beginning_room),
:trap_first => method(:trap_first),
:hallway_boss => method(:hallway_boss),
:cavern_room => method(:cavern_room),
:sanctuary_room => method(:sanctuary_room),
:priest_room => method(:priest_room),
:giant_doorway => method(:giant_doorway),
:money_loop => method(:money_loop),
:to_the_beast => method(:to_the_beast),
:dragon_two => method(:dragon_two),
:dragon_three => method(:dragon_three)
}
def runner(map, start)
next_one = start
while true
room = map[next_one]
puts "\n--------"
next_one = room.call()
end
end
reincarnate = false
jewel_hallway = false
jewel_cavern = false
jewel_stairway = false
runner(ROOMS, :reincarnation(reincarnate, jewel_hallway, jewel_cavern, jewel_stairway))
Then it all starts in the "reincarnation" function, which is below:
Code:
def reincarnation(reincarnate, jewel_hallway, jewel_cavern, jewel_stairway)
if reincarnate == false
puts "blah"
return :beginning_room
elsif jewel_hallway == true and jewel_cavern == true and jewel_stairway == true
puts "blah"
return :giant_doorway
else
puts "blah"
return :beginning_room
end
end
I have a feeling that I'm messing up somewhere with passing the variable through the symbol, into the hash, and into the method, and into the function. I'm new so I don't even know if I'm communicating this well. I'm hoping someone can set me straight on this! Haaaalp!
I appreciate it.