Ejemplo n.º 1
0
def game_start():
    # Resize the console for more room (also means no scrollback, potentially more predictable player experience?)
    os.system("mode con: cols=150 lines=70")
    
    ready = input("\nLoad existing saved game? (Y/N)\n» ")
    shouldload = gameparser.normalise_input(ready)

    if len(shouldload) > 0:
        if shouldload[0] == "y" or shouldload[0] == "yes":
            player.load()
    else:
        game_start()          

    typing_print("\nWelcome to CSI: CARDIFF.\n\nMost commands will be displayed at appropiate times in the game, but you can always display the game commands by typing the command HELP.\n\n\n\nYour role in this game is that of a new detective...")

    ready = input("\n\nReady to start the game? (Y/N)\n» ")
    gamestart = gameparser.normalise_input(ready)

    if len(gamestart) > 0:
        if gamestart[0] == "y" or gamestart[0] == "yes":
            # Main game loop
            main()
        else:
            exit()
    else:
        game_start()
Ejemplo n.º 2
0
def riddle_lady():
    """A riddle is given and the player must answer correctly to progress"""
    from player import inventory
    from items import item_ingredients
    global inventory
    if item_ingredients not in inventory:
        print("Are you ready to answer my riddle?")
        print(
            "'What's black when you buy it, red when you use it and white when you throw it away?'"
        )
        ans = input('> ')
        if ans == "":
            return
        from gameparser import normalise_input
        ans2 = normalise_input(ans)
        if ans2[0] == "coal" or ans2[0] == "charcoal":
            print("CORRECT!")
            print("""\"I wanted to test you, to see if you were worthy.
    Here are some ingredients for a hangover cure. You'll definitely find this useful.
    They need to be mixed with water, so you'll need to find something else to contain it.\"\n"""
                  )
            from player import inventory
            from items import item_ingredients
            from conversations import conv_lady
            conv_lady[
                "opening"] = """Leave me be now clerk. I've helped you more than I should."""
            conv_lady["questions"] = ["But..."]
            conv_lady["responses"] = [
                "(The lady turns away from you, she clearly doesn't want to talk)"
            ]
            inventory.append(item_ingredients)
            from game import print_inventory_items

        else:
            print("WRONG! Try again.")
Ejemplo n.º 3
0
def menu(exits, location_items, inv_items):

    # Display menu
    print_menu(exits, location_items, inv_items)

    # Read player's input
    user_input = input("> ")

    # Normalise the input
    normalised_user_input = normalise_input(user_input)

    # Return the input
    return normalised_user_input
Ejemplo n.º 4
0
def print_menu(room):
    # Display room name and items.
    print_room_name(room)
    print_room_items(room)
    print_room_npcs(room)

    # Read player's input
    user_input = input("\n» ")

    # Normalise the input
    normalised_user_input = gameparser.normalise_input(user_input)

    return normalised_user_input
Ejemplo n.º 5
0
def execute_drop(item_id):
    item_in_inv = False

    for item in player.inventory:
        item_not_concact = gameparser.normalise_input(item["id"])
        if len(item_not_concact) > 1:
            item_concact = item_not_concact[0] + item_not_concact[1]
        else:
            item_concact = item_not_concact[0]
        if item_concact == item_id:
            player.current_room["items"].append(item)
            player.inventory.remove(item)
            item_in_inv = True

    if item_in_inv == False:
        print("\nYou cannot drop that.\n")
        sleep(2)
Ejemplo n.º 6
0
def execute_take(item_id):
    item_in_room = False

    for item in player.current_room["items"]:
        item_not_concact = gameparser.normalise_input(item["id"])
        if len(item_not_concact) > 1:
            item_concact = item_not_concact[0] + item_not_concact[1]
        else:
            item_concact = item_not_concact[0]
        if item_concact == item_id:
            player.inventory.append(item)
            player.current_room["items"].remove(item)
            item_in_room = True
            typing_print("\n" + item["id"] + " has been added to your briefcase.\n")
            sleep(2)
    
    if item_in_room == False:
        print("You cannot take that.")
        sleep(2)
