Exemplo n.º 1
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room7_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == 'east':
                next_room = 8
                done_with_room = True
            elif go_where == 'north':
                if utils.has_a(player_inventory, 'golden goblet') == True:
                    print("The door is slammed shut")
                else:
                    next_room = 2
                    done_with_room = True
            else:
                print('You cannot go:', go_where)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, r7_inventory, take_what)
            if take_what == 'golden goblet':
                print("The door suddenly slams to the north!")
        elif the_command == 'drop':
            response = utils.scrub_response(response)
            drop_what = response[1]
            utils.drop_item(player_inventory, r7_inventory, drop_what)
            if drop_what == 'golden goblet':
                print("The door to the north swings back open!")
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(r7_inventory)
        elif the_command == 'examine':
            print(room7_description)
        elif the_command == 'help':
            utils.player_help()
        else:
            print("The command:", the_command,
                  "has not been implemented in Room 7")

    # END of WHILE LOOP
    return next_room
Exemplo n.º 2
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room5_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == 'north':
                next_room = 4
                done_with_room = True
            elif go_where == 'south':
                next_room = 6
                done_with_room = True
            elif go_where == 'east':
                next_room = 13
                done_with_room = True
            else:
                print("Can't go", go_where)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, room5_inventory, take_what)
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(room5_inventory, room5_interacts)
        elif the_command == 'drop':
            response = utils.scrub_response(response)
            drop_what = response[1]
            utils.drop_item(player_inventory, room5_inventory, drop_what)
        elif the_command == 'help':
            print(
                "The valid commands are",
                commands,
                no_args,
            )
        else:
            print("that command is not supported yet")
    # END of WHILE LOOP
    return next_room
Exemplo n.º 3
0
def run_room(player_inventory):
    room2_description = '''
    . . . 2nd room ...
    You are in a brightly lit room. The room appears to be an office. There is a desk in the center of the room with
    a key and a flask on top. Next to the desk lies a unremarkable short sword covered in webs and dust. There is an exit 
    to the NORTH and to the SOUTH.'''

    print(room2_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0]

        if the_command == 'go':
            direction = response[1]
            # Use your hand drawn map to help you think about what is valid
            if direction == 'north':
                next_room = 1
                done_with_room = True
            elif direction == 'south':
                next_room = 7
                done_with_room = True
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go,", direction)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, r2_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, r2_inventory, drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(r2_inventory)
        elif the_command == 'examine':
            print(room2_description)
        elif the_command == 'help':
            utils.player_help()
        else:
            print("Command not implemented in ROOM 2,", the_command)

    # end of main while loop
    return next_room
Exemplo n.º 4
0
def run_room(player_inventory):

    room10_description = '''
    . . . 10th Room ...
    The room is filled entirely with smoke. You can barely make out the door to the south. 
    The source of the smoke must be close by.
    '''

    print(room10_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1
    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands, no_args)
        the_command = response[0]

        if the_command == 'go':
            direction = response[1]
            # Use your hand drawn map to help you think about what is valid
            if direction == 'west':
                next_room = 6
                done_with_room = True
            elif direction == 'south':
                next_room = 11
                done_with_room = True
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go,", direction)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, room10_inventory, take_what)
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(room10_inventory, room10_interacts)
        elif the_command == 'drop':
            response = utils.scrub_response(response)
            drop_what = response[1]
            utils.drop_item(player_inventory, room10_inventory, drop_what)
        elif the_command == 'help':
            print("The valid commands are", commands, no_args, )
        else:
            print("Command not implemented in ROOM 2,", the_command)

    # end of main while loop
    return next_room
Exemplo n.º 5
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    utils.print_description(room9_description)


    # valid commands for this room
    commands = ["go", "take", "drop", "use", "status"]
    no_args = ["status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands, no_args)
        response = utils.scrub_response(response)
        the_command = response[0]

        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == 'south':
                is_locked = room8_state['door locked']
                if not is_locked:
                    next_room = 8
                    done_with_room = True
                else:
                    print('The door to Room 8 is locked.')
            else:
                print('You cannot go:', go_where)
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room9_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room9_inventory, drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(room9_inventory)
        elif the_command == 'use':
            use_what = response[1]
            if use_what in player_inventory:
                if use_what == 'key':
                    direction = utils.prompt_question('Which door would you like to use the key on?', ['south'])
                    if direction.lower() == 'south':
                        print('The door was already unlocked')

                else:
                    print('You have no way to use:', use_what)
            else:
                print("You don't have:", use_what)
        else:
            print('The command:', the_command, 'has not been implemented in room 9.')


            # END of WHILE LOOP
    return next_room
Exemplo n.º 6
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room5_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "examine", "status", "unlock"]
    no_args = ["examine", "status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    print(
        "the face on the door's eyes glow red as it says, in order to pass ye must answer me."
    )
    response = input(
        "What is it that when you take away the whole, \nyou still have some left over?"
    )
    while not response.lower() == "wholesome":
        print("WRONG!!!!.")
        response = input(
            "Try again. What is it that when you take away the whole, \nyou still have some left over?"
        )
    utils.player_health["health"] = 20
    print("you pass, I have restored you to your full health")
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "north":
                next_room = 7
                done_with_room = True
            elif go_where == "south":
                next_room = 3
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room5_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room5_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room5_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room5_inventory, room5_locked,
                         response)
        else:
            print("The command:", the_command,
                  "has not been implemented in room 5")

    return next_room
Exemplo n.º 7
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room3_description)
    global kobold_alive

    # valid commands for this room
    commands = ["go", "take", "drop", "examine", "status", "unlock", "attack"]
    no_args = ["examine", "status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1
    kobold_health = 12
    kobold_atk_org = 5


    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands, no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)

        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "west":
                next_room = 1
                done_with_room = True
            elif go_where == "north":
                next_room = 5
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room3_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room3_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room3_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room3_inventory, room3_locked, response)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "kobold", kobold_health, kobold_alive, response)
            kobold_health = x
            if x <= 0:
                print("the kobold is dead")
                kobold_alive = False
        else:
            print("The command:", the_command, "has not been implemented in room 3")
        x = utils.creature_action(kobold_alive, player_inventory, kobold_atk_org, "kobold")
        if x:
            next_room = 666
            done_with_room = True
    return next_room
