I am currently trying to create a text based game. I am trying to make it so when you pick up items you have variable which reads 'True' so you can use the items in a different room. The problem I have currently is in one room you kill a monster so I create a variable in which the monster_is_dead = True, But once I move onto another function, the script forgets that the monster_is_dead.it is difficult to explain a lot of script to paste in but I will try and pick out the part of the script I am having trouble with.
def room_2():
riddle_monster_alive = True
while riddle_monster_alive:
print 'As you step into the room, you feel someone watching you.. You close the door behind you and hear the door click.\n you are locked in!'
print "You look up into the center of the room to be greeted by a strange creature,a Kappa"
print 'the creature calls out to you "You are lost here, You could die here. I could kill you now for my Master, but that is no fun."'
print '"How about we play a game? if you win, I will go, if you lose, I will eat you right now"'
import random
a = 'rock'
b = 'paper'
c = 'scissors'
rockpaperscissorlist = [a,b,c]
print 'The Kappa are known for their trickery and games, you best play his game'
print '"Rock,paper and scissors we play till one of us loses"'
game_choice = raw_input('Pick A:Rock B:Paper C:Scissors [a/b/c]\n>').lower()
kappa_choice = random.choice(rockpaperscissorlist)
elif game_choice == 'a' and kappa_choice == c:
print 'Kappa picks scissors'
print 'You Win!'
riddle_monster_alive = False
break
riddle_monster_alive == False
room_2a()
So I have a new function for room 2, in which the monster is dead. However the script gets complicated as I let the player move back rooms as they will end up in function room_2() again and have to play against the monster again.
def room_2a():
print 'The air is still as the Kappa has now vanished.'
print 'You see a door the right and a door to the left'
print 'What will you do?\n A:Take the door to the right\n B:Take the door to the left?\n C:Go back the way you came\n D:Search the room'
room2choice = raw_input('> ').lower()
if room2choice == 'a':
room_10()
elif room2choice == 'b':
room_3()
elif room2choice == 'c':
room_1a()
elif room2choice == 'd':
print 'You searched but found nothing but a puddle of water from where the Kappa once stood'
room_2a()
I feel like I am making this more complicated than necessary.