コード例 #1
0
def add_player(gmcp_data):
    # {"name": "Adrik", "fullname": "Adrik Bergson, the Crystalline Song"}
    player = gmcp_data["name"]
    echo(f"+{player}")
    fighting(f"+{player}")
    s.players_in_room = (*s.players_in_room, player)
    update_frenemies()
コード例 #2
0
ファイル: balances.py プロジェクト: theophilus8402/mud_client
def set_display_balance_timer(matches):
    if matches == "on":
        echo("Turning on balance timer!")
        s.show_balance_times = True
    elif matches == "off":
        echo("Turning on balance timer!")
        s.show_balance_times = False
コード例 #3
0
ファイル: timers.py プロジェクト: theophilus8402/mud_client
    async def create_simple_timer(self, name, action, wait_time):

        await asyncio.sleep(wait_time)
        action()

        # once the action is done, remove it from the timers dict
        echo(f"removing {name}!")
        del self.timers[name]
コード例 #4
0
ファイル: generic.py プロジェクト: theophilus8402/mud_client
def someone_stopped_rebounding(matches):
    highlight_current_line(Fore.YELLOW)
    if matches[0].lower() == s.target.lower():
        echo("TARGET STOPPED REBOUNDING!!")
        echo("TARGET STOPPED REBOUNDING!!")
        fighting(f"{s.target} STOPPED REBOUNDING!!")
    else:
        fighting(f"{matches[0]} stopped rebounding!!")
コード例 #5
0
ファイル: generic.py プロジェクト: theophilus8402/mud_client
def someone_shielded(matches):
    highlight_current_line(Fore.YELLOW)
    if matches[0].lower() == s.target.lower():
        echo("TARGET SHIELDED!!")
        echo("TARGET SHIELDED!!")
        fighting(f"{s.target} SHIELDED!!")
    else:
        fighting(f"{matches[0]} shielded!!")
コード例 #6
0
def room_players(gmcp_data):
    # [{"name": "Vhaith", "fullname": "Shield Curator Vhaith Rian-Moonshadow"}, {"name": "Vindiconis", "fullname": "Volunteer Vindiconis"}]
    me = {"Vindiconis", "Dirus", "Palleo", "Sarmenti", "Veredus"}
    players = {player["name"] for player in gmcp_data}
    players.difference_update(me)
    echo(f"+{', '.join(players)}")
    s.players_in_room = tuple(players)
    update_frenemies()
コード例 #7
0
def get_mob_id(gmcp_data):
    #'106482': {'id': '106482', 'name': 'a young rat', 'icon': 'animal', 'attrib': 'm'}
    long_name = gmcp_data["name"]
    mob_id = gmcp_data["id"]
    if long_name not in long_short_name_map:
        echo(f"didn't find: {long_name}")
    short_name = long_short_name_map.get(long_name, "")
    return short_name, f"{short_name}{mob_id}"
コード例 #8
0
ファイル: defences.py プロジェクト: theophilus8402/mud_client
def auto_defences(defs, state):
    if state == "on":
        for defence in defs:
            echo(f"Auto {defence} on!!!")
            send(f"CURING PRIORITY DEFENCE {defence} 25")
    elif state == "off":
        for defence in defs:
            echo(f"Auto {defence} off!!!")
            send(f"CURING PRIORITY DEFENCE {defence} reset")
コード例 #9
0
ファイル: druid.py プロジェクト: theophilus8402/mud_client
def being_grove_summoned(matches):
    highlight_current_line(Fore.RED)

    if matches:
        echo(f"{matches[0].upper()} IS BEING GROVE SUMMONED!!!!")
        fighting(f"{matches[0].upper()} IS BEING GROVE SUMMONED!!")
    else:
        echo("YOU'RE BEING GROVE SUMMONED!!!! SHIELD!!!")
        fighting(f"YOU'RE BEING GROVE SUMMONED!! SHIELD!!!")
