예제 #1
0
    bal = gmcp_data.get("bal")
    eq = gmcp_data.get("eq")

    if bal == "1" and s.bal == "0":
        # echo("Got back balance!")
        pass
    elif bal == "0" and s.bal == "1":
        # echo("Lost balance!")

        # time how long it takes
        if s.show_balance_times:
            end_msg = r"^You have recovered balance on all limbs.$"
            create_end_timer("bal", end_msg)

    if eq == "1" and s.eq == "0":
        # echo("Got back eq!")
        pass
    elif eq == "0" and s.eq == "1":
        # echo("Lost eq!")

        # time how long it takes
        if s.show_balance_times:
            end_msg = r"^You have recovered equilibrium.$"
            create_end_timer("eq", end_msg)

    s.bal = bal
    s.eq = eq


c.add_gmcp_handler("Char.Vitals", gmcp_bal_eq)
예제 #2
0
        from achaea.monk import (
            ab_kaido,
            ab_tekura,
            ab_telepathy,
            monk_battlerage,
            monk_misc,
            monk_moves,
        )
    """
    elif name.lower() == "sylvus":
        echo("Loading modules for sylvus!")
        from achaea import serpent
    """


c.add_gmcp_handler("Char.Name", handle_login_info)


def show_help(alias_group):
    lines = [
        f"{pattern:15.15} : {desc}"
        for pattern, desc in c.help_info.get(alias_group, [])
    ]
    help_lines = "\n".join(lines)
    return echo(f"{alias_group}:\n{help_lines}")


base_aliases = [
    ("#help (.*)", "show help", lambda m: show_help(m[0])),
]
c.add_aliases("base", base_aliases)
예제 #3
0
import ui.core
from client import c, echo

from achaea.state import s

# Char.Vitals:
# {"hp": "1350", "maxhp": "1350", "mp": "1485", "maxmp": "1485", "ep": "4600", "maxep": "4600", "wp": "4600", "maxwp": "4600", "nl": "1", "bal": "1", "eq": "1", "string": "H:1350/1350 M:1485/1485 E:4600/4600 W:4600/4600 NL:1/100 ", "charstats": ["Bleed: 0", "Rage: 0"]}


def gmcp_vitals(gmcp_data):
    prompt_text = create_prompt_text(gmcp_data)
    ui.core.update_prompt_info(prompt_text)


c.add_gmcp_handler("Char.Vitals", gmcp_vitals)


def get_char_stat(prompt_info, stat_type):
    char_stats = prompt_info.get("charstats", [])
    for stat in char_stats:
        if stat.startswith(stat_type):
            s_type, amount = stat.split(" ")
            return amount
    return "???"


def create_prompt_text(prompt_info):
    hp = prompt_info.get("hp", "???")
    max_hp = prompt_info.get("maxhp", "???")
    mp = prompt_info.get("mp", "???")
    max_mp = prompt_info.get("maxmp", "???")
예제 #4
0
RoomHindrance = namedtuple("RoomHindrance", "name short_name id direction")


def add_room_hindrance(gmcp_data):
    # Char.Items.Add
    # {"location": "room", "item": {"id": "550634", "name": "a large wall of ice"}}

    # make sure it's for the room
    if gmcp_data.get("location") != "room":
        return

    item = gmcp_data.get("item", {})
    name = item.get("name", "")

    if name in ROOM_HINDRANCE_NAMES:
        new_hindrance = RoomHindrance(
            name=name,
            short_name=SHORT_NAMES[name],
            id=item.get("id", ""),
            direction="?",
        )

        # store it in the state
        s.room_hindrance = (*s.room_hindrance, new_hindrance)

    # TODO: other things to look for: gravehands, occultist tentacles, stone walls,
    # piety


c.add_gmcp_handler("Char.Items.Add", add_room_hindrance)
예제 #5
0
from client import c, echo, send
from client.messenger import SimpleMessenger
from client.logger import SimpleFileLogger


