예제 #1
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
예제 #2
0
def run_room(player_inventory):
    print(room13_description)

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

    next_room = -1

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

        if the_command == "go":
            go_where = response[1]
            if go_where == "west":
                next_room = 10
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "take":
            take_what = response[1]
            utils.take_item(player_inventory, room13_inventory, take_what)
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room13_inventory, drop_what)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room13_inventory)
        elif the_command == "examine":
            print(room13_description)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "ruby":
                utils.use_gem("ruby", player_inventory, room13_status)
                if room13_status["ruby"] == 1 and room13_status["sapphire"] == 1 and room13_status["emerald"] == 1:
                    print(end_game)
                    next_room = 42
                    done_with_room = True
            elif use_what == "sapphire":
                utils.use_gem("sapphire", player_inventory, room13_status)
                if room13_status["ruby"] == 1 and room13_status["sapphire"] == 1 and room13_status["emerald"] == 1:
                    print(end_game)
                    next_room = 42
                    done_with_room = True
            elif use_what == "emerald":
                utils.use_gem("emerald", player_inventory, room13_status)
                if room13_status["ruby"] == 1 and room13_status["sapphire"] == 1 and room13_status["emerald"] == 1:
                    print(end_game)
                    next_room = 42
                    done_with_room = True
            elif use_what == "torch":
                utils.use_torch1(use_what, player_inventory)
            else:
                print("There is no reason to use,", use_what, "here")

        else:
            print("I do not understand:", the_command)

    return next_room
예제 #3
0
def run_room(player_inventory):

    if room5_status["east_locked"] == 1:
        print(room5_description)
    else:
        print(room5_description_no_vines)

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

    next_room = -1

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

        if the_command == "go":
            go_where = response[1]
            if go_where == "south":
                next_room = 6
                done_with_room = True
            elif go_where == "north":
                next_room = 4
                done_with_room = True
            elif go_where == "east":
                if room5_status["east_locked"] == 1:
                    print("Vines block your path, try burning them down")
                else:
                    next_room = 8
                    done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room5_inventory)
        elif the_command == "examine":
            if room5_status["east_locked"] == 1:
                print(room5_description)
            else:
                print(room5_description_no_vines)
        elif the_command == "take":
            take_what = response[1]
            utils.take_item(player_inventory, room5_inventory, take_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "torch":
                utils.use_torch(use_what, player_inventory, room5_status,
                                "east_locked")
            else:
                print("There is no reason to use,", use_what, "here")
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room5_inventory, drop_what)
        else:
            print("I do not understand", the_command)

    return next_room
예제 #4
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
예제 #5
0
def run_room(player_inventory):
    coin_count = room8_inventory["coin"]
    if coin_count < 1:
        print(room8_description_no_coin)
    else:
        print(room8_description)

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

    next_room = -1

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

        if the_command == "go":
            go_where = response[1]
            if go_where == "south":
                next_room = 7
                done_with_room = True
            elif go_where == "west":
                next_room = 5
                done_with_room = True
            elif go_where == "east":
                next_room = 9
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room8_inventory)
        elif the_command == "examine":
            coin_count = room8_inventory["coin"]
            if coin_count < 1:
                print(room8_description_no_coin)
            else:
                print(room8_description)
        elif the_command == "take":
            take_what = response[1]
            utils.take_item(player_inventory, room8_inventory, take_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "torch":
                utils.use_torch1(use_what, player_inventory)
            else:
                print("There is no reason to use,", use_what, "here")
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room8_inventory, drop_what)
        else:
            print("I do not understand", the_command)

    return next_room
예제 #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", "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
예제 #7
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
예제 #8
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
예제 #9
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room3_description)

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

    # 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]
            if go_where == "west":
                next_room = 1
                done_with_room = True
            elif go_where == "east":
                next_room = 4
                done_with_room = True
            else:
                print("You cannot go,", go_where)
        elif the_command == 'take':
            take_what = response[1]
            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 == "examine":
            print(room3_description)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "torch":
                utils.use_torch1(use_what, player_inventory)
            else:
                print("There is no reason to use,", use_what, "here")
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room3_inventory, drop_what)
        else:
            print("I do not understand", the_command)

            # END of WHILE LOOP
    return next_room
