def numberRequest(data: Data) -> dict: return { "target": data.take(), "question": data.takeString(), "min": data.take(), "max": data.take() }
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
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
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
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
def playerUpdate(data: Data) -> dict: return {"id": data.take(), "update": json.loads(data.takeString())}
def yesNoRequest(data: Data) -> dict: return {"target": data.take(), "question": data.takeString()}
def confirmRequest(data: Data) -> dict: return {"target": data.take()}
def ids(data: Data) -> dict: count = data.take() return {"ids": [data.take() for i in range(count)]}
def yesNoQuestion(data: Data) -> dict: return {"question": YesNoQuestion(data.take())}
def idAndName(data: Data) -> dict: return {"id": data.take(), "name": data.takeString()}
def id(data: Data) -> dict: return {"id": data.take()}
def reply(data: Data) -> dict: return {"id": data.take(), "reply": data.take()}