def pssParse(opts): global state d = loadJson(opts) d["idle"] = d["idle"] == "*" d["x"] = strtoi(d["x"]) d["y"] = strtoi(d["y"]) d["name"] = d["name"].strip() d["hp"] = strtoi(d["hp"]) d["maxhp"] = strtoi(d["maxhp"]) d["sp"] = strtoi(d["sp"]) d["maxsp"] = strtoi(d["maxsp"]) d["ep"] = strtoi(d["ep"]) d["maxep"] = strtoi(d["maxep"]) d["spepstring"] = d["spepstring"].strip() # get nergal minions sp and ep strings if d["sp"] == None and d["spepstring"] != "": spep = d["spepstring"].split(" ") d["sp"] = spepstringToInt(spep[0].strip()) d["ep"] = spepstringToInt(spep[-1].strip()) d["maxsp"] = 100 d["maxep"] = 100 newMember = pssJsonToMember(d) if newMember.name[:1] == "+" or state.manualMinions: state = state._replace(pssHasMinions=True) # leave invis to be handled by batclient messages if newMember.name != "Someone": handleNewMember(newMember)
def parseMessage(message) -> Member: """ Parse incoming party update message :param message: message as a string with fields separated by spaces :returns: dictionary with fields and their respective values boolean and number fields are converted to respective python data types """ d = dict(zip(PARTY_STATUS_UPDATE_FIELDS, message.split(" "))) x = strtoi(d["place_x"]) y = strtoi(d["place_y"]) place = None if x == None or y == None else Place(cast(int, x), cast( int, y)) return Member( str(d["player"]), int(d["hp"]), int(d["maxhp"]), int(d["sp"]), int(d["maxsp"]), int(d["ep"]), int(d["maxep"]), place, bool(d["formation"] == "1"), bool(d["member"] == "1"), bool(d["entry"] == "1"), bool(d["following"] == "1"), bool(d["leader"] == "1"), bool(d["linkdead"] == "1"), bool(d["resting"] == "1"), bool(d["idle"] == "1"), bool(d["invisible"] == "1"), bool(d["dead"] == "1"), int(d["stunned"]), int(d["unconscious"]), None, time(), MemberDataSource.BCPROXY, )
def guild(s: str): global state mage = MAGE.match(s) guildWithLevels = GUILD_WITH_LEVELS.match(s) if mage and mage.group("subguilds") != "10/10": state.guilds.add(PlayerGuild("Mage", 10, 10)) for typeStr in mage.group("subguilds").split(", "): type = MAGE_TYPES.match(typeStr) if type: lvl = (strtoi(type.group("lvl")) if type.group("lvl") is not None else None) state.guilds.add(PlayerGuild(type.group("type"), lvl, 10)) elif guildWithLevels: lvl2 = guildWithLevels.group("lvl") maxlvl = guildWithLevels.group("maxlvl") state.guilds.add( PlayerGuild( guildWithLevels.group("guild"), strtoi(lvl2), strtoi(maxlvl) if maxlvl is not None else None, )) else: state.guilds.add(PlayerGuild(s, None, None))