예제 #10
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
예제 #11
0
def run_room(player_inventory, player_equipped, combat_off_inventory,
             combat_spell_inventory, mobs, player_health):
    description = '''
    In the middle of the room is a fountain of blood. The fountain is elegantly designed with etchings of ancient battles
    between man and wolf.  The dark red light of the room fades into a ruby shade towards the middle of the room. There are
    passages going north and west.
    '''
    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 = 4

    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]
            if direction == 'north':
                next_room = 7
                done_with_room = True
            elif direction == 'west':
                next_room = 2
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room4_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room4_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(room4_inventory, room4_map,
                                  room4_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':
            print("There is nothing to loot in this room.")
        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("\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("********************************************************\n")
    # end of main while loop
    return next_room
예제 #12
0
def run_room(player_inventory):
    description = '''
    . . .Room 2. . . 
    You carefully walk down the stairs and descend into a cramped room with barrels stacked to 
    the ceiling. Whatever was inside them became rotten years ago and they expel a nearly 
    unbearable odor. Atop a barrel you see a *coin* glistening in the torchlight. You
    see stairs leading up to the north and stairs leading further down to the west.
    '''
    no_coin_description = '''
    . . .Room 2. . . 
    You carefully walk down the stairs and descend into a cramped room with barrels stacked to 
    the ceiling. Whatever was inside them became rotten years ago and they expel a nearly 
    unbearable odor. 
    You see stairs leading up to the north and stairs leading further down to the 
    west.
    '''

    coin_count = room2_inventory["coin"]
    if coin_count < 1:
        print(no_coin_description)
    else:
        print(description)

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

    # 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 = 1
                done_with_room = True
            elif direction == "west":
                next_room = 14
                done_with_room = True
            else:
                print("There is no way to go,", direction)
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room2_inventory, take_what)
        elif the_command == "status":
            utils.room_status(room2_inventory)
            utils.player_status(player_inventory)
        elif the_command == "examine":
            coin_count = room2_inventory["coin"]
            if coin_count < 1:
                print(no_coin_description)
            else:
                print(description)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "torch":
                utils.use_torch1(use_what, player_inventory)
            else:
                print("There is no reason to use,", use_what, "here")
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room2_inventory, drop_what)
        else:
            print("I do not understand", the_command)

    # end of main while loop
    return next_room
