二七王:前端删掉 9 处阶段/控制权推导,一律读服务端包字段

I-3 前端不再持有对局状态机(配合服务端上一提交的下发面补齐):
- 删掉 5 处按 rpc 名硬编码的 aset.step(Deal=1 / Call=2 / Main=3 / Bury=5 / Result=6),
  一律改 _apply 读包里的 step
- 删掉 4 处 turn.seat = aset.banker(CallHandler / MainHandler / ResyncHandler×2),
  增量路径读 nextseat、重连路径读分组里的 seat;同一条规则不再有 4 个写入处

I-2 ResyncHandler._applyBalance 由只接 aset 扩为接 aset/bottom/account,
结算面板开着时重连/硬刷新不再丢抠底明细与末局大结算。
一致性测试 EXCLUDE 随之从 4 条收缩为 2 条(去掉 result.bottom / result.account,
只留一次性事件 table.ancard3s 与归下一轮的 result.chupai),未新增任何豁免条目。

夹具按新包结构重跑(种子不变,牌局不变):diff 纯为 67 行新增字段、0 行删除;
test_fixture 补上 step/nextseat/Balance 同源断言(68→82 checks)。
export_packets.js 里关于 playproc/seatlist 活引用的注释已过时,更正为仍存在的
Balance.readystate 与三份结算快照。

各 handler 单测补齐新字段并新增守卫用例:刻意构造 nextseat != banker、
step 为非预期值的包,使「退回硬编码/banker 反推」的写法必然转红(11/11 已验证)。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-27 21:31:20 +08:00
co-authored by Claude Opus 5
parent 5d981a722e
commit 8b2cfdaf27
14 changed files with 284 additions and 55 deletions
+12 -5
View File
@@ -17,7 +17,7 @@ const ASET = { banker: 0, call: 60, multiple: 3, flower: 3, grade: 45, upgrade:
// ================= 正常出牌结算 =================
S.reset(); evts.length = 0;
EQW_ResultHandler.handleJiesuan({ success: true,
EQW_ResultHandler.handleJiesuan({ success: true, step: 6,
chupai: { seat: 2, cards: [9], maxseat: 0, grade: 10 },
bottom: { cards: [1,2,3,4,5,6,7,8], multiple: 2, grade1: 20, grade2: 40 },
aset: ASET });
@@ -25,13 +25,13 @@ EQW_ResultHandler.handleJiesuan({ success: true,
t.eq('小局结算入状态', S.result.aset, ASET);
t.eq('抠底入状态', S.result.bottom.grade2, 40);
t.eq('最后一手入状态', S.result.chupai.maxseat, 0);
t.eq('step 置为结算', S.aset.step, 6);
t.eq('step 读包字段(结算=6)', S.aset.step, 6);
t.eq('结算发事件', evts.indexOf('EQW_ASET_RESULT') >= 0, true);
t.eq('非末局不发大局结算事件', evts.indexOf('EQW_ACCOUNT_RESULT') < 0, true);
// ================= 投降结算(无 chupai / 无 bottom)=================
S.reset(); evts.length = 0;
EQW_ResultHandler.handleJiesuan({ success: true, aset: { banker: 0, call: 70, multiple: 1,
EQW_ResultHandler.handleJiesuan({ success: true, step: 6, aset: { banker: 0, call: 70, multiple: 1,
upgrade: -99, seatlist: [] } });
t.eq('投降结算入状态', S.result.aset.upgrade, -99);
t.eq('投降无 chupai', S.result.chupai, null);
@@ -43,18 +43,25 @@ const ACCOUNT = [{ score: 12, grades: [6,6], grade_jf_total: 8, grade_cg_total:
{ score: -6, grades: [-3,-3], grade_jf_total: -4, grade_cg_total: -2, grade_bw_total: 0 },
{ score: -6, grades: [-3,-3], grade_jf_total: -4, grade_cg_total: -2, grade_bw_total: 0 }];
S.reset(); evts.length = 0;
EQW_ResultHandler.handleJiesuan({ success: true, aset: ASET, account: ACCOUNT });
EQW_ResultHandler.handleJiesuan({ success: true, step: 6, aset: ASET, account: ACCOUNT });
t.eq('大局结算入状态', S.result.account, ACCOUNT);
t.eq('末局发大局结算事件', evts.indexOf('EQW_ACCOUNT_RESULT') >= 0, true);
// ================= 解散:走 Free 入口,取值少一层 =================
S.reset(); evts.length = 0;
EQW_ResultHandler.handleFree({ rpc: 'jiesuan',
data: { success: true, aset: { banker: -1, call: -1, multiple: 0, upgrade: 0, seatlist: [] },
data: { success: true, step: 6, aset: { banker: -1, call: -1, multiple: 0, upgrade: 0, seatlist: [] },
account: ACCOUNT } });
t.eq('解散取到 aset', S.result.aset.multiple, 0);
t.eq('解散取到 account', S.result.account, ACCOUNT);
t.eq('解散发大局结算事件', evts.indexOf('EQW_ACCOUNT_RESULT') >= 0, true);
t.eq('解散包的 step 也读包字段', S.aset.step, 6);
// 【守卫】结算 step 只读包字段,不按 rpc 名硬编码为 6。
// 退回 `aset.step = 6` 的写法必转红。
S.reset();
EQW_ResultHandler.handleJiesuan({ success: true, step: 4, aset: ASET });
t.eq('jiesuan step 照读包字段', S.aset.step, 4);
// ================= 解散:deskfree 为 null(首局发牌前解散)=================
S.reset(); evts.length = 0;