Ejemplo n.º 1
0
def getStatus(state: State) -> str:
    s = ""
    hasCol4 = Place(4, 1) in state.places
    for y in range(0, 4):
        col1 = lines(state, Place(1, y + 1))
        col2 = lines(state, Place(2, y + 1))
        col3 = lines(state, Place(3, y + 1))
        col4 = lines(state, Place(4, y + 1))

        s += "{0} {1} {2} {3}\n".format(col4[0], col1[0], col2[0], col3[0])
        s += "{0} {1} {2} {3}\n".format(col4[1], col1[1], col2[1], col3[1])
    return s
Ejemplo n.º 2
0
def changeTargetPlace(placeRaw: str):
    global state
    placeList = placeRaw.split()
    place = Place(int(placeList[0]), int(placeList[1]))
    if place in state.places:
        target = reSub(r"^[+]", "", state.places[place].name)
        state = state._replace(target=target)
        tfeval("/trigger You are now target-healing {0}.".format(target))
Ejemplo n.º 3
0
def ginfo(s: str):
    global state
    # we'll want front row to be first, so this is done in a bit difficult way
    names = list()
    places = state.places
    for y in [1, 2, 3]:
        for x in [1, 2, 3]:
            place = Place(x, y)
            if place in places:
                names.append(places[place].name)
    for place in UNKNOWN_PLACES:
        if place in places:
            names.append(places[place].name)
    tfeval("/python_call ginfo.partyReport {0}".format(" ".join(names)))
Ejemplo n.º 4
0
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,
    )
Ejemplo n.º 5
0
def pssJsonToMember(j) -> Member:
    unc = 0
    if j["state"] == "unc":
        unc = 1
    elif j["state"][:4] == "unc|":
        unc = int(j["state"][-1:]) + 2

    stu = 0
    if j["state"] == "stu":
        stu = 1
    elif j["state"][:4] == "stu|":
        stu = int(j["state"][-1:])

    return Member(
        j["name"],
        j["hp"],
        j["maxhp"],
        j["sp"],
        j["maxsp"],
        j["ep"],
        j["maxep"],
        Place(j["x"], j["y"]),
        j["state"] == "form",
        j["state"] == "mbr",
        j["state"] == "ent",
        j["state"] == "fol",
        j["state"] == "ldr",
        j["state"] == "ld",
        j["state"] == "rest",
        j["idle"],
        j["name"] == "Someone",
        j["state"] == "dead",
        stu,
        unc,
        j["state"][:3] == "amb",
        time(),
        MemberDataSource.PSS,
    )
Ejemplo n.º 6
0
        None,
        time(),
        MemberDataSource.BCPROXY,
    )


def getMemberByName(name: str) -> Optional[Member]:
    global state
    for member in state.members:
        if member.name == name:
            return member
    return None


UNKNOWN_PLACES: Sequence[Place] = [
    Place(1, 4),
    Place(2, 4),
    Place(3, 4),
    Place(4, 4),
    Place(4, 1),
    Place(4, 2),
    Place(4, 3),
]

#: batclient messages will have out-of-formation places as 6,1 or something
VALID_PLACES: FrozenSet[Place] = frozenset([
    Place(1, 1),
    Place(1, 2),
    Place(1, 3),
    Place(2, 1),
    Place(2, 2),