feat(match): 添加画面上下镜像、跳过准备和装甲板整局复位

This commit is contained in:
sloray committed 2026-10-31 09:27:26 +08:00
1 parent 235fb1c73b
commit 338efa5c2e
39 files changed
+1094 -54

No files matched your search

+19
View File
@@ -39,6 +39,7 @@ MSG_ARMOR_HEALTH = 5 # MsgType::ArmorHealth
MSG_ARMOR_CONTROL = 6
MSG_MATCH_STATE = 7 # 比赛计时广播;装甲板探测器忽略
MSG_ARMOR_DAMAGE_CONTROL = 8 # 扣血许可;装甲板探测器忽略
MSG_ARMOR_RESET = 9 # 复位与回执;探测器只解析,不发送
PROTOCOL_VERSION = 1
TEAM_NAMES = {0: "队伍一", 1: "队伍二", 255: "待分配队伍"}
@@ -66,6 +67,24 @@ def decode_damage_control(data):
return (board, session, sequence, bool(data[47])) if board and session and sequence else None
def decode_reset(data):
"""独立核对复位及回执的 56 字节格式,不向设备发送复位。"""
if len(data) != HEADER + 29 or int.from_bytes(data[:4], "little") != MAGIC:
return None
if data[4] != MSG_ARMOR_RESET or int.from_bytes(data[5:7], "little") != PROTOCOL_VERSION or data[-1] not in (0, 1):
return None
board = int.from_bytes(data[27:31], "little")
session = int.from_bytes(data[31:39], "little")
sequence = int.from_bytes(data[39:47], "little")
reset_id = int.from_bytes(data[47:55], "little")
acknowledged = bool(data[55])
if not board or not session or not 0 < reset_id <= sequence:
return None
if int.from_bytes(data[7:11], "little") != (board if acknowledged else 0):
return None
return board, session, sequence, reset_id, acknowledged
def decode(data):
"""解析一个数据报,返回 (team, index, hp, sender_id, version) 或 None。"""
if len(data) < HEADER + 4: