Ejemplo n.º 1
0
def handle_server_text(client, msg):
    c.current_chunk = msg
    for msg_line in msg.split("\n"):
        c.current_line = msg_line
        print(f"> {msg_line}")
        stripped_line = strip_ansi(msg_line).strip()
        client.handle_triggers(stripped_line)
Ejemplo n.º 2
0
def parse_who_here(current_chunk):
    current_chunk = strip_ansi(current_chunk)
    found_start = False
    for line in current_chunk.split("\r\n"):
        if "You see the following people here:" in line:
            found_start = True
        elif found_start:
            people_here = line.split(", ")
            break
    echo(f"people here: {people_here}")
Ejemplo n.º 3
0
def parse_enemies(current_chunk):
    """
    You have the following enemies:
    Farrah
    Mezghar
    You have currently used 2 enemy slots of your 20 maximum.
    """
    global enemies
    global frenemy
    current_chunk = strip_ansi(current_chunk)
    m = re_enemies.search(current_chunk)
    enemies = m.groups()[0].split("\r\n")
    c.echo(f"enemies: {' '.join(enemies)}")
    frenemy.notify("enemies", enemies)
Ejemplo n.º 4
0
def parse_allies(current_chunk):
    """
    You have the following allies:
    Ada is an ally (M).
    Aina is an ally.
    Rhogan is an ally.
    You have currently used 5 ally slots of your 20 maximum.
    """
    global allies
    global frenemy
    current_chunk = strip_ansi(current_chunk)
    allies = re_allies.findall(current_chunk)
    c.echo(f"allies: {' '.join(allies)}")
    frenemy.notify("allies", allies)
Ejemplo n.º 5
0
def queued_throw_dagger(current_chunk):
    #Running queued eqbal command: STAND;GET DAGGER;THROW DAGGER AT RASAHI ACONITE\r\nYou are not fallen or kneeling.\r\nI see no \"dagger\" to take.\r\nYou rub some aconite on an obsidian dagger.\r\nYou c**k back your arm and throw an obsidian dagger at Rasahi.

    #Running queued eqbal command: STAND;GET DAGGER;THROW DAGGER AT RASAHI ACONITE\r\nYou are not fallen or kneeling.\r\nYou pick up an obsidian dagger.\r\nYou must have whatever you wish to throw wielded.

    #Lizabel twists her body out of harm's way.


    current_chunk = strip_ansi(current_chunk)

    info = {}
    info["missed"] = False

    for line in current_chunk.split("\r\n"):

        matches = re_venom.match(line)
        if matches:
            m = matches.groups()
            venom = m[0]
            weapon = m[1]
            c.echo(f"venom: {venom} weapon: {weapon}")
            info["venom"] = venom
            info["weapon"] = weapon
            continue

        matches = re_throw.match(line)
        if matches:
            m = matches.groups()
            weapon = m[0]
            target = m[1]
            info["target"] = target
            c.echo(f"target: {target} weapon: {weapon}")

        if line == "You must have whatever you wish to throw wielded.":
            c.echo(f"{Fore.YELLOW}{Style.BRIGHT}#######################")
            c.echo("## NOT JUGGLING !!!  ##")
            c.echo(f"#######################{Style.NORMAL}")

        matches = re_throw_miss.match(line)
        if matches:
            info["missed"] = True

    if info["missed"] == False:
            c.echo(f"{Fore.YELLOW}{Style.BRIGHT}#######################")
            c.echo("## NOT JUGGLING !!!  ##")
            c.echo(f"#######################{Style.NORMAL}")
Ejemplo n.º 6
0
def find_and_ally_party(matches):
    first_dash = False
    members = []
    for line in c.current_chunk.split("\r\n"):
        line = strip_ansi(line)
        if line == "Your party has the following members:":
            continue
        elif line == "-------------------------------------------------":
            if not first_dash:
                first_dash = True
            else:
                # should be at the end
                break
        else:
            line = line.rstrip(".")
            line = line.rstrip(",")
            echo(line)
            members.extend(line.split(", "))
            echo(members)
    [ally_person(m) for m in members]
    c.remove_temp_trigger("party_member_trigger")
Ejemplo n.º 7
0
async def handle_from_server_queue(from_server_queue):

    while True:
        data = await from_server_queue.get()
        c.current_chunk = data
        c.main_log(data, "server_text")
        output = []
        try:
            for line in data.split("\n"):

                c.modified_current_line = None
                c.current_line = line
                stripped_line = strip_ansi(line).rstrip("\r")
                c.handle_triggers(stripped_line)

                # c.echo(f"stripped_line: '{ascii(stripped_line)}'")
                # c.echo(f"dl: {c._delete_lines}")
                if c._delete_line is True or stripped_line in c._delete_lines:
                    # "delete" the line by not appending it to the output
                    c._delete_line = False
                elif c.modified_current_line is None:
                    output.append(line)
                elif c.modified_current_line != "":
                    output.append(c.modified_current_line)

            # clear the delete_lines
            c._delete_lines.clear()

            c.run_after_current_chunk()

            # some triggers have probably queued stuff to send, so send it
            if c.to_send:
                c.send_flush()
            c.echo("\n".join(output).strip())

            from_server_queue.task_done()

        except Exception:
            traceback.print_exc(file=sys.stdout)
Ejemplo n.º 8
0
 def delete_lines(self, lines):
     for line in lines:
         self._delete_lines.add(strip_ansi(line).rstrip("\r"))