Exemplo n.º 8
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room5_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == 'south':
                next_room = 4
                done_with_room = True
            elif go_where == 'west':
                next_room = 6
                done_with_room = True
            else:
                print('You cannot go:', go_where)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, r5_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, r5_inventory, drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(r5_inventory)
        elif the_command == 'examine':
            print(room5_description)
        elif the_command == 'use':
            use_what = response[1]
            if use_what == 'button':
                player_inventory['special_item2'] = 7
                print("The button is pressed")
        elif the_command == 'help':
            utils.player_help()
        else:
            print("The command:", the_command,
                  "has not been implemented in Room 5")

    # END of WHILE LOOP
    return next_room
Exemplo n.º 9
0
def run_room(player_inventory):
    description = '''
    . . . Main Room . . .
    You open your eyes. The room you see is unfamiliar. You see a brightly lit
    doorway to the SOUTH. To the EAST you see a closed door. 

    '''
    print(description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "unlock"]
    no_args = ["examine", "status"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        if the_command == 'go':
            direction = response[1].lower()
            # Use your hand drawn map to help you think about what is valid
            if direction == 'south':
                next_room = 2
                done_with_room = True
            elif direction == 'east':
                is_locked = room1_locked["east"]
                if not is_locked:
                    next_room = 3
                    done_with_room = True
                if is_locked:
                    print("door is locked")
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go,", direction)
        elif the_command == 'take':
            utils.take(player_inventory, room1_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room1_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room1_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room1_inventory, room1_locked,
                         response)
    # end of while loop
    return next_room
Exemplo n.º 10
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room8_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "unlock"]
    no_args = ["examine", "status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands, no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "north":
                next_room = 4
                done_with_room = True
            elif go_where == "south":
                next_room = 10
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room8_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room8_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room8_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room8_inventory, room8_locked, response)
        else:
            print("The command:", the_command, "has not been implemented in room 8")
        if not utils.has_a(player_inventory, "antidote"):
            utils.player_health["health"] = utils.player_health["health"] - 2
            print("your throat is burning and your eyes water, you lose two hp")
            if utils.player_health["health"] <= 0:
                next_room = 666
                done_with_room = True
    return next_room
Exemplo n.º 11
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room6_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "examine", "status", "unlock"]
    no_args = ["examine", "status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "east":
                next_room = 4
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room6_inventory, response)
            print("debug response", response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room6_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room6_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room6_inventory, room6_locked,
                         response)
        else:
            print("The command:", the_command,
                  "has not been implemented in room 6")
    return next_room
