Exemplo n.º 1
0
def check_solving_command(data, command, target):
    """
    Check if the command needed to progress is the command provided
    """
    ret = False
    room = room_cmds.get_curr_room(data)
    if "actions" in room["objects"][target]:
        actions = room["objects"][target]["actions"]
        if room["objects"][target]["itemstate"] >= 0 and room["objects"][
                target]["itemstate"] < len(actions):
            curr_action = actions[room["objects"][target]["itemstate"]]
            if curr_action["action"] == command and room["objects"][target][
                    "name"] == target:
                if "requires" in curr_action:
                    if check_requires(data, target):
                        ret = True
                elif "required_item" in curr_action:
                    if check_requires_item(data, target):
                        ret = True
                else:
                    ret = True
        if ret is True:
            do_solving_command(data, target)
        else:
            send_item_error(room, target, command)
Exemplo n.º 2
0
def command_return(result, data, target):
    """
    handle return values from solving function
    """
    room = room_cmds.get_curr_room(data)
    print(result["msg"])
    if result["event"] == "activate":
        activate_object(result["value"], data)
    elif result["event"] == "drop_item":
        for item in result["value"]:
            room["items"].append(item)
    elif result["event"] == "get_item":
        for item in result["value"]:
            data["inventory"].append(item)
    elif result["event"] == "unlock_door":
        open_door(data, room, room["objects"][target])
        print("Mystisk röst: " + room["unlock_msg"])
    elif result["event"] == "open_chest":
        open_chest(result, data)
    elif result["event"] == "riddle":
        ask_riddle(result, data)
    elif result["event"] == "read_book":
        read_book(result, data)
    elif result["event"] == "solve":
        solve(result, data)

    if "complete_objective" in result:
        room["objectives"][result["complete_objective"]] = True
Exemplo n.º 3
0
def print_clue():
    """
    prints out a clue to solve the current step of the room
    """
    room = room_cmds.get_curr_room(data)
    roomstate = room["state"]
    print(room["clues"][roomstate])
Exemplo n.º 4
0
def check_requires(data, target):
    """
    check if required objective for object is solved
    """
    room = room_cmds.get_curr_room(data)
    ret = False

    if room["objectives"][room["objects"][target]["actions"][
            room["objects"][target]["itemstate"]]["requires"]] is True:
        ret = True
    return ret
Exemplo n.º 5
0
def check_requires_item(data, target):
    """
    Check if required item for object is in inventory
    """
    room = room_cmds.get_curr_room(data)
    ret = False

    if inv.in_inv(
            data,
            room["objects"][target]["actions"][0]["required_item"]) is True:
        # do_solving_command(data, target)
        ret = True
    return ret
Exemplo n.º 6
0
def do_solving_command(data, target):
    """
    run solving command provided and eventual events triggered
    """
    room = room_cmds.get_curr_room(data)

    result = room["objects"][target]["actions"][room["objects"][target]
                                                ["itemstate"]]["done"]

    if "solve" in result:
        room["state"] += 1
        room["objects"][target]["itemstate"] += 1

    command_return(result, data, target)
Exemplo n.º 7
0
def get_cmd_target(data, choice):
    """
    Parse the command input and gets the target value
    """
    room = room_cmds.get_curr_room(data)
    target = None
    if " " in choice:
        choice_arr = choice.split(" ", 1)
        temp_target = choice_arr[1].strip()
        try:
            if temp_target in room["objects"]:
                target = room["objects"][temp_target]["name"]
            elif temp_target in room["items"] or inv.in_inv(
                    data, temp_target) is True:
                target = temp_target
        except Exception:
            print("Objektet kändes inte igen.")
            target = False

    return target
Exemplo n.º 8
0
def do_command(data, command, target):
    """
    run command provided
    """
    room = room_cmds.get_curr_room(data)

    if command == "titta":
        state = room["objects"][target]["itemstate"]

        if target in room["objects"] and "descr" in room["objects"][target]:
            descr = room["objects"][target]["descr"]
            if state == -1:
                if "inactive_descr" in room["objects"][target]:
                    print(room["objects"][target]["inactive_descr"])
            elif state < len(descr):
                print(descr[state])
            else:
                print(descr[state - 1])
    else:
        pass
Exemplo n.º 9
0
def do_cheat():
    """
    solves the current room automatically
    """
    room = room_cmds.get_curr_room(data)

    for item_object in room["objects"]:
        if "max_state" in room["objects"][item_object]:
            room["objects"][item_object]["state"] = len(
                room["objects"][item_object]["descr"]) - 1

    for obj in room["objectives"]:
        room["objectives"][obj] = True

    if "got_items" in room:
        for item in room["got_items"]:
            data["inventory"].append(item)

    if data["current_room"] == 1:
        data["rooms"][4]["objectives"]["book_read"] = True

    room["state"] = len(room["clues"]) - 1
Exemplo n.º 10
0
def check_wall(data, signs, result):
    """
    check if the stone wall-game is solved
    """
    room = room_cmds.get_curr_room(data)

    if data["stone_wall_solution"] == signs:
        result["cinematic"][0][5] = result["cinematic"][0][5].format(
            signs[0], signs[1], signs[2], signs[3])
        result["cinematic"][1][6] = result["cinematic"][1][6].format(
            signs[0], signs[1], signs[2], signs[3])
        room["state"] += 1
        room["objects"]["stenvägg"]["itemstate"] += 1

        room["objectives"]["door_open"] = True
        room["objectives"]["door_unlocked"] = True

        for picture in result["cinematic"]:
            print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
            print("Du löste hemligheten!")
            graphic = ""
            for line in picture:
                graphic += line + "\n"

            print(graphic)
            time.sleep(1)
        time.sleep(1)
        print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
        print("Du löste hemligheten!")
        print("Du kan lämna källaren och äntligen komma ut!")
        print(
            "Mystisk röst: Är du ute?! Hur är det end möjligt?! Du ska få igen för det här!"
        )
    else:
        print("Alla tecken återställs till sin ursprungliga position.")
        print("Du angav fel lösning på pusslet.")
Exemplo n.º 11
0
def activate_object(curr_object, data):
    """
    make object active and usable
    """
    room = room_cmds.get_curr_room(data)
    room["objects"][curr_object]["itemstate"] += 1
Exemplo n.º 12
0
def print_info():
    """
    prints out the descr of the room
    """
    room = room_cmds.get_curr_room(data)
    print(room["descr"])