コード例 #10
0
ファイル: target.py プロジェクト: theophilus8402/mud_client
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")
コード例 #11
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}")
コード例 #12
0
ファイル: defences.py プロジェクト: theophilus8402/mud_client
def fighting_defences(matches):
    if matches == "on":
        echo("Adding fighting defences!!")
        s.wanted_defences = add_wanted_defences(s.wanted_defences, fighting_defs)
        for fdef in fighting_defs:
            set_defence(fdef, 25, state=s)
    elif matches == "off":
        echo("Removing fighting defences!!")
        s.wanted_defences = remove_wanted_defences(s.wanted_defences, fighting_defs)
        for fdef in fighting_defs:
            set_defence(fdef, 0, state=s)
コード例 #13
0
def remove_player(gmcp_data):
    # "Farrah"
    echo(f"-{gmcp_data}")
    fighting(f"-{gmcp_data}")
    players = set(s.players_in_room)
    players.discard(gmcp_data)
    if players:
        s.players_in_room = tuple(players)
    else:
        s.players_in_room = tuple()
    update_frenemies()
コード例 #14
0
def update_name_map(long_name, matches):
    short_name = matches[0]
    if long_name in long_short_name_map:
        old_short_name = long_short_name_map[long_name]
        if old_short_name != short_name:
            echo(
                f"name_map conflict: {long_name} => {short_name} / {old_short_name}"
            )
    else:
        echo(f"Adding: {long_name} -> {short_name}")
        long_short_name_map[long_name] = short_name
        save_name_map(DEFAULT_NAME_MAP_PATH)
コード例 #15
0
ファイル: timers.py プロジェクト: theophilus8402/mud_client
    async def create_recurring_timer(self, name, action, wait_time):

        try:
            while True:
                await asyncio.sleep(wait_time)
                action()
        except:
            pass
        finally:
            echo(f"removing {name}!")
            # once the action is done, remove it from the timers dict
            del self.timers[name]
コード例 #16
0
def parse_number_attack(matches):

    if matches[2] == None:
        strike_type_num = int(matches[0])
        limb_num = 7
        golem_attack_num = int(matches[1])
    else:
        strike_type_num = int(matches[0])
        limb_num = int(matches[1])
        golem_attack_num = int(matches[2])

    if strike_type_num not in strike_map:
        echo("Not a valid strike num!")
        return
    if limb_num not in limb_map:
        echo("Not a valid limb num!")
        return
    if golem_attack_num not in golem_map:
        echo("Not a valid golem num!")
        return

    strike_attack = strike_map[strike_type_num]
    limb = limb_map[limb_num]
    golem_attack = golem_map[golem_attack_num]

    attack = f"stand;{strike_attack}{limb};{golem_attack}".format(target=s.target)
    echo(attack)
    send(attack)
コード例 #17
0
def store_room(gmcp_data):
    room_num = gmcp_data["num"]
    if not room_in_db(room_num):
        echo(f"Egads!  {room_num} hasn't been stored!  Adding it now!")
        # echo(f"{gmcp_data}")
        room_info = copy(gmcp_data)
        room_info["details"] = str(gmcp_data["details"])
        room_info["exits"] = str(gmcp_data["exits"])
        try:
            room = RoomInfo(**room_info)
            session.add(room)
            session.commit()
        except:
            echo("eep!  Something is happening")
コード例 #18
0
ファイル: bleeding.py プロジェクト: theophilus8402/mud_client
def stop_bleeding(matches):
    amt = int(matches[0])
    clots = []
    if (amt >= 50) and (s.mp >= 3800):
        clots.append("clot")
    if (amt >= 100) and (s.mp >= 3700):
        clots.append("clot")
    if (amt >= 200) and (s.mp >= 3600):
        clots.append("clot")
    if (amt >= 300) and (s.mp >= 3500):
        clots.append("clot")
    if (amt >= 400) and (s.mp >= 3400):
        clots.append("clot")
    if clots:
        echo(f"Clotting {len(clots)}x!")
        send(";".join(clots))
コード例 #19
0
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}")
コード例 #20
0
def reject_lust(luster):
    echo(f"{luster} LUSTED YOU!!! REJECT {luster}")
    timers.add(
        f"reject_{luster}1",
        lambda luster: echo(f"{luster} LUSTED YOU!!! REJECT {luster}"),
        1,
    )
    timers.add(
        f"reject_{luster}2",
        lambda luster: echo(f"{luster} LUSTED YOU!!! REJECT {luster}"),
        3,
    )
    timers.add(
        f"reject_{luster}3",
        lambda luster: echo(f"{luster} LUSTED YOU!!! REJECT {luster}"),
        6,
    )
