예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
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
예제 #5
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
예제 #6
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room15_description = '''
        . . .  15th room ... 
        You find yourself in a dead end room. 
        '''

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

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

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

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

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

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
예제 #7
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
예제 #8
0
파일: room7.py 프로젝트: ReidLuhn/maze_game
def run_room(player_inventory):
    # Let the user know what the room looks like
    room7_description = '''
        . . .  7th room ... 
        You find yourself in an almost pitch black room.'''

    if room7_inventory['meat'] == 1:
        room7_description = room7_description + '\nYou see some meat on a plate.'
    if room7_inventory['armor'] == 1:
        room7_description = room7_description + '\nThere is also a set a of armor hanging on the wall.'
    if room7_inventory['trap'] == 1:
        room7_description = room7_description + '\nSuddenly you hear the tell tale signs of a triggered pit trap! You should try jumping!'

    print(room7_description)

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

    # 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 == 'jump':
            if room7_inventory['trap'] == 1:
                if random.randrange(21) > 10:
                    print(
                        "You narrowly avoid the trap! It is now disabled and will not bother you again."
                    )
                    room7_inventory['trap'] = 0
                else:
                    player_inventory[
                        'health'] = player_inventory['health'] - 10
                    if player_inventory['health'] <= 0:
                        print("You died! GAME OVER")
                        break
                    print(
                        "You could not jump far enough and fall into the pit! You take ten points of damage. You are now at",
                        player_inventory['health'], "health.")
                    print(
                        "After some time, you manage to climb out. The trap is now disabled and will not bother you again."
                    )
                    room7_inventory['trap'] = 0
            else:
                print("You jump up and hit your head. Nothing happens.")
        elif the_command == 'go':
            if room7_inventory['trap'] == 1:
                print("You must try to avoid the trap first!")
            else:
                direction = response[1].lower()
                if direction == 'west':
                    next_room = 4
                    done_with_room = True
                elif direction == 'south':
                    next_room = 11
                    done_with_room = True
                else:
                    print("You cannot go", direction)
        elif the_command == 'take':
            if room7_inventory['trap'] == 1:
                print("You must try to avoid the trap first!")
            else:
                take_what = response[1]
                utils.take_item(player_inventory, room7_inventory, take_what)
        elif the_command == 'drop':
            if room7_inventory['trap'] == 1:
                print("You must try to avoid the trap first!")
            else:
                drop_what = response[1]
                utils.drop_item(player_inventory, room7_inventory, drop_what)
        elif the_command == 'status':
            if room7_inventory['trap'] == 1:
                print("You must try to avoid the trap first!")
            else:
                utils.room_status(room7_inventory)
                utils.player_status(player_inventory)
        elif the_command == 'drink':
            potion = response[1]
            if room7_inventory['trap'] > 0:
                print("You must try to avoid the trap first!")
            else:
                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
