def room2():
    text.room2_text()
    safe_key = random.randint(1, 2)

    room2_choice = input("Please enter 1 or 2 to pick a key: ")

    choose = True
    while choose:
        if room2_choice == "1":
            if safe_key == 1:
                print(
                    "Congratulations, you unlocked the rabbit cage! You are safe to move on to the next room."
                )
                room3.room3()
            else:
                print("Unfortunately you died because the lion ate you.")
                lost.lost()
            choose = False
        elif room2_choice == "2":
            if safe_key == 2:
                print(
                    "Congratulations, you unlocked the rabbit cage! You are safe to move on to the next room."
                )
                room3.room3()
            else:
                print("Unfortunately you died because the lion ate you.")
                lost.lost()
            choose = False
        elif room2_choice == "exit":
            text.exit_game()
            choose = False
        else:
            room2_choice = input("Please enter 1 or 2 to pick a key: ")
            choose = True
def choose_door():
    win_door = random.randint(1, 2)

    choose = True
    while choose:
        door_choice = input("Enter 1 or 2 to choose a door: ")
        if door_choice == "1":
            if win_door == 1:
                text.win()
            else:
                text.return_to_room2_text()
                room2()
            choose = False
        elif door_choice == "2":
            if win_door == 2:
                text.win()
            else:
                text.return_to_room2_text()
                room2()
            choose = False
        elif door_choice == "exit":
            text.exit_game()
            choose = False
        else:
            choose = True
示例#3
0
def room3():
    text.room3_text()
    room3_choice = input(
        "1 is Protego (shield) and 2 is Sectunsempra (attack). Please enter 1 or 2: "
    )

    try_again = True

    while try_again:
        opponent_spell = random.randint(1, 2)
        if opponent_spell == 1:
            opponent_spell = "Protego"
        else:
            opponent_spell = "Sectumsempra"

        if room3_choice == "1":
            if opponent_spell == "Protego":
                print("OH NO! You and your opponent both chose Protego!")
                again = input(
                    "1 is Protego (shield) and 2 is Sectumsempra (attack). Please enter 1 or 2."
                )
                try_again = True
            else:
                print(
                    "Congratulations! You blocked your opponent's attack and bought time to escape into the next room safely"
                )
                try_again = False
                room4.room4()

        elif room3_choice == "2":
            if opponent_spell == "Protego":
                print(
                    "Congratulations! You attacked your opponent when they chose to shield."
                )
                print("You were able to escape safely to the next room!")
                try_again = False
                room4.room4()
            else:
                print(
                    "OH NO! Both you and your opponent attacked each other! You both died."
                )
                lost.lost()
                try_again = False

        elif room3_choice == "exit":
            text.exit_game()
            try_again = False

        else:
            room3_choice = input("Please enter 1 or 2: ")
            try_again = True
示例#4
0
def lost():
    print("Sorry you lost the game!")
    if_play_again = input(
        "If you would like to play again please enter play, if not then enter exit: "
    )

    choose = True
    while choose:
        if if_play_again == "play":
            introduction.introduction()
            choose = False
        elif if_play_again == "exit":
            text.exit_game()
            choose = False
        else:
            if_play_again = input(
                "Please enter play or exit (all in lowercase letters): ")
            choose = True
def room4():
    text.room4_text()
    room4_name = input(
        "First, choose your superhero! You can type in your favorite superhero or make one up just for yourself: "
    )
    print("Hello " + room4_name + " now you must choose a magic word")
    room4_choice = input(
        "Which magic word would you like to call, C924 or G420: ")

    choose = True
    while choose:
        superhero = random.randint(1, 2)
        if room4_choice == "C924":
            if superhero == 1:
                print(
                    "Congrats! You have picked the correct code name. A Superhero came and save you!"
                )
                print("Now you are faced with 2 doors to exit to.")
                choose_door()
            else:
                print(
                    "Sorry you pickd the wrong code name! You were killed by a villain."
                )
                lost.lost()
            choose = False
        elif room4_choice == "G420":
            if superhero == 1:
                print(
                    "Sorry you picked the wrong code name! You were killed by a villain."
                )
                lost.lost()
            else:
                print(
                    "Congrats! You have picked the correct code name. A Superhero came and save you!"
                )
                print("Now you are faced with 2 doors to exit to.")
                choose_door()
            choose = False
        elif room4_choice == "exit":
            choose = False
            text.exit_game()
        else:
            room4_choice = input("Please enter C924 or G429: ")
            choose = True
def introduction():
    print("Welcome to the Adventure Game!")
    print("Imagine you are stuck in a maze with many rooms and you can't see where you are.")
    print("You are only given the choice to choose a room. The adventure may be a safe or a dangerous one.")
    print("Whenever you want to leave you can enter exit (all lowercase letters)")
    print("There might be tricks coming your way.... Watch out and good luck! Most importantly, have fun!")
    print("Your first room is the starting room")

    welcome_room = input("You leave the first room and are faced with 2 rooms numbers 1 and 2. Enter 1 or 2: ")
    
    choose = True
    while choose:
        if welcome_room == "1":
            room1.room1()
            choose = False
        elif welcome_room == "2":
            room2.room2()
            choose = False
        elif welcome_room == "exit":
            text.exit_game()
            choose = False
        else:
            welcome_room = input("Please enter 1 or 2: ")
            choose = True
示例#7
0
def room1():
    text.room1_text()
    safe_book = random.randint(1, 2)

    choose = True
    while choose:
        room1_choice = input("Enter 1 or 2 to choose a book: ")
        if room1_choice == "1":
            if safe_book == 1:
                print(
                    "Congratulations, you found the key! You may use the key to move on to the second room."
                )
                room3.room3()
            else:
                print(
                    "Unfortunately you died because the books have fallen on you."
                )
                lost.lost()
            choose = False
        elif room1_choice == "2":
            if safe_book == 2:
                print(
                    "Congratulations, you found the key! You may use the key to move on to the second room."
                )
                room3.room3()
            else:
                print(
                    "Unfortunately you died because the books have fallen on you."
                )
                lost.lost()
            choose = False
        elif room1_choice == "exit":
            text.exit_game()
            choose = False
        else:
            choose = True