コード例 #21
0
def parse_map(current_line):
    if current_line.count(":") != 1:
        # probably not the beginning line
        return

    start_index = 0
    chunk_lines = c.current_chunk.split("\n")
    for i, line in enumerate(chunk_lines):
        if line == current_line:
            start_index = i
            end_index = start_index
            stuff = chunk_lines[i:i + 5]
        elif (line.count(":") >= 2) and (line.count("-") >= 6):
            end_index = i
            break

    stuff = chunk_lines[start_index:end_index + 1]
    c.delete_lines(stuff)
    echo("\n".join(stuff))
コード例 #22
0
def figure_out_unknown_mobs(mobs):
    trigger_names = []
    echo(f"trying to figure out: {mobs}")
    for mob_id, long_name in mobs:

        trigger_name = f"mob_id{mob_id}"
        trigger_names.append(trigger_name)
        echo(f"creating trig for: {mob_id} / {long_name}")

        update_func = partial(update_name_map, long_name)
        mob_trigger = (fr"^(.+){mob_id}\s+{long_name}$", update_func)
        c.add_temp_trigger(trigger_name, mob_trigger)

    send("ih")
    trigger_names.append("info_here")
    info_here_trigger = (
        fr"^Number of objects: \d+$",
        lambda m: [c.remove_temp_trigger(tn) for tn in trigger_names],
    )
    c.add_temp_trigger("info_here", info_here_trigger)
コード例 #23
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")
コード例 #24
0
ファイル: portal.py プロジェクト: theophilus8402/mud_client
def incoming_portal(portal_type):
    echo(
        f"### Incoming Portal!!! {portal_type.upper()} Check for a mono in the room! ###"
    )
    if monolith_in_room() == True:
        echo("Phew!  There's a monolith in the room!")
    else:
        echo("Panic!  There's no monolith in the room!")
コード例 #25
0
def find_mobs_in_room(gmcp_data):
    # Char.Items.List {"location": "room", "items": [{"id": "113519", "name": "a runic totem", "icon": "rune"}, {"id": "293949", "name": "Jodri, Shepherd of the Devout", "icon": "humanoid", "attrib": "m"}, {"id": "544262", "name": "a monolith sigil", "icon": "rune", "attrib": "t"}]}
    # echo(gmcp_data)

    # make sure we're getting room info
    if gmcp_data["location"] != "room":
        return False

    # find all the mobs
    try:
        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)
コード例 #26
0
ファイル: path.py プロジェクト: theophilus8402/mud_client
    def update(self, room_info):
        try:
            if self.last_room.num != room_info.num:
                echo(f"PathRecorder({id(self)}): new room ({room_info.num})")

                # find the exit used pertaining to the new room
                for direction, room_num in self.last_room.exits.items():
                    if room_num == room_info.num:
                        echo(f"adding ({direction}, {room_num}) to path")
                        self.path.append((direction, room_num))
                        break
                self.last_room = room_info

                echo(f"path: {self.path}")
        except AttributeError as e:
            echo(f"PathRecorder: probably haven't seen a last_room yet")
            self.last_room = room_info
コード例 #27
0
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}")
コード例 #28
0
def count_strike(matches):
    echo("Calling count_strike")
    strike_type = strike_map[matches[0]]
    person_hit = matches[1]
    limb = matches[2]
    echo(f"{strike_type} strike to {person_hit}'s {limb}")

    # need to check to see if I rebounded!
    # echo(f"current_chunk: '{c.current_chunk}'")
    if "The attack rebounds back onto you!" in c.current_chunk:
        echo("You fool!  You rebounded!")
コード例 #29
0
def stormhammer(matches):
    echo(matches)
    try:
        if matches is None:
            peeps = s.target
        else:
            peeps = " and ".join([s.target, *matches.split(" ")])
        echo(peeps)
        eqbal(f"stand;cast stormhammer at {peeps}")
    except Exception as e:
        echo(f"stormhammer: {e}")
コード例 #30
0
ファイル: balances.py プロジェクト: theophilus8402/mud_client
 def tmp_trig(matches):
     total = time.time() - start_time
     echo(f"{timer_type}: {total:0.2}s")
     c.remove_temp_trigger(timer_type)