예제 #13
0
파일: room9.py 프로젝트: ReidLuhn/maze_game
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
예제 #14
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
예제 #15
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
예제 #16
0
def run_room(player_inventory, player_equipped, combat_off_inventory,
             combat_spell_inventory, mobs, player_health):
    description = '''
    A glowing aura of blinding light floats in the center of the room. The aura hums and swirls, cascading light throughout
    the seemingly infinite room.
    '''
    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 = 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]
        if the_command == 'go':
            direction = response[1]
            if direction == 'south':
                next_room = 9
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room12_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room12_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(room12_inventory, room12_map,
                                  room12_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 room12_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 room12_loot_sources:
                    utils.loot(chosen, room12_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':
                print(
                    "A strange wind blows through the room and snuffs out the magic you are trying to use."
                )
        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 close you eyes and the light fades.\n\t")
        print("The torch you had placed has been burned up.")
    # end of main while loop
    return next_room
예제 #17
0
def run_room(player_inventory, player_equipped, combat_off_inventory,
             combat_spell_inventory, mobs, player_health):
    description = '''
    The room seems to look like an abandoned living space. There is an empty table in the center and a dusty study on the
    southern wall. There is a door to the north and a passage to the east.
    '''

    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 = 8

    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]
            if direction == 'north':
                if room_state['is_locked']:
                    print('''
            You suddenly hear a faint voice whisper, 'You may not go further into my residence if you do not
            identify my being. I have no legs, yet I can dance. I have no lungs, yet I breathe. I have no life to lose,
            yet I am capable of dying.'
                        ''')
                    while True:
                        print("Type 'Q' if you wish to stop guessing.")
                        answer = input("What am I?\n")
                        answer = answer.title()
                        if answer == 'Q':
                            print("You are done guessing.\n")
                            break
                        elif answer == 'Fire':
                            print(
                                "The voice catches your ear, saying 'You may enter'."
                            )
                            next_room = 10
                            room_state["is_locked"] = False
                            done_with_room = True
                            break
                        else:
                            print("The door does not move.\n")
                else:
                    print("The voice says, 'You may enter.'")
            elif direction == 'east':
                next_room = 5
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room8_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room8_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(room8_inventory, room8_map,
                                  room8_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':
            print("There is nothing to loot in this room.")
        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("\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("********************************************************\n")
    # end of main while loop
    return next_room
예제 #18
0
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health):
    description = '''
           A puddle of blood covers the dungeon floor, coming from a body the wolf was feasting on. The body was the commanding
           officer who had given you a walk through the prison. There are passages going north, east, south, and west.
           '''
    next_room = 6
    done_with_room = False

    if room_state['encounter']:
        print("Before you are able to get a good look around, a wolf pounces at you!")
        utils.combat(player_equipped, player_inventory, combat_off_inventory, combat_spell_inventory, mobs, mob,
                     player_health, wolf_attack)
        room_state['encounter'] = False
        if player_health['pl_hp'] <= 0:
            next_room = 15
            done_with_room = True

    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

    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]
            if direction == 'north':
                next_room = 11
                done_with_room = True
            elif direction == 'east':
                next_room = 7
                done_with_room = True
            elif direction == 'south':
                next_room = 2
                done_with_room = True
            elif direction == 'west':
                next_room = 5
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room6_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room6_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(room6_inventory, room6_map, room6_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 room6_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 room6_loot_sources:
                    utils.loot(chosen, room6_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("\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("********************************************************\n")
    # end of main while loop
    return next_room
예제 #19
0
def run_room(player_inventory, player_equipped, combat_off_inventory, combat_spell_inventory, mobs, player_health):
    description = '''
    The northern wall has a bookcase covering it. The bookcase is filled with cobwebs and only contains one book.
    There are passages going east, south, and west. 
    '''

    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 = 7

    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]
            if direction == 'east':
                next_room = 9
                done_with_room = True
            elif direction == 'south':
                next_room = 4
                done_with_room = True
            elif direction == 'west':
                next_room = 6
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room7_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room7_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(room7_inventory, room7_map, room7_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 room7_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 room7_loot_sources:
                    utils.loot(chosen, room7_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("\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("********************************************************\n")
    # end of main while loop
    return next_room
예제 #20
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
예제 #21
0
def run_room(inventory):

    if room1_status["cobwebs_up"] == 1:
        print(description)
    else:
        print(description_no_web)

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

    # 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 == 'south':
                next_room = 2
                done_with_room = True
            elif direction == 'east':
                if room1_status["cobwebs_up"] == 1:
                    print(
                        "you will have to chop down the cobwebs in order to proceed"
                    )
                else:
                    next_room = 3
                    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':
            take_what = response[1]
            utils.take_item(inventory, room1_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(inventory, room1_inventory, drop_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "torch":
                utils.use_torch1(use_what, inventory)
            elif use_what == "sword":
                utils.use_sword(use_what, inventory, room1_status)
            else:
                print("There is no reason to use,", use_what, "here")
        elif the_command == "status":
            utils.room_status(room1_inventory)
            utils.player_status(inventory)
        elif the_command == "examine":
            if room1_status["cobwebs_up"] == 1:
                print(description)
            else:
                print(description_no_web)

    # end of while loop
    return next_room
예제 #22
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
예제 #23
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
예제 #24
0
파일: room8.py 프로젝트: ReidLuhn/maze_game
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
예제 #25
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
예제 #26
0
def run_room(player_inventory):

    room6_description = ''' 
    . . .Room 6. . .
    You enter a room filled with wooden crates stacked three high, 
    they all have some odd characters inscribed on their sides that you 
    are unable to read. There are empty flasks, small empty bags with the 
    names of herbs written on them, and in the corner of the room you see
    one, lone, shimmering, *coin*.
    You see a passage to the north, and east'''

    room6_descripton_no_coin =  ''' 
    . . .Room 6. . .
    You enter a room filled with wooden crates stacked three high, 
    they all have some odd characters inscribed on their sides that you 
    are unable to read. There are empty flasks and small empty bags with the 
     names of herbs written on them.
     You see a passage to the north, and east'''
    coin_count = room6_inventory["coin"]
    if coin_count < 1:
        print(room6_descripton_no_coin)
    else:
        print(room6_description)

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

    next_room = -1

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

        if the_command == "go":
            go_where = response[1]
            if go_where == "north":
                next_room = 5
                done_with_room = True
            elif go_where == "east":
                next_room = 7
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room6_inventory)
        elif the_command == "examine":
            coin_count = room6_inventory["coin"]
            if coin_count < 1:
                print(room6_descripton_no_coin)
            else:
                print(room6_description)
        elif the_command == "take":
            take_what = response[1]
            utils.take_item(player_inventory, room6_inventory, take_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "torch":
                utils.use_torch1(use_what, player_inventory)
            else:
                print("There is no reason to use,", use_what, "here")
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room6_inventory, drop_what)
        else:
            print("I do not understand", the_command)

    return next_room
예제 #27
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
예제 #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
예제 #29
0
def run_room(player_inventory, player_equipped, combat_off_inventory,
             combat_spell_inventory, mobs, player_health):
    description = '''
    In the middle of the room is a giant hearth. Next to the hearth is an empty set of armor holding a sword in the fire,
    as if it were poking the flames. The sword shines bright red and is on fire, yet not bent or melting in the slightest.
    There is a passage to the south.
    '''

    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 = 10

    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]
            if direction == 'south':
                next_room = 8
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room10_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room10_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(room10_inventory, room10_map,
                                  room10_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 room10_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 room10_loot_sources:
                    utils.loot(chosen, room10_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("\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("********************************************************\n")
    # end of main while loop
    return next_room
예제 #30
0
def run_room(player_inventory, player_equipped, player_health,
             combat_spell_inventory):

    description = '''
    A red light persists throughout the room and shines down on an blood trail going north. There is a faint drip of water 
    coming from the ceiling. There are passages going north, east, south, and west.
    '''
    player_hp = utils.get_player_hp(player_health)
    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 = 2

    done_with_room = False
    if player_hp == 0:
        next_room = 15
        done_with_room = True
    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]
            if direction == 'east':
                next_room = 4
                done_with_room = True
            elif direction == 'west':
                next_room = 3
                done_with_room = True
            elif direction == 'north':
                next_room = 6
                done_with_room = True
            elif direction == 'south':
                next_room = 1
                done_with_room = True
            else:
                print("\n\tYou may not go in that direction.\n\t")
        elif the_command == 'take':
            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':
            status = response[1]
            if status == 'player':
                utils.player_status(player_inventory, player_equipped,
                                    player_health)
            elif status == 'room':
                utils.room_status(room2_inventory, room2_map,
                                  room2_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':
            print("There are no loot sources in this room.")
        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("\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("********************************************************\n")
    # end of main while loop
    return next_room