как я могу остановить функцию 'room5', в то время как room6 'работает - PullRequest
0 голосов
/ 31 октября 2019

я пишу простую игру в слова и упрощенно в одной части игры, игрок должен ответить на загадку (комната 5), а затем перейти в другую комнату с пронумерованным замком (комната 6). когда игрок вводит правильный номер, он снова и снова задает один и тот же вопрос из комнаты 5. есть ли способ, которым я могу остановить это, чтобы игрок мог прогрессировать?

def room5():
    loop5 = True
    time.sleep(1)
    print("You enter a room with blood splatter on the walls")
    print("You decipher a sentence on the wall")
    while loop5 == True:
        print("What has 88 keys but can’t open a single door?")
        print("What is the answer")
        print("You may 'come back' later if you do not know")
        choice = input("> ")
        if choice.lower() == "keyboard":
            time.sleep(1)
            print("You whisper the word")
            print("The number 9 appears on the wall")
            print("Remember this number")
            hallway()
            loop5 = False
        if choice.lower().startswith("c"):
            loop5 = False
            hallway()

        else:
            time.sleep(1)
            print("You whispered the word and nothing happened")
            print("Try again or go back to the hallway")

time.sleep(1)
print("You enter a hallway")
print("there are 6 doors")
print("Which door would you like to enter: 1,2,3,4,5,6")
choice = input("> ")

while loop == True:
    if choice == "2":
        room2()
    if choice == "3":
        room3()
    if choice == "4":
        room4()
    if choice == "5":
        room5()
    if choice == "6":
        loopme = True
        time.sleep(1)
        print("You come across a door with a number lock on it")
        print("Enter the 4 digit code")
        while loopme == True:
            choice = input("> ")
            if choice == "2849":
                print("The lock fell off, the door swings open for you to walk through")
                loop = False
                loopme = False
            else:
                print("You enter the code and nothing happened")
                hallway()

код должен просто заканчиваться словами: «Замок упал, дверь распахивается, чтобы вы могли пройти», выведенный наэкран

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...