Example #1
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
Example #2
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
Example #3
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
Example #4
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
Example #5
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
Example #6
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
Example #7
0
def run_room(player_inventory):
    if room12_status["chest locked"] == 1:
        print(room12_description)
    elif room12_status["chest locked"] == 0 and room12_inventory[
            "sapphire"] == 1:
        print(room12_description_chest_unlocked_sapphire_inside)
    else:
        print(room12_description_chest_unlocked_no_sapphire)

    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 = 10
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room12_inventory)
        elif the_command == "examine":
            if room12_status["chest locked"] == 1:
                print(room12_description)
            elif room12_status["chest locked"] == 0 and room12_inventory[
                    "sapphire"] == 1:
                print(room12_description_chest_unlocked_sapphire_inside)
            else:
                print(room12_description_chest_unlocked_no_sapphire)
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room12_inventory, drop_what)
        elif the_command == "take":
            take_what = response[1]
            if take_what == "sapphire":
                if room12_status["chest locked"] == 0:
                    utils.take_item(player_inventory, room12_inventory,
                                    "sapphire")
                else:
                    print(
                        "You cannot take the sapphire while the chest is locked"
                    )
            else:
                utils.take_item(player_inventory, room12_inventory, take_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "key":
                if player_inventory["key"] > 0:
                    player_inventory["key"] = 0
                    room12_status["chest locked"] = 0
                    print("You unlock the chest with your *key* and see a \n"
                          "massive shining blue *sapphire*")
                else:
                    print("You cannot use what you do not possess")
            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
Example #8
0
def run_room(player_inventory):
    emerald_count = room10_inventory["emerald"]
    if emerald_count < 1:
        print(room10_description_no_emerald)
    else:
        print(room10_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 = 11
                done_with_room = True
            elif go_where == "west":
                next_room = 9
                done_with_room = True
            elif go_where == "east":
                next_room = 13
                done_with_room = True
            elif go_where == "south":
                next_room = 12
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room10_inventory)
        elif the_command == "examine":
            emerald_count = room10_inventory["emerald"]
            if emerald_count < 1:
                print(room10_description_no_emerald)
            else:
                print(room10_description)
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room10_inventory, drop_what)
        elif the_command == "take":
            take_what = response[1]
            coin_count = player_inventory["coin"]
            if take_what == "emerald" and coin_count > 0:
                print("Hey, stealing is not very nice!")
            else:
                utils.take_item(player_inventory, room10_inventory, take_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "coin" or use_what == "coins":
                current_coin_count = player_inventory["coin"]
                if current_coin_count == 4:
                    utils.take_item(player_inventory, room10_inventory, "emerald")
                    player_inventory["coin"] = 0
                    print("Wow, maybe you are better than those other adventurers,\n"
                          "thanks for your purchase!")
                else:
                    print("You are gonna need more money than that! I said 4 coins\n "
                          "and I ain't budgin'")
            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
Example #9
0
def run_room(player_inventory):
    room4_description = '''
    . . . Room 4 . . .
    You enter a smaller well lit room with polished, pristine, wooden walls and a cowled 
    figure sitting at a well kept desk. Before you can get a good look at the figure he 
    runs out of the room to the south at an almost inhuman speed. In its haste the creature forgot one shimmering 
    *coin* on the desk. There is a passage to the south and the west.'''

    room4_description_no_coin = '''
    . . . Room 4 . . .
    You enter a smaller well lit room with polished, pristine, wooden walls and a well 
    kept desk and short stool. There is a passage to the south and the west '''

    coin_count = room4_inventory["coin"]
    if coin_count < 1:
        print(room4_description_no_coin)
    else:
        print(room4_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 = 5
                done_with_room = True
            elif go_where == "west":
                next_room = 3
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == 'take':
            take_what = response[1]
            utils.take_item(player_inventory, room4_inventory, take_what)
        elif the_command == "status":
            utils.room_status(room4_inventory)
            utils.player_status(player_inventory)
        elif the_command == "examine":
            coin_count = room4_inventory["coin"]
            if coin_count < 1:
                print(room4_description_no_coin)
            else:
                print(room4_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, room4_inventory, drop_what)
        else:
            print("I do not understand", the_command)

    return next_room
Example #10
0
def run_room(player_inventory):
    if room11_status["dragon alive"] == 0 and room11_inventory["ruby"] == 0:
        print(room11_description_no_dragon_no_ruby)
    elif room11_status["dragon alive"] == 0 and room11_inventory["ruby"] == 1:
        print(room11_description_no_dragon)
    else:
        print(room11_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 = 10
                done_with_room = True
            else:
                print("You cannot go", go_where)
        elif the_command == "status":
            utils.player_status(player_inventory)
            utils.room_status(room11_inventory)
        elif the_command == "examine":
            if room11_status["dragon alive"] == 0 and room11_inventory[
                    "ruby"] == 0:
                print(room11_description_no_dragon_no_ruby)
            elif room11_status["dragon alive"] == 0 and room11_inventory[
                    "ruby"] == 1:
                print(room11_description_no_dragon)
            else:
                print(room11_description)
        elif the_command == "drop":
            drop_what = response[1]
            utils.drop_item(player_inventory, room11_inventory, drop_what)
        elif the_command == "take":
            take_what = response[1]
            if take_what == "ruby":
                if room11_status["dragon alive"] == 0:
                    utils.take_item(player_inventory, room11_inventory, "ruby")
                else:
                    print(
                        "Maybe try doing something about that dragon before\n"
                        "taking the *ruby*")
            else:
                utils.take_item(player_inventory, room11_inventory, take_what)
        elif the_command == "use":
            use_what = response[1]
            if use_what == "sword":
                if utils.has_a(player_inventory, "sword"):
                    room11_status["dragon alive"] = 0
                    print(
                        "You walk up yo the sleeping dragon very stealthily, as\n"
                        "you approach it you can feel its hot breath as it snores\n"
                        "peacefully. You take your sword and stab straight down\n"
                        "into a crack between its scales near its torso. The\n"
                        "dragon makes a terrible roar and lets loose a jet of\n"
                        "flame straight up into the air through its nostrils. The\n"
                        "dragon then falls lifeless to the ground and you feel it\n"
                        "is much safer now to take the *ruby*.")
                else:
                    print("You cannot use what you do not possess.")
            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