Exemplo n.º 12
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room15_description = '''
        . . .  15th room ... 
        You find yourself in a dead end room. 
        '''

    if room15_inventory['death mage'] > 0:
        room15_description = room15_description + " A robed death mage floats in front of you. He seems to be guarding something."
    if room15_inventory['magic key'] > 0:
        room15_description = room15_description + " A magic key sits on a pedestal. It is embellished with jewels and gold."
    if room15_inventory['minor healing potion'] > 0:
        room15_description = room15_description + " A minor healing potion sits in a corner."
    print(room15_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1
    mage_health = 30
    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'north':
                next_room = 14
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            if take_what == 'magic key':
                if room15_inventory['death mage'] > 0:
                    print(
                        "The death mage is still in your way. It begins to move forward."
                    )
                else:
                    utils.take_item(player_inventory, room15_inventory,
                                    take_what)

            if take_what != 'magic key':
                if room15_inventory['death mage'] > 0:
                    print(
                        "The Death Mage is still in your way. It begins to move forward."
                    )
                else:
                    utils.take_item(player_inventory, room15_inventory,
                                    take_what)
        elif the_command == 'use':
            use_what = response[1].lower()
            if use_what == 'sword':
                if 'sword' in player_inventory.keys():
                    if room15_inventory['death mage'] > 0:
                        blah = True
                        while blah == True:
                            r = random.randrange(21)
                            if r > 11:
                                if mage_health > 10:
                                    print("You slice across the mage's chest.")
                                    mage_health = mage_health - 10
                                    print("The death mage's health is now: ",
                                          mage_health)
                                    response = utils.ask_command(
                                        "What do you want to do?", commands,
                                        no_args)
                                if mage_health == 10:
                                    blah = False
                                    room15_inventory['death mage'] = 0
                                    print(
                                        "You stab the mage in the heart and it dies in a pile of ashes."
                                    )
                                if mage_health == 0:
                                    print("The mage is dead Donny.")
                            else:
                                print("You missed!")
                                player_inventory[
                                    'health'] = player_inventory['health'] - 20
                                print(
                                    "He attacks you with a flame spell for twenty points of damage. Your health is now",
                                    player_inventory['health'])
                                if player_inventory['health'] <= 0:
                                    print(
                                        "The death mage engulfs you in a final cloud of flames, and you fall down dead. GAME OVER!"
                                    )
                                    blah = False
                                    break
                                else:
                                    print("Keep fighting!")
                                    response = utils.ask_command(
                                        "What do you want to do?", commands,
                                        no_args)
                    else:
                        print("You swing at nothing.")
                else:
                    print("You don't have a weapon DONNY!!!")
            elif use_what == 'bowling ball':
                if 'bowling ball' in player_inventory.keys():
                    print(
                        "The bowling ball sails through the air, and hits the mage in the chest. The death mage is thrown against the wall, and dies instantly."
                    )
                    room15_inventory['death mage'] = 0
                    mage_health = 0
                else:
                    print("You don't have a bowling ball stupid.")
            else:
                print("This item cannot kill the death mage!")
        elif the_command == 'status':
            utils.room_status(room15_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room15_inventory, drop_what)
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'map':
                utils.map(player_inventory)
        elif the_command == 'drink':
            if room15_inventory['death mage'] > 0:
                print("The death mage prevents you from doing this.")
            else:
                potion = response[1]
                if potion == 'healing potion':
                    if player_inventory['healing potion'] == 1:
                        print(
                            "You drink a healing potion. You gain 20 hit points."
                        )
                        player_inventory[
                            'health'] = player_inventory['health'] + 20
                        print("Your health is now:",
                              player_inventory['health'])
                elif potion == 'minor healing potion':
                    if player_inventory['minor healing potion']:
                        print(
                            "You drink the minor healing potion. You gain 10 hit points."
                        )
                        player_inventory[
                            'health'] = player_inventory['health'] + 10
                        print("Your health is now:",
                              player_inventory['health'])
                else:
                    print("You do not have a healing potion Donny.")

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 13
0
def run_room(player_inventory, player_equipped, combat_off_inventory,
             combat_spell_inventory, mobs, player_health):
    description = (
        "\nThe red light still shines in the dimly light room, exposing the gruesome scene of what used to"
        "\nguards. To the west is a mossy wall stained with blood. To the east is a wall with guard's corpse"
        "\npropped up against it. In the center are the torn shackles and another corpse. There's a passage going"
        "\nnorth.\n")

    print(description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "status", "loot", "equip"]
    no_args = ["loot", "equip"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0]
        if the_command == 'go':
            direction = response[1]
            # Use your hand drawn map to help you think about what is valid
            if direction == 'north':
                if room_state['encounter']:
                    print(
                        "As you go to enter the next room, a Young Wolf attacks you!"
                    )
                    utils.combat(player_equipped, player_inventory,
                                 combat_off_inventory, combat_spell_inventory,
                                 mobs, mob, player_health, rat_attack)
                    room_state['encounter'] = False
                    if player_health['pl_hp'] <= 0:
                        next_room = 15
                        done_with_room = True
                    else:
                        next_room = 2
                        done_with_room = True
                else:
                    next_room = 2
                    done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, room1_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room1_inventory, drop_what)
        elif the_command == 'status':
            status = response[1]
            if status == 'player':
                utils.player_status(player_inventory, player_equipped,
                                    player_health)
            elif status == 'room':
                utils.room_status(room1_inventory, room1_map,
                                  room1_loot_sources)
            else:
                print("That is not a valid option.")
        elif the_command == 'equip':
            utils.equip_item(player_equipped, player_inventory)
        elif the_command == 'loot':
            while True:
                print("The available loot sources are:\n")
                for key in room1_loot_sources.keys():
                    print("\t\t", key)
                chosen = input(
                    "\nWhich would you like to loot? Type 'Q' if you wish to stop looting.\n\t"
                )
                chosen = chosen.title()
                if chosen == 'Q':
                    break
                elif chosen in room1_loot_sources:
                    utils.loot(chosen, room1_loot_sources, player_inventory)
                    break
                else:
                    print("That is not an available loot source.\n")
        elif the_command == 'use':
            interaction = response[1]
            if interaction == 'heal':
                if room_state['heal']:
                    if utils.has_a(player_inventory, 'Bolster'):
                        utils.heal(player_health, player_inventory,
                                   combat_spell_inventory)
                        room_state['heal'] = False
                    elif utils.has_a(player_inventory, 'Heal'):
                        utils.heal(player_health, player_inventory,
                                   combat_spell_inventory)
                        room_state['heal'] = False
                    else:
                        print("You do not have the heal spell!")
                else:
                    print("You have already used your heal in this room!\n")
            else:
                print("That is not an option in this room.")
        else:
            print("\n\tThat is not an available command in this room.\n\t")

    if player_health['pl_hp'] <= 0:
        print("A light consumes you...")
    else:
        print("\n\tYou press on the door and it slowly creaks ajar.")
        print("********************************************************")
    # end of while loop
    return next_room
Exemplo n.º 14
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room9_description = '''
        . . .  9th room ... 
        This room is brightly lit with candles, and the granite walls are slick with dew.
        '''

    if room9_inventory['gold key'] > 0:
        room9_description = room9_description + " The gold key hangs from a hook."
    if room9_inventory['holy hand grenade'] > 0:
        room9_description = room9_description + " A holy hand grenade rests on a golden pillow."
    print(room9_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0]

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'west':
                next_room = 8
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room9_inventory, take_what)
        elif the_command == 'status':
            utils.room_status(room9_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room9_inventory, drop_what)
        elif the_command == 'drink':
            potion = response[1]
            if potion == 'healing potion':
                if player_inventory['healing potion'] == 1:
                    print(
                        "You drink a healing potion. You gain 20 hit points.")
                    player_inventory[
                        'health'] = player_inventory['health'] + 20
                    print("Your health is now:", player_inventory['health'])
            elif potion == 'minor healing potion':
                if player_inventory['minor healing potion']:
                    print(
                        "You drink the minor healing potion. You gain 10 hit points."
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] + 10
                    print("Your health is now:", player_inventory['health'])
            else:
                print("You do not have a healing potion Donny.")
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'holy hand grenade':
                print("The grenade has directions that read:")
                phoo = '''
                
                And the Lord spake, saying, First shalt
               thou take out the Holy Pin.

               Then, shalt thou count to three, no more,
               no less.

              Three shalt be the number thou shalt
              count, and the number of the counting
              shalt be three.

              Four shalt thou not count,
              nor either count thou two, excepting that
              thou then proceed to three.

              Five is right out. 

              Once the number three,
              being the third number, be reached, then
              lobbest thou thy Holy Hand Grenade of
              Antioch towards thy foe, who being
              naughty in my sight, shall snuf it.
              '''
                print(phoo)
            if examine_what == 'map':
                utils.map(player_inventory)

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 15
0
def run_room(player_inventory):
    global rat_alive
    description = '''
    . . . 
    You are in a brightly lit room. The room appears to be an office. There are doors exiting heading west and north.
    There is a large rat lying on the table.'''

    print(description)

    # valid commands for this room
    commands = ["go", "take", "drop", "examine", "status", "attack", "unlock"]
    no_args = ["examine", "status"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1
    rat_health = 5
    rat_atk_org = 3

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        if the_command == 'go':
            direction = response[1].lower()
            # Use your hand drawn map to help you think about what is valid
            if direction == 'north':
                next_room = 1
                done_with_room = True
            elif direction == "west":
                next_room = 4
                done_with_room = True
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go", direction)
        elif the_command == 'take':
            utils.take(player_inventory, room2_inventory, response)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room2_inventory, room2_locked,
                         response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room2_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room2_inventory)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "rat", rat_health, rat_alive,
                             response)
            rat_health = x
            if x <= 0:
                print("the rat is dead")
                rat_alive = False
        else:
            print("Command not implemented in ROOM 2,", the_command)
        x = utils.creature_action(rat_alive, player_inventory, rat_atk_org,
                                  "rat")
        if x:
            next_room = 666
            done_with_room = True
    # end of main while loop
    return next_room