Ejemplo n.º 7
0
def conversation(dictionary, npc_id):
    print("\nSelect dialogue option letter or press -enter- to return:\n")

    for key in sorted(dictionary):
        print(str(key).upper() + ': "' + dictionary[key][0] + '"')

    chosen_dialogue = input("\n» ")
    if chosen_dialogue != "":

        dialogue_choice = gameparser.normalise_input(chosen_dialogue)

        if dialogue_choice[0] == "end":
            exit()
        elif dialogue_choice[0] == "a" or dialogue_choice[0] == "b" or dialogue_choice[0] == "c":
            print("\n· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·\n")
            typing_print("YOU" + ': "' + dictionary[dialogue_choice[0]][0] + '"\n')
            sleep(1)
            typing_print(npc_id.upper() + ': "' + dictionary[dialogue_choice[0]][1] + '"\n')
            sleep(2)
            if type(dictionary[dialogue_choice[0]][2]) == dict:
                conversation(dictionary[dialogue_choice[0]][2], npc_id)
            elif type(dictionary[dialogue_choice[0]][2]) == list:
                give_item(dictionary[dialogue_choice[0]][2][0])
                dial_index = npc.npc_dict[npc_id]["d_index"]
                npc.npc_dict[npc_id]["dialogue"] = dialogues.dialswap[npc_id][dial_index]
                npc.npc_dict[npc_id]["d_index"] = dial_index + 1
                return False
            elif dictionary[dialogue_choice[0]][2] == "end_convo":
                return False
            elif dictionary[dialogue_choice[0]][2] == "end_game":
                game_failed()
            elif dictionary[dialogue_choice[0]][2] == "win_game":
                game_win()
            elif dictionary[dialogue_choice[0]][2] == "inc_convo":
                dial_index = npc.npc_dict[npc_id]["d_index"]
                npc.npc_dict[npc_id]["dialogue"] = dialogues.dialswap[npc_id][dial_index]
                npc.npc_dict[npc_id]["d_index"] = dial_index + 1
                return False
    else:
        return False
Ejemplo n.º 8
0
def riddle_lady():
    """A riddle is given and the player must answer correctly to progress"""
    print("Are you ready to answer my riddle?")
    print(
        "'What's black when you buy it, red when you use it and white when you throw it away?'"
    )
    ans = input('> ')
    from gameparser import normalise_input
    ans2 = normalise_input(ans)
    if ans2[0] == "coal" or ans2[0] == "charcoal":
        print("CORRECT!")
        print("""I wanted to test you, to see if you were worthy.
Here are some ingredients for a hangover cure. You'll definitely find this useful.
They need to be mixed with water, so you'll need to find something else to contain it."""
              )
        from player import inventory
        from items import item_ingredients
        inventory.append(item_ingredients)
        from game import print_inventory_items
        print_inventory_items(inventory)
    else:
        print("WRONG! Try again.")
Ejemplo n.º 9
0
def console():
    global answer1
    global answer2
    global answer3
    global answer4
    global answer5
    print("\n///////////////////////////\n")
    print("Hello subject. The questions are:\n")
    print(
        " 1) What is your name?\n" + '  > ' + answer1 +
        "\n\n 2) Who created this facility?\n" + '  > ' + answer2 +
        "\n\n 3) What is your purpose?\n" + '  > ' + answer3 +
        "\n\n 4) What is the name of the company operating this facility?\n" +
        '  > ' + answer4 + "\n\n 5) What are you?\n" + '  > ' + answer5 +
        "\n\n///////////////////////////")
    print('\nAre you ready to answer a question?')
    print('\nYou can type:')
    print(" YES")
    print(" NO")
    print(" CLEAR (To clear all answers)")
    print(" SUBMIT (To submit answers, this can only be done once)")
    print(" NOTE to view notes\n")
    print("///////////////////////////")
    choice = gameparser.normalise_input(input('> '))
    if type(choice) == list:
        if choice[0] == "yes":
            print("Please select a question to answer, 1/2/3/4/5:")
            question = input('> ')
            if question == "1":
                if answer1 == "Unanswered":
                    print("What is your name?")
                    answer1 = input('> ')
                else:
                    print("Do you want to overwrite your previous answer:")
                    print(answer1)
                    if input("YES\nNO\n") == "yes":
                        print("What is your name?")
                        answer1 = input('> ')
            if question == "2":
                if answer2 == "Unanswered":
                    print("Who created this facility?")
                    answer2 = input('> ')
                else:
                    print("Do you want to overwrite your previous answer:")
                    print(answer2)
                    if input("YES\nNO\n") == "yes":
                        print("Who created this facility?")
                        answer2 = input('> ')
            if question == "3":
                if answer3 == "Unanswered":
                    print("What is your purpose?")
                    answer3 = input('> ')
                else:
                    print("Do you want to overwrite your previous answer:")
                    print(answer3)
                    if input("YES\nNO\n") == "yes":
                        print("What is your purpose?")
                        answer3 = input('> ')
            if question == "4":
                if answer4 == "Unanswered":
                    print(
                        "What is the name of the company operating this facility?"
                    )
                    answer4 = input('> ')
                else:
                    print("Do you want to overwrite your previous answer:")
                    print(answer4)
                    if input("YES\nNO\n") == "yes":
                        print(
                            "What is the name of the company operating this facility?"
                        )
                        answer4 = input('> ')
            if question == "5":
                if answer5 == "Unanswered":
                    print("What are you?")
                    answer5 = input('> ')
                else:
                    print("Do you want to overwrite your previous answer:")
                    print(answer5)
                    if input("YES\nNO\n") == "yes":
                        print("What are you?")
                        answer5 = input('> ')
            print("\nReturning you to menu...")
            time.sleep(1.2)
            console()
        elif choice[0] == "clear":
            if 'yes' in gameparser.normalise_input(
                    input(
                        "Are you sure you want to clear all of your current answers?\nYES\nNO\n"
                    )):
                answer1, answer2, answer3, answer4, answer5 = "Unanswered"
                print("Answers cleared.")
                time.sleep(1.5)
                console()
        elif choice[0] == "no":
            print(
                "\nVery well. Explore the complex and find the answers. Quickly now.\n"
            )
        elif choice[0] == "submit":
            if 'yes' in gameparser.normalise_input(
                    input(
                        "Are you sure you want to submit your answers?\nYES\nNO\n"
                    )):
                print("Excellent. Assessing your performance...")
                time.sleep(2)
                score = 0
                if "harris" in gameparser.normalise_input(str(answer1)):
                    score = score + 1
                if "esther" in gameparser.normalise_input(str(answer2)):
                    score = score + 1
                if "jakobe" in gameparser.normalise_input(answer2):
                    score = score + 1
                if "franco" in gameparser.normalise_input(answer2):
                    score = score + 1
                if "freedom" in gameparser.normalise_input(answer3):
                    score = score + 1
                if "culture" in gameparser.normalise_input(answer4):
                    score = score + 1
                if "complex" in gameparser.normalise_input(answer4):
                    score = score + 1
                if "human" in gameparser.normalise_input(answer5):
                    score = score + 1
                win(score)
        elif choice[0] == "note":
            print(items.item_notepad["description"])
            console()
    elif type(choice) == None:
        interact_console()