says = SimpleMessenger()
says_logger = SimpleFileLogger("says.log")
says.attach(says_logger)


def handle_says(gmcp_data):
    says(gmcp_data["text"])
c.add_gmcp_handler("Comm.Channel.Text", handle_says)
예제 #6
0
        items = gmcp_data["items"]
        mobs = get_mobs_from_items(gmcp_data["items"])
    except Exception as e:
        echo(f"find_mobs_in_room: {e}")
        echo(f"gmcp_data: {gmcp_data}")
        return False

    # update the mobs_in_room set
    s.mobs_in_room = tuple(mobs)

    # push to the ui
    frenemies_text = create_frenemies_text()
    update_frenemies_info(frenemies_text)


c.add_gmcp_handler("Char.Items.List", find_mobs_in_room)


def mob_entered_room(gmcp_data):
    # Char.Items.Add { "location": "room", "item": { "id": "118764", "name": "a young rat", "icon": "animal", "attrib": "m" } }

    # Char.Items.Add {"location": "room", "item": {"id": "31722", "name": "a stirge's egg"}}

    if gmcp_data["location"] == "room" and "m" in gmcp_data.get(
            "item", {}).get("attrib", []):
        item = gmcp_data["item"]
        short_name, mob_id = get_mob_id(item)
        item["short_name"] = short_name
        s.mobs_in_room = (*s.mobs_in_room, (mob_id, item))

    # push to the ui
예제 #7
0
import asyncio

from achaea.basic import curebal, eqbal
from achaea.state import s
from client import c, echo, send
from client.timers import timers


def gmcp_defences(gmcp_data):
    s.defences = tuple(defence["name"] for defence in gmcp_data)


c.add_gmcp_handler("Char.Defences.List", gmcp_defences)


def gmcp_defences_add(gmcp_data):
    defence = gmcp_data["name"]
    # echo(f"Woo!  We've gained {defence}!")
    s.defences = (*s.defences, defence)


c.add_gmcp_handler("Char.Defences.Add", gmcp_defences_add)


def gmcp_defences_remove(gmcp_data):
    lost_defences = set(gmcp_data)
    echo(f"Egads!  We've lost {lost_defences}!")
    s.defences = tuple(set(s.defences).difference(lost_defences))
    # defences("")

예제 #8
0
ferocity = 0


def gmcp_ferocity(gmcp_data):
    #Char.Vitals { "hp": "4500", "maxhp": "4275", "mp": "4107", "maxmp": "4207", "ep": "16525", "maxep": "16525", "wp": "14275", "maxwp": "14275", "nl": "32", "bal": "1", "eq": "1", "vote": "1", "string": "H:4500/4275 M:4107/4207 E:16525/16525 W:14275/14275 NL:32/100 ", "charstats": [ "Bleed: 0", "Rage: 0", "Spec: Sword and Shield", "Ferocity: 0" ] }
    global ferocity
    char_stats = gmcp_data.get("charstats", [])
    for stat in char_stats:
        if stat.startswith("Ferocity: "):
            _, str_ferocity = stat.split(" ")
            ferocity = int(str_ferocity)
    if ferocity > 0:
        c.echo(f"Ferocity: {ferocity}")


c.add_gmcp_handler("Char.Vitals", gmcp_ferocity)


def raze_target(shielder):
    if shielder == s.target:
        eqbal(f"stand;raze {s.target}", prepend=True)


def stop_raze(shielder):
    if shielder == s.target:
        c.echo(f"{s.target} stopped rebounding!  Stop razing!")


shielding_triggers = [
    (
        r"^A nearly invisible magical shield forms around (.*?).$",
예제 #9
0
        lambda matches: echo(f"Monolith in room: {monolith_in_room()}"),
    ),
    ("^cir$", "Char.Items.Room",
     lambda matches: c.gmcp_send('Char.Items.Room ""')),
]
c.add_aliases("room_info", room_aliases)