Exemplo n.º 16
0
def run_room(player_inventory):
    global mimic_alive
    # Let the user know what the room looks like
    print(room9_description)

    # valid commands for this room
    commands = [
        "go", "take", "drop", "use", "examine", "status", "unlock", "attack"
    ]
    no_args = ["examine", "status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1
    mimic_health = 10
    mimic_atk = 5

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "west":
                next_room = 7
                done_with_room = True
            elif go_where == "east":
                next_room = 11
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room9_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room9_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room9_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room9_inventory, room9_locked,
                         response)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "mimic", mimic_health,
                             mimic_alive, response)
            mimic_health = x
            if x <= 0:
                print("the mimic is dead")
                mimic_alive = False
        else:
            print("The command:", the_command,
                  "has not been implemented in room 9")
        x = utils.creature_action(mimic_alive, player_inventory, mimic_atk,
                                  "mimic")
        if x:
            next_room = 666
            done_with_room = True
        if not mimic_alive:
            utils.health = utils.player_health["health"] + 2
            print(
                "the relaxed feeling o the library heals you 2 hp as you loosen up and your heart rate slows. \nThe smell of old books comforts you, it is friendly magic that's at work here"
            )
    return next_room
Exemplo n.º 17
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    if room_state['pitch_black'] == True:
        print(room4_dim_description)
    else:
        print(room4_lit_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        # now deal with the command
        if room_state['pitch_black'] == False:
            if the_command == 'go':
                go_where = response[1].lower()
                if go_where == 'south':
                    next_room = 3
                    done_with_room = True
                elif go_where == 'north':
                    next_room = 5
                    done_with_room = True
                else:
                    print('You cannot go:', go_where)
            elif the_command == 'take':
                response = utils.scrub_response(response)
                take_what = response[1]
                utils.take_item(player_inventory, r4_inventory, take_what)
            elif the_command == 'drop':
                drop_what = response[1]
                utils.drop_item(player_inventory, r4_inventory, drop_what)
            elif the_command == 'use':
                use_what = response[1]
                if use_what == 'torch':
                    if utils.has_a(player_inventory, 'torch') == True:
                        pitch_black = room_state['pitch_black']
                        if pitch_black:
                            room_state['pitch_black'] = False
                            print("The room is filled with bright light!")
                        else:
                            print("The room is already lit!")
                elif use_what == 'sword':
                    if utils.has_a(player_inventory, 'short sword'):
                        print(
                            "You put your short sword into the sheath and it fits perfectly. The chest next to it "
                            "opens and inside you can see a key.")
                        player_inventory['short sword'] = player_inventory[
                            'short sword'] - 1
                        r4_inventory['key'] = r4_inventory['key'] + 1
                    else:
                        print("You don't possess the correct item")
                else:
                    print("You need a torch to operate in this room")
            elif the_command == 'status':
                utils.player_status(player_inventory)
                utils.room_status(r4_inventory)
            elif the_command == 'examine':
                print(room4_lit_description)
            elif the_command == 'help':
                utils.player_help()
            else:
                print("The command:", the_command,
                      "has not been implemented in Room 4")
        else:
            if the_command == 'use':
                use_what = response[1]
                if use_what == 'torch':
                    if utils.has_a(player_inventory, 'torch') == True:
                        pitch_black = room_state['pitch_black']
                        if pitch_black:
                            room_state['pitch_black'] = False
                            print("The room is filled with bright light!")
                            player_inventory[
                                'torch'] = player_inventory['torch'] - 1
                            print(room4_lit_description)
                        else:
                            print("The room is already lit!")
                    else:
                        print("You need a torch to operate in this room")
                else:
                    print("You cannot use that")
            elif the_command == 'examine':
                print(room4_dim_description)
            elif the_command == 'status':
                utils.player_status(player_inventory)
            elif the_command == 'go':
                go_where = response[1].lower()
                if go_where == 'south':
                    next_room = 3
                    done_with_room = True
            elif the_command == 'help':
                utils.player_help()
            else:
                print("The command:", the_command,
                      "has not been implemented in Room 4")

    # END of WHILE LOOP
    return next_room
Exemplo n.º 18
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room6_description = '''
        . . .  6th room . . . 
        This room seems to have almost no purpose. Nothing but pictures hang on the wall. One of a mountain landscape with titled 'happy little accidents',
        one with a great battle scene between ancient men and a mammoth titled 'gory simplicity', and one of a wooden bowl of fruit titled 'pointless'.
        There is a door to the South, but it has no door knob, and no key hole. Just a thick layer of clay a soft stone cakes the front of the door.
        '''

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    print(room6_description)

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1
    door_writings = 0
    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0]

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'west':
                next_room = 2
                done_with_room = True
            if direction == 'south':
                is_locked = room_state['door_locked']
                if not is_locked:
                    next_room = 12
                    done_with_room = True
                else:
                    print("The door is locked.")
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room6_inventory, take_what)
        elif the_command == 'use':
            use_what = response[1]
            if use_what == 'pick axe':
                if room6_inventory['pick axe'] == 0:
                    print(
                        "You hack away the loose rock and clay to reveal a small bit of writing. It says: Answer this riddle correctly, and you may pass "
                        "through this door. (clears throat), thirty white horses on a red hill. First they champ, then they stamp, and then they "
                        "stand still. What is it?")
                    correct = False
                    while correct == False:
                        response = input("What is the answer?:")
                        if response != 'teeth':
                            print("Incorrect! Try Again!")
                        elif response == 'teeth':
                            print("Correct!")
                            door_locked = room_state["door_locked"]
                            correct = True
                            if door_locked:
                                room_state["door_locked"] = False
                                print("The door to the SOUTH is unlocked!")
                            else:
                                print("The door was already unlocked!")

        elif the_command == 'status':
            utils.room_status(room6_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room6_inventory, drop_what)
        elif the_command == 'drink':
            potion = response[1]
            if potion == 'healing potion':
                if player_inventory['healing potion'] == 1:
                    print(
                        "You drink a healing potion. You gain 20 hit points.")
                    player_inventory[
                        'health'] = player_inventory['health'] + 20
                    print("Your health is now:", player_inventory['health'])
            elif potion == 'minor healing potion':
                if player_inventory['minor healing potion']:
                    print(
                        "You drink the minor healing potion. You gain 10 hit points."
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] + 10
                    print("Your health is now:", player_inventory['health'])
            else:
                print("You do not have a healing potion Donny.")
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'door':
                print(
                    "You notice some small cave paintings depicting the hunting of some kind of large animal."
                )
                door_writings = door_writings + 1
            if examine_what == 'gory simplicity':
                if door_writings == 1:
                    print(
                        "You notice the painting hides a secret alcove. Within the alcove lies a pick axe"
                    )
            if examine_what == 'happy little accidents':
                print(
                    "The painting is quite striking, and it seems to made by a strange man named Bob Ross."
                )
            if examine_what == 'pointless':
                print("It looks just like the title says it does: pointless.")
            if examine_what == 'map':
                utils.map(player_inventory)

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 19
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room8_description = '''
        . . .  8th room ... 
        You are standing in a hallway. There is a door to the EAST and a locked door to the WEST. 
        '''

    if room8_inventory['elven greatsword'] > 0:
        room8_description = room8_description + " There is an elven greatsword hanging on the wall."
    if room8_inventory['book'] > 0:
        room8_description = room8_description + " There is a book on a desk."
    print(room8_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'west':
                is_locked = room_state['door_locked']
                if not is_locked:
                    next_room = 10
                    done_with_room = True
                else:
                    print("The door is locked.")
            if direction == 'east':
                next_room = 9
                done_with_room = True
            if direction == 'south':
                next_room = 5
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room8_inventory, take_what)
        elif the_command == 'status':
            utils.room_status(room8_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room8_inventory, drop_what)
        elif the_command == 'use':
            use_what = response[1]
            if use_what == 'gold key':
                if 'gold key' not in player_inventory.keys():
                    print("You don't have a gold key!")
                else:
                    door_locked = room_state["door_locked"]
                    if door_locked:
                        room_state["door_locked"] = False
                        print("The door to the WEST is unlocked!")
                    else:
                        print("The door was already unlocked!")
        elif the_command == 'drink':
            potion = response[1]
            if potion == 'healing potion':
                if player_inventory['healing potion'] == 1:
                    print(
                        "You drink a healing potion. You gain 20 hit points.")
                    player_inventory[
                        'health'] = player_inventory['health'] + 20
                    print("Your health is now:", player_inventory['health'])
            elif potion == 'minor healing potion':
                if player_inventory['minor healing potion']:
                    print(
                        "You drink the minor healing potion. You gain 10 hit points."
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] + 10
                    print("Your health is now:", player_inventory['health'])
            else:
                print("You do not have a healing potion Donny.")
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'book':
                print("The book has no writing in it.")
            if examine_what == 'map':
                utils.map(player_inventory)

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 20
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room13_description)
    global lizard_man_alive

    # valid commands for this room
    commands = ["go", "take", "drop", "examine", "status", "unlock", "attack"]
    no_args = [
        "examine",
        "status",
    ]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1
    kobold_king_atk = 7
    kobold_king_health = 20

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "north":
                is_locked = room13_locked["north"]
                if not is_locked:
                    next_room = 547
                    done_with_room = True
                if is_locked:
                    print("door is sealed with special glowing symbols")
            elif go_where == "south":
                next_room = 11
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room13_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room13_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room13_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room13_inventory, room13_locked,
                         response)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "lizard man",
                             kobold_king_health, lizard_man_alive, response)
            kobold_king_health = x + 1.5
            if x <= 0:
                lizard_man_alive = False
                print(
                    '''The lizard man falls to the ground with a satisfying thud. His face is locked in a final expression of
                pain and rage before going limp. Victory is yours. The door at the end of the hall's sealing runes fade away.
                ''')
                room13_locked["north"] = False
        else:
            print("The command:", the_command,
                  "has not been implemented in room 13")
        x = utils.creature_action(lizard_man_alive, player_inventory,
                                  kobold_king_atk, "lizard man")
        if x:
            next_room = 666
            done_with_room = True
    return next_room
