Example #1
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room3_description)
    global kobold_alive

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

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


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

        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "west":
                next_room = 1
                done_with_room = True
            elif go_where == "north":
                next_room = 5
                done_with_room = True
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room3_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room3_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room3_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room3_inventory, room3_locked, response)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "kobold", kobold_health, kobold_alive, response)
            kobold_health = x
            if x <= 0:
                print("the kobold is dead")
                kobold_alive = False
        else:
            print("The command:", the_command, "has not been implemented in room 3")
        x = utils.creature_action(kobold_alive, player_inventory, kobold_atk_org, "kobold")
        if x:
            next_room = 666
            done_with_room = True
    return next_room
Example #2
0
def run_room(player_inventory):
    global rat_alive
    description = '''
    . . . 
    You are in a brightly lit room. The room appears to be an office. There are doors exiting heading west and north.
    There is a large rat lying on the table.'''

    print(description)

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

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

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

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

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

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

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

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

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

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

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

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands,
                                     no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "south":
                next_room = 5
                done_with_room = True
            elif go_where == "east":
                is_locked = room7_locked["east"]
                if not is_locked:
                    next_room = 9
                    done_with_room = True
                if is_locked:
                    print("door is locked")
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room7_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room7_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room7_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room7_inventory, room7_locked,
                         response)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "wolves", wolves_health,
                             wolves_alive, response)
            wolves_health = x
            if x <= 0:
                print("the wolves are dead")
                wolves_alive = False
        else:
            print("The command:", the_command,
                  "has not been implemented in room 7")
        x = utils.creature_action(wolves_alive, player_inventory, wolves_atk,
                                  "wolves")
        if x:
            next_room = 666
            done_with_room = True
    return next_room
Example #6
0
def run_room(player_inventory):
    # Let the user know what the room looks like
    print(room11_description)
    global kobolds_alive

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

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

    done_with_room = False
    while not done_with_room:
        # Examine the response and decide what to do
        response = utils.ask_command("What do you want to do?", commands, no_args)
        the_command = response[0].lower()
        response = utils.scrub_response(response)
        # now deal with the command
        if the_command == 'go':
            go_where = response[1].lower()
            if go_where == "west":
                next_room = 9
                done_with_room = True
            elif go_where == "north":
                is_locked = room11_locked["north"]
                if not is_locked:
                    next_room = 13
                    done_with_room = True
                if is_locked:
                    print("door is locked")
            else:
                print("That direction is not an option")
        elif the_command == 'take':
            utils.take(player_inventory, room11_inventory, response)
        elif the_command == 'drop':
            utils.drop(player_inventory, room11_inventory, response)
        elif the_command == "status":
            utils.player_status(player_inventory)
        elif the_command == "examine":
            utils.examine(room11_inventory)
        elif the_command == "unlock":
            utils.unlock(player_inventory, room11_inventory, room11_locked, response)
        elif the_command == "attack":
            x = utils.attack(player_inventory, "kobolds", kobolds_health, kobolds_alive, response)
            kobolds_health = x
            if x <= 0:
                print("the kobolds are dead")
                kobolds_alive = False
        else:
            print("The command:", the_command, "has not been implemented in room 11")
        x = utils.creature_action(kobolds_alive, player_inventory, kobolds_atk, "kobolds")
        if x:
            next_room = 666
            done_with_room = True
        if utils.has_a(player_inventory, "healing rune"):
            for i in range(3):
                if utils.player_health["health"] < 20:
                    utils.player_health["health"] = utils.player_health["health"] + 1
                print("you've been healed extra for having the healing rune and by the magical pool")
        else:
            for i in range(2):
                if utils.player_health["health"] < 20:
                    utils.player_health["health"] = utils.player_health["health"] + 1
            print("you've been healed for being by the magical pool")
    return next_room