def room_items(gmcp_data):
    if gmcp_data.get("location", "") != "room":
        return

    s.room_items = tuple(gmcp_data.get("items", []))


c.add_gmcp_handler("Char.Items.List", room_items)


def monolith_in_room():
    """
    s.room_items = (
        { "id": "12027", "name": "a bloody cross" },
        { "id": "22082", "name": "a runic totem", "icon": "rune" },
        { "id": "58874", "name": "a Khaal Theurgist", "icon": "guard", "attrib": "mx" },
        { "id": "169411", "name": "a monolith sigil", "icon": "rune", "attrib": "t" },
        { "id": "176739", "name": "a sewer grate", "icon": "door" },
        { "id": "183679", "name": "a shrine of Sartan", "icon": "shrine" },
    )
    """
    for item in s.room_items:
        if item.get("name", "") == "a monolith sigil":
예제 #10
0
    for stat in char_stats:
        name, value = stat.split(": ")

        if name.lower() == "angelpower":
            global angel_power
            angel_power = int(value)
            #c.echo(f"angel_power: {angel_power}")

        elif name.lower() == "devotion":
            global devotion
            devotion = int(value.rstrip("%"))
            #c.echo(f"devotion: {devotion}")

        elif name.lower() == "conviction":
            global conviction
            conviction = int(value)
            #c.echo(f"conviction: {conviction}")

        elif name.lower() == "prayer_length":
            global prayer_length
            prayer_length = int(value)
            #c.echo(f"prayer_length: {prayer_length}")

        elif name.lower() == "prayer":
            global prayer
            prayer = value
            #c.echo(f"prayer: {prayer}")


c.add_gmcp_handler("Char.Vitals", gmcp_priest_status)
예제 #11
0
    party_announce(f"Target: {s.target}", "target")

    send(f"SETTARGET {s.target}")

    # set the target trigger
    target_trigger = (
        s.target,
        lambda m: highlight_current_line(Fore.RED, pattern=s.target, flags=re.I),
    )
    c.add_temp_trigger("target_trigger", target_trigger, flags=re.IGNORECASE)


target_aliases = [
    ("^t (.*)$", "target", lambda m: target(m[0])),
]
c.add_aliases("target", target_aliases)


re_party_target = re.compile(r"Target[: ]+(\w+)\.")
def gmcp_party_target(gmcp_data):
    if gmcp_data["channel"] == "party":
        match = re_party_target.search(gmcp_data["text"])
        if match:
            party_target = match.groups()[0]
            if party_target in enemies:
                echo(f"PARTY TARGET: {party_target}")
                target(party_target)
            else:
                echo(f"{party_target} NOT AN ENEMY")
c.add_gmcp_handler("Comm.Channel.Text", gmcp_party_target)
예제 #12
0
c.add_after_current_chunk_process(summarize_afflictions)


def gained_aff(gmcp_data):
    new_aff = gmcp_data["name"]
    echo(f"Gained {new_aff}!")
    s.new_afflictions.add(new_aff)
    s.current_afflictions.add(new_aff)
    fighting(f"Affs: {' '.join(_summarize_afflictions())}")

    if new_aff in shield_affs:
        echo(f"{Fore.YELLOW}{Style.BRIGHT}#### Gained {new_aff} ####")
        echo(f"### May want to Shield ###{Style.RESET_ALL}")


c.add_gmcp_handler("Char.Afflictions.Add", gained_aff)

shield_affs = {
    "damagedrightleg",
    "damagedrightarm",
    "damagedleftleg",
    "damagedleftarm",
    "prone",
}


def cured_aff(gmcp_data):
    cured_affs = set(gmcp_data)
    echo(f"Cured {', '.join(cured_affs)}!")
    s.cured_afflictions.update(cured_affs)
    s.current_afflictions.difference_update(set(cured_affs))