Exemplo n.º 21
0
def run_room(player_inventory):
    room11_description = '''
    . . . 11th Room ...
    There it is! The ELEVATOR!!! However it is blocked by fire.
    You must use something to 
    '''

    print(room11_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        if the_command == 'go':
            direction = response[1]
            # Use your hand drawn map to help you think about what is valid
            if direction == 'north':
                next_room = 10
                done_with_room = True
            if direction == 'east':
                if room11_interacts['fire']:
                    print("You can't walk through fire.")
                else:
                    next_room = 12
                    done_with_room = True
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go,", direction)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, room11_inventory, take_what)
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(room11_inventory, room11_interacts)
        elif the_command == 'drop':
            response = utils.scrub_response(response)
            drop_what = response[1]
            utils.drop_item(player_inventory, room11_inventory, drop_what)
        elif the_command == 'help':
            print(
                "The valid commands are",
                commands,
                no_args,
            )
        elif the_command == 'use':
            response = utils.scrub_response(response)
            use_what = response[1]
            if utils.has_a(player_inventory, use_what):
                if use_what == 'filled mug':
                    room11_interacts['fire'] = False
                    print(
                        "You throw the water and extinguish the flame. Now you can leave through the elevator."
                    )
                else:
                    print("You can't use that here.")
            else:
                print("You can't use that here.")
        else:
            print("Command not implemented in ROOM 2,", the_command)

    # end of main while loop
    return next_room
Exemplo n.º 22
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    if room_state['pitch_black']:
        print(room12_dim_description)
    else:
        print(room12_lit_description)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help"]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        # now deal with the command
        if room_state['pitch_black'] == False:
            if the_command == 'go':
                go_where = response[1].lower()
                if go_where == 'south':
                    next_room = 11
                    done_with_room = True
                elif go_where == 'east':
                    is_locked = room_state['door_locked']
                    if not is_locked:
                        next_room = 13
                        done_with_room = True
                    else:
                        print("Key required to open locked door.")
                else:
                    print('You cannot go:', go_where)
            elif the_command == 'take':
                response = utils.scrub_response(response)
                take_what = response[1]
                utils.take_item(player_inventory, r12_inventory, take_what)
            elif the_command == 'drop':
                drop_what = response[1]
                utils.drop_item(player_inventory, r12_inventory, drop_what)
            elif the_command == 'use':
                use_what = response[1]
                if use_what == 'torch':
                    if utils.has_a(player_inventory, 'torch') == True:
                        pitch_black = room_state['pitch_black']
                        if pitch_black:
                            room_state['pitch_black'] = False
                            print("The room is filled with bright light!")
                        else:
                            print("The room is already lit!")
                elif use_what == 'key':
                    if utils.has_a(player_inventory, 'key') == True:
                        door_locked = room_state['door_locked']
                        if door_locked:
                            room_state['door_locked'] = False
                            print("The door to the EAST is unlocked!")
                            player_inventory[
                                'key'] = player_inventory['key'] - 1
                        else:
                            print("The door was already unlocked!")
                    else:
                        print("You need a key to open this door")
                else:
                    print("You need a torch to operate in this room")
            elif the_command == 'status':
                utils.player_status(player_inventory)
                utils.room_status(r12_inventory)
            elif the_command == 'examine':
                print(room12_lit_description)
            elif the_command == 'help':
                utils.player_help()
            else:
                print("The command:", the_command,
                      "has not been implemented in Room 4")
        else:
            if the_command == 'use':
                use_what = response[1]
                if use_what == 'torch':
                    if utils.has_a(player_inventory, 'torch') == True:
                        pitch_black = room_state['pitch_black']
                        if pitch_black:
                            room_state['pitch_black'] = False
                            print("The room is filled with bright light!")
                            player_inventory[
                                'torch'] = player_inventory['torch'] - 1
                            print(room12_lit_description)
                        else:
                            print("The room is already lit!")
                    else:
                        print("You need a torch to operate in this room")
                else:
                    print("You cannot use that")
            elif the_command == 'examine':
                print(room12_dim_description)
            elif the_command == 'status':
                utils.player_status(player_inventory)
            elif the_command == 'go':
                go_where = response[1].lower()
                if go_where == 'south':
                    next_room = 11
                    done_with_room = True
            elif the_command == 'help':
                utils.player_help()
            else:
                print("The command:", the_command,
                      "has not been implemented in Room 12")

    # END of WHILE LOOP
    return next_room
Exemplo n.º 23
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    if room_state['door_blocked']:
        print(room7_description)
    else:
        print(room7_no_copier)

    # valid commands for this room
    commands = ["go", "take", "drop", "use", "examine", "status", "help", "move"]
    no_args = [ "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands, no_args)
        the_command = response[0]

        # now deal with the command
        if room_state['door_blocked']:
            if the_command == 'go':
                go_where = response[1].lower()
                if go_where == 'south':
                    print("The door is blocked by a copier.")
                elif go_where == 'east':
                    next_room = 6
                    done_with_room = True
                else:
                    print("Can't go", go_where)
            elif the_command == 'take':
                response = utils.scrub_response(response)
                take_what = response[1]
                utils.take_item(player_inventory, room7_inventory, take_what)
            elif the_command == 'status':
                utils.player_status(player_inventory)
                utils.room_status(room7_inventory, room7_interacts)
            elif the_command == 'drop':
                response = utils.scrub_response(response)
                drop_what = response[1]
                utils.drop_item(player_inventory, room7_inventory, drop_what)
            elif the_command == 'examine':
                response = utils.scrub_response(response)
                exam_what = response[1].title()
                if exam_what.title() in exam_objs:
                    if room_state['flashlight']:
                        if exam_what == 'Painting':
                            print(painting_description)
                            utils.add_item_to_inventory('flashlight', player_inventory)
                    else:
                        print("You already took the flashlight")
                else:
                    print("You can only examine", exam_objs, "in this room")
            elif the_command == 'move':
                response = utils.scrub_response(response)
                move_what = response[1]
                if move_what.lower() == 'copier':
                    room_state['door_blocked'] = False
                    print("You move the copier out of the way of the door")
                else:
                    print("You can't move", move_what)
            elif the_command == 'help':
                print("The valid commands are", commands, no_args, )
            else:
                print("that command is not supported in this room")
        else:
            if the_command == 'go':
                go_where = response[1].lower()
                if go_where == 'south':
                    next_room = 8
                    done_with_room = True
                elif go_where == 'east':
                    next_room = 6
                    done_with_room = True
                else:
                    print("Can't go", go_where)
            elif the_command == 'take':
                response = utils.scrub_response(response)
                take_what = response[1]
                utils.take_item(player_inventory, room7_inventory, take_what)
            elif the_command == 'status':
                utils.player_status(player_inventory)
                utils.room_status(room7_inventory, room7_interacts)
            elif the_command == 'drop':
                response = utils.scrub_response(response)
                drop_what = response[1]
                utils.drop_item(player_inventory, room7_inventory, drop_what)
            elif the_command == 'examine':
                response = utils.scrub_response(response)
                exam_what = response[1].title()
                if exam_what.title() in exam_objs:
                    if room_state['flashlight']:
                        if exam_what == 'Painting':
                            print(painting_description)
                            utils.add_item_to_inventory('flashlight', player_inventory)
                    else:
                        print("You already took the flashlight")
                else:
                    print("You can only examine", exam_objs, "in this room")
            elif the_command == 'move':
                print("You already moved the copier. There is nothing else to move.")
            elif the_command == 'help':
                print("The valid commands are", commands, no_args, )
            else:
                print("that command is not supported in this room")
    # END of WHILE LOOP
    return next_room
Exemplo n.º 24
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room12_description = '''
        . . .  12rd room ... 
        You find yourself in a sort of corridor. There are doors to the EAST and WEST.
        '''

    if room_state['door_locked'] == True:
        room12_description = room12_description + " The door to the WEST is locked. It seems like you need a special gem to unlock it."
    if room12_inventory['map'] == 1:
        room12_description = room12_description + " There is a map hanging on the wall."
    if room12_inventory['healing potion'] == 1:
        room12_description = room12_description + " A healing potion sits on the desk."
    print(room12_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'east':
                next_room = 13
                done_with_room = True
            elif direction == 'west':
                is_locked = room_state['door_locked']
                if not is_locked:
                    next_room = 14
                    done_with_room = True
                elif 'sapphire' in player_inventory.keys():
                    print("You should use the sapphire")
                else:
                    print("You do not have a gem.")
            elif direction == 'north':
                next_room = 6
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room12_inventory, take_what)
        elif the_command == 'use':
            if response[1] == 'sapphire':
                if 'sapphire' not in player_inventory.keys():
                    print("You do not have a gem.")
                else:
                    door_locked = room_state["door_locked"]
                    if door_locked:
                        room_state["door_locked"] = False
                        print(
                            "You place the sapphire in the center of the door. It glows for a moment,"
                            " and then winks out. You hear some clicking, and now the door to the WEST is unlocked!"
                        )
                        del player_inventory['sapphire']
                    else:
                        print("The door was already unlocked!")
        elif the_command == 'status':
            utils.room_status(room12_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drink':
            potion = response[1]
            if potion == 'healing potion':
                if player_inventory['healing potion'] == 1:
                    print(
                        "You drink a healing potion. You gain 20 hit points.")
                    player_inventory[
                        'health'] = player_inventory['health'] + 20
                    print("Your health is now:", player_inventory['health'])
            elif potion == 'minor healing potion':
                if player_inventory['minor healing potion']:
                    print(
                        "You drink the minor healing potion. You gain 10 hit points."
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] + 10
                    print("Your health is now:", player_inventory['health'])
            else:
                print("You do not have a healing potion Donny.")
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room12_inventory, drop_what)
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'healing potion':
                print(
                    "Nothing special about it, it's just a healing potion Donny."
                )
            if examine_what == 'map':
                print(
                    "It is a map of the dungeon. You are in room 12, and the map looks like this: "
                )
                map = '''    
                      10---8---9   4---7 
                           |       |   | 
                           5---1---3   11
                               |         
                               2---6     
                                   |     
                             14---12---13
                              |          
                             15     
                                  
                        I'm the map!
                            '''
                print(map)

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 25
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room12_description)
    global tree_container

    # valid commands for this room
    commands = [
        "go", "take", "drop", "use", "examine", "status", "unlock", "attack"
    ]
    no_args = ["examine", "status"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "east":
                next_room = 10
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room12_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room12_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room12_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room12_inventory, room12_locked,
                         response)
        elif the_command == "attack":
            if tree_container:
                if response[1] == "tree" or "roots":
                    if utils.has_a(player_inventory, "axe"):
                        print(
                            "you chop away the roots revealing the key and helm"
                        )
                        room12_inventory["helm"] = 1
                        room12_inventory["key"] = 1
                        tree_container = False
                    else:
                        print("this action requires an axe")
                else:
                    print("your option for attacking is roots")
            else:
                print("you alredy chopped away the roots")
        else:
            print("The command:", the_command,
                  "has not been implemented in room 12")

    return next_room
Exemplo n.º 26
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room3_description = '''
        . . .  3rd room ... 
        You are in a room that feels very familiar. There is a door to the north.
        '''

    if room3_inventory['sword'] > 0:
        room3_description = room3_description + " There is a sword hanging on the wall."
    if room3_inventory['clue'] > 0:
        room3_description = room3_description + " There is a clue on the desk."
    print(room3_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'west':
                next_room = 1
                done_with_room = True
            if direction == 'north':
                next_room = 4
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room3_inventory, take_what)
        elif the_command == 'status':
            utils.room_status(room3_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room3_inventory, drop_what)
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'clue':
                print(
                    "The clue reads: WITHIN THIS DUNGEON LIES A GREAT TREASURE. SEEK IT AT YOUR OWN RISK!!!"
                )
            if examine_what == 'sword':
                print("The sword is made of polished steel.")
            if examine_what == 'map':
                utils.map(player_inventory)
        else:
            print("Bleh")

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 27
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room13_description = '''
        . . .  13th room ... 
        This room smells a lot like someone had a piss in it. A large shelf stands in the corner.
        '''

    if room13_inventory['bowling ball'] > 0:
        room13_description = room13_description + " A huge bowling ball sits on the table. On the front there is a name: Jeff Lebowski."
    if room13_inventory['sapphire'] > 0:
        room13_description = room13_description + " A sapphire the size of 2/17 of a mini-fridge sits on a pillow in the center of the room."
    if room13_inventory['rug'] > 0:
        room13_description = room13_description + " A rug that really ties the room together sits on the floor. There is a pee stain on it."
    print(room13_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'west':
                next_room = 12
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room13_inventory, take_what)
        elif the_command == 'status':
            utils.room_status(room13_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room13_inventory, drop_what)
        elif the_command == 'drink':
            potion = response[1]
            if potion == 'healing potion':
                if player_inventory['healing potion'] == 1:
                    print(
                        "You drink a healing potion. You gain 20 hit points.")
                    player_inventory[
                        'health'] = player_inventory['health'] + 20
                    print("Your health is now:", player_inventory['health'])
            elif potion == 'minor healing potion':
                if player_inventory['minor healing potion']:
                    print(
                        "You drink the minor healing potion. You gain 10 hit points."
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] + 10
                    print("Your health is now:", player_inventory['health'])
            else:
                print("You do not have a healing potion Donny.")
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'map':
                utils.map(player_inventory)

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 28
0
def run_room(player_inventory):

    room2_description = '''
    . . . 
    You are in a brightly lit room. The room appears to be an office. 
    There is a key, pen and coffee mug on the corner of a desk.
    '''

    print(room2_description)

    # valid commands for this room
    commands = [
        "go", "take", "drop", "use", "examine", "status", "help", "open"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0]

        if the_command == 'go':
            direction = response[1].lower()
            # Use your hand drawn map to help you think about what is valid
            if direction == 'north':
                next_room = 1
                done_with_room = True
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go,", direction)
        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, room2_inventory, take_what)
        elif the_command == 'open':
            response = utils.scrub_response(response)
            if response[1] in room2_interacts:
                print("You opened", response[1])
            else:
                print("There is no", response[1], "to open")
        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(room2_inventory, room2_interacts)
        elif the_command == 'drop':
            response = utils.scrub_response(response)
            drop_what = response[1]
            utils.drop_item(player_inventory, room2_inventory, drop_what)
        elif the_command == 'help':
            print(
                "The valid commands are",
                commands,
                no_args,
            )
        else:
            print("Command not implemented in ROOM 2,", the_command)

    # end of main while loop
    return next_room