예제 #9
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room14_description = '''
        . . .  14th room ... 
        You find yourself in a dimly lit room.
        '''

    if room14_inventory['wolf'] > 0:
        room14_description = room14_description + " A wolf sits in front of the only other door to the SOUTH. It is incredibly thin and desperate for food. " \
                                                  "You are starting to look pretty tasty."
    print(room14_description)

    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)
        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 = 12
                done_with_room = True
            if direction == 'south':
                if room14_inventory['wolf'] == 0:
                    next_room = 15
                    done_with_room = True
                else:
                    print("The wolf is still in the way.")
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            if take_what != 'wolf':
                utils.take_item(player_inventory, room14_inventory, take_what)
            else:
                print(
                    "The wolf is chained to the wall. You cannot take her with you."
                )
        elif the_command == 'status':
            utils.room_status(room14_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            if drop_what == 'meat':
                if 'meat' in player_inventory.keys():
                    utils.drop_item(player_inventory, room14_inventory,
                                    drop_what)
                    print(
                        "The wolf tears into it. It seems like she is very happy with you now and moves out of the way."
                    )
                    room14_inventory['wolf'] = 0
            else:
                utils.drop_item(player_inventory, room14_inventory, drop_what)
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'map':
                utils.map(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 == 'use':
            use_what = response[1]
            if use_what == 'sword':
                print(
                    "The second you reach for your sword, the wolf grows at you. There must be another way."
                )
            elif use_what == 'meat':
                if 'meat' in player_inventory.keys():
                    print(
                        "The wolf doesn't want to eat it while you are holding it."
                    )
                else:
                    print("You don't have any.")
            else:
                print("Nothing happens.")

            # END of WHILE LOOP - done_room
            # TODO return next room
    return next_room
예제 #10
0
파일: room4.py 프로젝트: ReidLuhn/maze_game
def run_room(player_inventory):
    description = '''
    . . . 
    You open the door to the fourth room.'''

    if room4_inventory['kobold'] == 1:
        description = description + '\nImmediately you spot a well armed kobold! He lunges at you with his spear! It is kill or be killed!'


    commands = ["go", "take", "drop", "use", "drink", "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
    print(description)

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you do?", commands, no_args)
        response = utils.scrub_response(response)
        the_command = response[0].lower()
        if the_command == 'use':
            if room4_inventory['kobold'] > 0:
                if response[1].lower() == 'sword':
                    blah = True
                    while blah == True:
                        if random.randrange(21) > 5:
                            print("You have slain the kobold!!!")
                            blah = False
                            room4_inventory['kobold'] = 0
                        else:
                            print("You missed!")
                            player_inventory['health'] = player_inventory['health'] - 10
                            print("He attacks you for ten points of damage. Your health is now", player_inventory['health'])
                            if player_inventory['health'] <= 0:
                                print("You died! GAME OVER")
                                break
                            print("Keep fighting!")
                            response = utils.ask_command("What do you do?", commands, no_args)
                else:
                    print("This item cannot kill the kobold!")
            else:
                print("Nothing happens.")
        elif the_command == 'go':
            if room4_inventory['kobold'] == 1:
                print("You must kill the kobold first!")
            direction = response[1]
            # Use your hand drawn map to help you think about what is valid
            if direction == 'south':
                next_room = 3
                done_with_room = True
            elif direction == 'east':
                if room4_inventory['kobold'] == 0:
                    print("You move towards the next room.")
                    done_with_room = True
                    next_room = 7
                else:
                    print("You cannot pass to the next room without killing the kobold!")
            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].lower()
            if take_what == 'kobold':
                print("You cannot take the kobold.")
            else:
                utils.take_item(player_inventory, room4_inventory, take_what)
        elif the_command == 'drop':
            if room4_inventory['kobold'] == 1:
                print("You must kill the kobold first!")
            drop_what = response[1]
            utils.drop_item(player_inventory, room4_inventory, drop_what)
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'map':
                utils.map(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.")
    # end of main while loop
    return next_room
예제 #11
0
파일: room1.py 프로젝트: ReidLuhn/maze_game
def run_room(player_inventory):
    description = '''
    . . . Main Room . . .

    You open your eyes. The room you see is unfamiliar. You see a brightly lit
    doorway to the SOUTH. To the EAST and WEST you see a closed doors.

    '''
    print(Fore.BLUE + Style.BRIGHT + description + Style.RESET_ALL)

    # valid commands for this room
    commands = [
        "go", "take", "drop", "use", "drink", "master", "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 == 'south':
                next_room = 2
                done_with_room = True
            elif direction == 'east':
                is_locked = room_state['door_locked']
                if not is_locked:
                    next_room = 3
                    done_with_room = True
                else:
                    print("The door is locked.")
            elif direction == 'west':
                is_locked2 = room_state['door_locked2']
                if not is_locked2:
                    next_room = 5
                    done_with_room = True
                else:
                    print("The door is locked. You need a magic key.")
            else:
                # In this room, there is nowhere else to go.
                print("There is no way to go,", direction)
        elif the_command == 'take':
            print("There is nothing to take here.")
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room1_inventory, drop_what)
        elif the_command == 'use':
            use_what = response[1]
            if use_what == 'key':
                if 'key' not in player_inventory.keys():
                    print("You don't have a key!")
                else:
                    door_locked = room_state["door_locked"]
                    if door_locked:
                        room_state["door_locked"] = False
                        print("The door to the EAST is unlocked!")
                    else:
                        print("The door was already unlocked!")
            elif use_what == 'magic key':
                if player_inventory['magic key'] == 0:
                    print("You don't have the magic key!")
                else:
                    door_locked2 = room_state["door_locked2"]
                    if door_locked2:
                        room_state["door_locked2"] = False
                        print("The door to the WEST is unlocked!")
                    else:
                        print("The door was already unlocked!")
            else:
                print("Gabe is a genius.")
        elif the_command == 'status':
            utils.room_status(room1_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'examine':
            examine_what = response[1]
            if examine_what == 'map':
                utils.map(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 == 'master':
            phoo = response[1]
            if phoo == 'key':
                next_room = 15
                done_with_room = True

    # end of while loop
    return next_room
예제 #12
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    # valid commands for this room
    room11_description = '''
        . . .  11th room ... 
       You enter a brightly lit room with a large chandelier.'''

    if room11_inventory['dynamite'] == 1:
        room11_description = room11_description + " You see a stick of dynamite."
    if room11_inventory['caltrops'] == 1:
        room11_description = room11_description + " A small bag of caltrops sits in the corner."
    if room11_inventory['healing potion'] == 1:
        room11_description = room11_description + " A healing potion sits on a shelf."
    print(room11_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 == 'north':
                next_room = 7
                done_with_room = True
            else:
                print("You cannot go", direction)
        elif the_command == 'take':
            take_what = response[1].lower()
            utils.take_item(player_inventory, room11_inventory, take_what)
            if take_what == 'dynamite':
                if room11_inventory['spider'] == 1:
                    print(
                        "You hear a soft click, and an enormous spider pops out of a trap door. It jumps and tries to attack you!"
                    )
                    blah = True
                    while blah == True:
                        response = utils.ask_command("What do you do?",
                                                     commands, no_args)
                        the_command = response[0]
                        if the_command != 'use':
                            print(
                                "You must use something to kill the spider first!"
                            )
                        if the_command == 'use':
                            if response[1].lower() == 'sword':
                                if room11_inventory['spider'] > 0:
                                    r = random.randrange(21)
                                    if r > 10:
                                        print("You have slain the spider!!!")
                                        blah = False
                                        room11_inventory['spider'] = 0
                                    else:
                                        print("You missed!")
                                        player_inventory[
                                            'health'] = player_inventory[
                                                'health'] - 10
                                        print(
                                            "He attacks you for ten points of damage. Your health is now",
                                            player_inventory['health'])
                                        if player_inventory['health'] <= 0:
                                            print("You died! GAME OVER")
                                            break
                                        print("Keep fighting!")
                                else:
                                    print("You stab the spider corpse again.")
                            elif response[1].lower() != 'sword':
                                print("You must use your sword to fight!")
                        elif the_command != 'use':
                            print(
                                "You must use something to kill the spider first!"
                            )
                else:
                    print("There is only one stick of it, so use it wisely.")
        elif the_command == 'status':
            utils.room_status(room11_inventory)
            utils.player_status(player_inventory)
        elif the_command == 'drop':
            drop_what = response[1]
            utils.drop_item(player_inventory, room11_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'])
                else:
                    print("You don't have a healing potion.")
            elif potion == 'minor healing potion':
                if 'minor healing potion' in player_inventory.keys():
                    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