Now, I just can't seem to figure it out
What i'm after I think is a global Boolean that'll be set to False unless door two has been accessed then it'll flip the Boolean to be True but because i'm invoking roomChoice() to go back to the start after entering room two it's all being restarted. Just wondering the logic to achieve this.
try and ignore the horrible mess that is this code ha, I'm doing this program in an attempt to convert from Java to Python and learn Vim in the process, so just slowly learning here.
global key = False
def roomChoice():
print("It is now time to make a decision, so go on, 1, 2 or 3")
userinput = int(input())
while userinput != 1 or 2 or 3:
if(userinput == 1):
print("Doors locked")
roomChoice()
elif(userinput == 1 and key == True):
print(
"You've entered the room, it's now time to decide if you want to steal the wallet?")
userinput = input()
if(userinput == "yes"):
print("Nice move, quick lets get out of here")
elevator()
elif(userinput == "no"):
print("Well, on your way back to the elevator someone sees you coming out of the apartment, later they realise a wallet has been stolen, because you have been seen at the crime you are falsely imprisoned for burglary. 10 years, the judge really didn’t like you.")
exit()
else:
roomChoice()
elif(userinput == 2):
print("Oh look a key, I wonder if that'll get you into room one?")
key = True
roomChoice()
else:
roomChoice()
break
Aucun commentaire:
Enregistrer un commentaire