Exemplo n.º 29
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room10_description = '''
        . . .  10th room ... 
        You find yourself in a darkly lit small room.
        '''

    if room10_inventory['rabbit'] > 0:
        room10_description = room10_description + "  A small rabbit sits on top of a large treasure chest."
    print(room10_description)

    commands = [
        "go", "take", "drop", "use", "drink", "examine", "status", "help"
    ]
    no_args = ["examine", "status", "help"]

    # nonsense room number,
    # In the loop below the user should eventually ask to "go" somewhere.
    # If they give you a valid direction then set next_room to that value
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()

        # now deal with the command
        if the_command == 'go':
            direction = response[1].lower()
            if direction == 'east':
                next_room = 8
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            if take_what != 'rabbit':
                if take_what == 'treasure':
                    if room10_inventory['rabbit'] == 0:
                        utils.take_item(player_inventory, room10_inventory,
                                        take_what)
                        print(
                            "You find a tortoise named Maynard, and you get to keep him forever! THE END"
                        )
                        break
                    else:
                        print("The bunny still guards the treasure!")
                else:
                    utils.take_item(player_inventory, room10_inventory,
                                    take_what)
            else:
                print("You cannot take the rabbit.")
        elif the_command == 'status':
            utils.room_status(room10_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drink':
            potion = response[1]
            if potion == 'healing potion':
                if player_inventory['healing potion'] == 1:
                    print(
                        "You drink a healing potion. You gain 20 hit points.")
                    player_inventory[
                        'health'] = player_inventory['health'] + 20
                    print("Your health is now:", player_inventory['health'])
            elif potion == 'minor healing potion':
                if player_inventory['minor healing potion']:
                    print(
                        "You drink the minor healing potion. You gain 10 hit points."
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] + 10
                    print("Your health is now:", player_inventory['health'])
            else:
                print("You do not have a healing potion Donny.")
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room10_inventory, drop_what)
        elif the_command == 'use':
            use_what = response[1]
            if use_what != 'holy hand grenade':
                if room10_inventory['rabbit'] > 0:
                    print("The rabbit seems to be immune to such attacks!")
                    print(
                        "The rabbit lunges and bites you for 10 points of damage!"
                    )
                    player_inventory[
                        'health'] = player_inventory['health'] - 10
                    print("Your health is now: ", player_inventory['health'])
                    if player_inventory['health'] <= 0:
                        print("You died! GAME OVER")
                        break
                else:
                    print("It does nothing.")
            if use_what == 'holy hand grenade':
                if room10_inventory['rabbit'] > 0:
                    blah = '''
                        After thoroughly reading the instructions, you count 'one......two.......five!, shit, three!!!"
                        the holy hand grenade sails through the air......... and hits the bunny on the head, killing him instantly. The holy hand grenade rolls
                        away and does nothing.
                        '''
                    print(blah)
                    room10_inventory['rabbit'] = 0
                else:
                    print("It does nothing.")
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'map':
                utils.map(player_inventory)

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
Exemplo n.º 30
0
def run_room(player_inventory):
    utils.print_description(description)
    # valid commands for this room
    commands = ["go", "take", "drop", "use", 'status']
    no_args = ["status"]

    # nonsense room number, we need to figure out which room they want in the loop
    next_room = -1

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        response = utils.scrub_response(response)
        the_command = response[0]

        if the_command == 'go':
            direction = response[1]
            # Use your hand drawn map to help you think about what is valid
            if direction == 'north':
                next_room = 1
                done_with_room = True
            elif direction == 'south':
                is_locked = room4_state['door locked']
                if not is_locked:
                    next_room = 4
                    done_with_room = True
                elif is_locked:
                    print("The door to room 4 is locked.")
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go", direction)

        elif the_command == 'take':
            response = utils.scrub_response(response)
            take_what = response[1]
            utils.take_item(player_inventory, room2_inventory, take_what)

        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room2_inventory, drop_what)

        elif the_command == 'status':
            utils.player_status(player_inventory)
            utils.room_status(room2_inventory)

        elif the_command == 'use':
            use_what = response[1]
            if use_what in player_inventory:
                object = use_what.split()
                if object[1] == 'key':
                    direction = utils.prompt_question(
                        'Which door would you like to use the key on?',
                        ['north', 'south'])
                    if direction.lower() == 'north':
                        print('The door was already unlocked')
                    elif direction.lower() == 'south':
                        door_locked = room4_state['door locked']
                        if door_locked:
                            if object[0] == 'brass':
                                room4_state['door locked'] = False
                                current_count = player_inventory['brass key']
                                player_inventory[
                                    'brass key'] = current_count - 1
                                print('The door to the SOUTH is now unlocked.')
                            else:
                                print('A', use_what, 'is unable to unlock the',
                                      direction, 'door.')
                        else:
                            print('The door was already unlocked.')
                else:
                    print('You have no way to use:', use_what)
            else:
                print("You don't have:", use_what)
        elif the_command == 'examine':
            examine_what = response[1]

        else:
            print("Command not implemented in ROOM 2,", the_command)

    # end of main while loop
    return next_room