예제 #1
0
def run_room(player_inventory, player_health):
    # Let the user know what the room looks like

    if room3_inventory['Crowbar'] == 0:
        room3_description = '''
    . . .  3rd room ... 
    You are in a storage room that feels very familiar. There is nothing else of interest in this room.'''
        print(room3_description)
    else:
        room3_description = '''
        . . .  3rd room ... 
        You are in a storage room that feels very familiar. There is a CROWBAR laying on the ground near the door. . . 
        There is nothing else of interest in this room'''
        print(room3_description)
    # valid commands for this room
    commands = ["go", "take", "drop", "use", "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 = 2
                done_with_room = True

            else:
                print('. . . ')
        elif the_command == 'take':
            take_what = response[1].title()
            utils.take_item( player_inventory, room3_inventory,
                             take_what)
        elif the_command == 'drop':
            drop_what = response[1].title()
            utils.drop_item( player_inventory, room3_inventory,
                         drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory,player_health)
            utils.room_status(room3_inventory)
        else:
            print('The command', the_command, 'is invalid in ROOM3')

    return next_room
예제 #2
0
def run_room(player_inventory, player_health):
    description = '''
    . . . 
    In the gloom, you can just make out the outline of rows of lockers lining the room, and one row in the middle. 
    Light reflects off a shiny handle of a FLASHLIGHT and some BATTERIES next to it.
    Behind the row of lockers, there is an open door leading to complete darkness'''

    print(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 = 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)
        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':
                if r5.is_open == False:
                    print('That room is locked now, you cant get in. . . ')
                else:
                    next_room = 5
                    done_with_room = True
            elif direction == 'east':
                next_room = 2
                done_with_room = True
            else:
                # In this room, there is nowhere else to go.
                print('. . . ')
        elif the_command == 'take':
            take_what = response[1].title()
            utils.take_item( player_inventory, room4_inventory,
                             take_what)
        elif the_command == 'drop':
            drop_what = response[1].lower()
            utils.drop_item( player_inventory, room4_inventory,
                         drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory, player_health)
            utils.room_status(room4_inventory)
        else:
            print("Command not implemented in ROOM 2,", the_command)

    # end of main while loop
    return next_room
예제 #3
0
def run_room(player_inventory, player_health):
    blind = True
    can_use_shower = False
    description = '''It's pitch black in here, you can't even tell what type of room this is.
    Using a FLASHLIGHT would be pretty useful right about now . . . 
    If you don't have a flashlight, you could always EXAMINE the room . . .'''

    print(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 == 'east':
                next_room = 4
                done_with_room = True
                is_open = False
            else:
                # In this room, there is nowhere else to go.
                print('. . . ')
        elif the_command == 'use':
            use_what = response[1].title()
            if use_what == "Flashlight":
                if 'Flashlight' in player_inventory:
                    blind = False
                    can_use_shower = True
                    print(
                        '''You use your FLASHLIGHT. Upon shining it around the room, you quickly discern this room is a bathroom.
                    There are stalls and urinals on one side . . .
                     You shine your light to the other side of the room . . .
                     . . . The other side has a few showers. Using the SHOWER to get some water doesn't seem like such a bad idea . . .'''
                    )
                else:
                    print('You cannot use that here')
            if use_what == 'Shower' and can_use_shower:
                player_health = player_health + 20
                print(
                    'The water quenches your thirst and gives you extra strength. You now have',
                    player_health,
                    'health. However, now the shower is out of water.')
                can_use_shower = False
            else:
                print('You cant use that here. . . ')
        elif the_command == 'take':
            take_what = response[1].title()
            utils.take_item(player_inventory, room5_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1].title()
            utils.drop_item(player_inventory, room5_inventory, drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory, player_health)
            utils.room_status(room5_inventory)
        elif the_command == 'examine':
            injury_chance = random.randint(0, 4)
            if injury_chance == 1 or 2:
                print(
                    '''You slam your head into a nearby wall. You storm out of the room, slamming the door shut as you go.
                You quickly realize the door locked behind you.''')
                player_health = player_health - 5
                next_room = 4
                done_with_room = True
                is_open = False
            else:
                print(
                    '''You use your hands to guide you along the edge of the bathroom. You reach a corner and you feel a handle.
                Upon turning it you realize it is a SHOWER. You can now use the SHOWER.'''
                )
                can_use_shower = True
    else:
        print('You cannot do that in this room')

    # end of main while loop
    return next_room
예제 #4
0
def run_room(player_inventory, player_health):
    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

    description = '''. . . 
Moonlight penetrates the large glass panes on the ceiling to reveal the room is much larger than you anticipated. . . 
It seems to be a large dining hall. . . 
It seems there was a conflict here not long ago, there is flecks of blood on the floor, and most of the tables have been overturned. . . 
There are doors each leading NORTH, SOUTH, and EAST, and you notice a lock holding the EASTERN door shut. . . 
The only thing that you see that could be actually useful to you is a BUTTER KNIFE laying close by. . .'''
    print(description)

    if 'Flashlight' in player_inventory:
        print(
            'As always, you could always use your FLASHLIGHT to maybe reveal things that would otherwise be hidden. . . '
        )

    if 'Crowbar' or 'Bump Key' in player_inventory:
        print('You have some tools that could deal with that lock. . .')

    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 room_state['in_combat'] == True:
            if room_state['enemy_health'] == 30:
                room_state['surprise'] = False
                print(
                    'A strained scream pierces through the darkness as a shape rushes towards you knocking you backwards. . . '
                    'It slashes a cut in your arm dealing 10 damage'
                    'You realize as you get up that it is a mental patient just like you, only this one has lost its mind. . .'
                    'You are going to have to take care of it before you do anything else. . . .'
                )

                player_health = player_health - 10

            if the_command == 'use':
                use_what = response[1].title()
                if use_what in player_inventory:
                    if player_inventory[use_what] > 0:
                        if use_what == 'Flashlight':
                            print(
                                'You blind the patient with your flashlight and hit him with the end of the flashlight dealing 15 damage'
                            )
                            room_state['enemy_health'] = room_state[
                                'enemy_health'] - 15
                        elif use_what == 'Butter Knife':
                            print(
                                'You actually manage to draw blood with the dull knife by hacking furiously, dealing 5 damage'
                            )
                            room_state['enemy_health'] = room_state[
                                'enemy_health'] - 5
                        elif use_what == "Sub Machine Gun":
                            print(
                                'You shoot him in the chest and he stumbles backward  dealing 30 damage'
                            )
                            room_state['enemy_health'] = room_state[
                                'enemy_health'] - 30
                        elif use_what == 'Glass Shard':
                            print(
                                'The glass shard rips trough his gown and opens a gash along his arm dealing 10 damage'
                            )
                            room_state['enemy_health'] = room_state[
                                'enemy_health'] - 10
            elif the_command == 'status':
                utils.player_status(player_inventory, player_health)
                utils.room_status(room6_inventory)
            else:
                print('While in combat you cannot use that command')

            if room_state['enemy_health'] <= 0:
                print('The crazed patient falls to the ground dead')
                room_state['in_combat'] = False
                room_state['surprise'] = False

        if room_state['in_combat'] == False:
            room_state['surprise'] = False
            if the_command == 'go':
                direction = response[1]
                if direction == 'north':
                    next_room = 2
                    done_with_room = True
                elif direction == 'east':

                    if room_state['door_locked'] == False:
                        next_room = 7
                        done_with_room = True
                    else:
                        print('The door is locked . . .')
                elif direction == 'south':
                    next_room = 8
                    done_with_room = True
                else:
                    print('You cannot go', direction, 'in this room. . . ')

            elif the_command == 'take':
                take_what = response[1].title()
                if take_what in room6_inventory:
                    utils.take_item(player_inventory, room6_inventory,
                                    take_what)
                    if take_what == 'Sub Machine Gun' or 'Butter Knife':
                        room_state['surprise'] = True
                        room_state['in_combat'] = True
                else:
                    print('There is nothing like that in this room')
            elif the_command == 'drop':
                drop_what = response[1].title()
                utils.drop_item(player_inventory, room6_inventory, drop_what)
            elif the_command == 'status':
                utils.player_status(player_inventory, player_health)
                print('In this room you can see. . .' 'a Butter Knife ')

            elif the_command == 'use' and room_state['in_combat'] == False:
                use_what = response[1].title()
                if use_what in player_inventory:
                    if player_inventory[use_what] > 0:
                        if use_what == 'Flashlight':
                            print('. . .')
                            time.sleep(1.0)
                            print(
                                '''. . . You flip the switch on the flashlight and shine it around the room. . . 
                    In the farthest SOUTHERN corner, you see some thing reflect the flashlight beam back to you. . . 
                    After making your way towards the source, you realize it's a SUB MACHINE GUN and there is a GUARD I.D. next to it'''
                            )

                        elif use_what == 'Crowbar' or use_what == 'Bump Key':
                            if room_state['continue_trying'] == True:
                                open_chance = random.randint(0, 4)

                                if open_chance == 1:

                                    if use_what == 'Crowbar':

                                        print(
                                            'The crowbar snaps in half. . . ')
                                        room_state['door_locked'] = True
                                        room_state['continue_trying'] = False
                                        del player_inventory['Crowbar']

                                    elif use_what == 'Bump Key':
                                        print(
                                            'It seems like you cant get any of the keys to work and the door stays locked. One of the keys is now pretty bent. . . '
                                            'You stop trying out of fear of breaking your tools. . . It does look like your BUMP KEYS are still usable though. . . .'
                                        )
                                        room_state['door_locked'] = True
                                        room_state['continue_trying'] = False

                                elif open_chance == 2 or 3 or 4 or 5:
                                    room_state['door_locked'] = False
                                    print(
                                        '. . . It worked! The door is now unlocked. . .'
                                    )

                            else:
                                print(
                                    'It isnt worth broken tools. . . you move on . . . '
                                )
                else:
                    print('''You don't have a''', use_what)

    return next_room
예제 #5
0
def run_room(player_inventory, player_health):
    description = '''
    . . . 
    You are in a brightly lit hallway with rooms identical to yours lining the walls and alarms blaring overhead. 
    Just as you walk in, all the doors begin to close automatically.
    All of a sudden, the lights cut out, as well as the alarms. 
    A few moments later, the lights come back on, but much dimmer, the alarms come back to life, more deafening than ever. At the end of the hall on the SOUTH side, one door is still open.
    To the WEST there is an open door 
    You see a GREEN BACKPACK in the far left corner and a BUMP KEY next to it.
    . . . 
    '''

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

    # 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 = 6
                done_with_room = True
            elif direction == 'east':
                next_room = 3
                done_with_room = True
            elif direction == 'west':
                next_room = 4
                done_with_room = True

            else:
                # In this room, there is nowhere else to go.
                print('. . . ')
        elif the_command == 'take':
            take_what = response[1].title()
            utils.take_item(player_inventory, room2_inventory, take_what)
        elif the_command == 'drop':
            drop_what = response[1].title()
            utils.drop_item(player_inventory, room2_inventory, drop_what)
        elif the_command == 'status':
            utils.player_status(player_inventory, player_health)
            utils.room_status(room2_inventory)
    else:
        print('You cannot', the_command, 'in this room')

    # end of main while loop
    return next_room