예제 #1
0
def optionsRequest(data: Data) -> dict:
    args = {"target": data.take(), "message": data.takeString()}

    count = data.take()
    args["options"] = [None] * count

    for i in range(count):
        args["options"][i] = data.takeString()

    return args
예제 #2
0
def numberRequest(data: Data) -> dict:
    return {
        "target": data.take(),
        "question": data.takeString(),
        "min": data.take(),
        "max": data.take()
    }
예제 #3
0
def atk(data: Data) -> dict:
    args = {"playersId": data.take(), "enemiesName": data.takeString()}
    dmg = data.takeNumeric(4, signed=True)

    args["attacker"] = Attacker.Player if dmg >= 0 else Attacker.Enemy
    args["dmg"] = abs(dmg)

    return args
예제 #4
0
def members(data: Data) -> dict:
    count = data.take()

    args = {"members": {}}
    for i in range(count):
        id = data.take()
        args["members"][id] = (data.takeString(), data.takeBool())

    return args
예제 #5
0
def globalStat(data: Data) -> dict:
    args = {
        "name": data.takeString(),
        "hidden": data.takeBool(),
        "main": data.takeBool()
    }

    if not args["hidden"]:
        for arg in ["min", "max", "value"]:
            args[arg] = data.takeNumeric(4, signed=True)

    return args
예제 #6
0
def diceRollRequest(data: Data) -> dict:
    args = {
        "target": data.take(),
        "message": data.takeString(),
        "dices": data.take(),
        "bonus": data.takeNumeric(4, signed=True),
        "results": {}
    }

    count = data.take()
    dices = args["dices"]

    for i in range(count):
        id = data.take()
        args["results"][id] = [None] * dices

        for dice in range(dices):
            args["results"][id][dice] = data.take()

    return args
예제 #7
0
def playerUpdate(data: Data) -> dict:
    return {"id": data.take(), "update": json.loads(data.takeString())}
예제 #8
0
def text(data: Data) -> dict:
    return {"text": data.takeString()}
예제 #9
0
def yesNoRequest(data: Data) -> dict:
    return {"target": data.take(), "question": data.takeString()}
예제 #10
0
def idAndName(data: Data) -> dict:
    return {"id": data.take(), "name": data.takeString()}
예제 #11
0
def name(data: Data) -> dict:
    return {"name": data.takeString()}
예제 #12
0
def enemiesGroup(data: Data) -> dict:
    return {"group": json.loads(data.takeString())}