Ejemplo n.º 10
0
def execute_command(command):
    if 0 == len(command):
        return

    if command[0] == "go" or command[0] == "enter":
        if len(command) > 1:
            if len(command) > 2:
                dest_concact = command[1] + command[2]
                execute_go(dest_concact)
            elif len(command) == 2:
                execute_go(command[1])
            else:
                print("Go where?")
                sleep(2)
        else:
            print("Go where?")
            sleep(2)

    elif command[0] == "take":
        if len(command) > 1:
            if len(command) > 2:
                take_concact = command[1] + command[2]
                execute_take(take_concact)
            elif len(command) == 2:
                execute_take(command[1])
            else:
                print("Take what?")
                sleep(2)
        else:
            print("Take what?")
            sleep(2)

    elif command[0] == "drop":
        if len(command) > 1:
            if len(command) > 2:
                drop_concact = command[1] + command[2]
                execute_drop(drop_concact)
            elif len(command) == 2:
                execute_drop(command[1])
            else:
                print("Drop what?")
                sleep(2)
        else:
            print("Drop what?")
            sleep(2)

    elif command[0] == "help":
        help_response = print_commands_help()
        if help_response == "":
            main()

    elif command[0] == "briefcase":
        inv_response = print_inventory(player.inventory)
        if inv_response == "":
            main()
        else:
            execute_command(gameparser.normalise_input(inv_response))

    elif command[0] == "end":
        ready = input("\nSave game? (Y/N)\n» ")
        shouldload = gameparser.normalise_input(ready)

        if shouldload[0] == "y" or shouldload[0] == "yes":
            player.save()
            
        exit()

    elif command[0] == "save":
        player.save()

    elif command[0] == "exit":
        if player.current_room != map_s.rooms["outsideoutside"]:
            player.current_room = move(player.current_room["exits"], "exit")

    elif command[0] == "talk":
        if len(command) > 1:
            if len(command) > 2:
                npc_concact = command[1] + command[2]
                execute_talk(npc_concact)
            elif len(command) == 2:
                execute_talk(command[1])
            else:
                print("Talk to whom?")
                sleep(2)

    elif command[0] == "open":
        if len(command) > 1:
            if len(command) > 2:
                open_concact = command[1] + command[2]
                execute_open(open_concact)
            elif len(command) == 2:
                execute_open(command[1])
            else:
                print("Open what?")
                sleep(2)
        else:
            print("Open what?")
            sleep(2)

    elif command[0] == "unlock":
        if len(command) > 1:
            if len(command) > 2:
                dest_concact = command[1] + command[2]
                execute_unlock(dest_concact)
            elif len(command) == 2:
                execute_unlock(command[1])
            else:
                print("Unlock where?")
                sleep(2)
        else:
            print("Unlock where?")
            sleep(2)

    else:
        print("This makes no sense.")
        sleep(2)