二七王:前端删掉 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:
@@ -14,37 +14,45 @@ Object.keys(EQW_Events).forEach(k => EventBus.on(EQW_Events[k], () => evts.push(
|
||||
|
||||
// ================= xuanzhu =================
|
||||
S.reset(); evts.length = 0;
|
||||
EQW_MainHandler.handleXuanzhu({ success: true, banker: 1, flower: 3,
|
||||
EQW_MainHandler.handleXuanzhu({ success: true, banker: 1, flower: 3, step: 3, nextseat: 1,
|
||||
countdown: 30, cards: [5, 6, 7] });
|
||||
t.eq('主牌花色', S.aset.flower, 3);
|
||||
t.eq('庄家', S.aset.banker, 1);
|
||||
t.eq('选主后手牌', S.my.cards, [5, 6, 7]);
|
||||
t.eq('step 置为埋牌', S.aset.step, 3);
|
||||
t.eq('控制权归庄家', S.turn.seat, 1);
|
||||
t.eq('step 读包字段(埋牌=3)', S.aset.step, 3);
|
||||
t.eq('控制权读包里的 nextseat', S.turn.seat, 1);
|
||||
t.eq('倒计时', S.turn.countdown, 30);
|
||||
t.eq('选主发事件',
|
||||
['EQW_MAIN_SET','EQW_HAND_CHANGED'].every(e => evts.indexOf(e) >= 0), true);
|
||||
|
||||
// 闲家视角:没有 cards,不抹已有手牌
|
||||
S.reset(); S.my.cards = [1, 2];
|
||||
EQW_MainHandler.handleXuanzhu({ success: true, banker: 0, flower: 2, countdown: 30 });
|
||||
EQW_MainHandler.handleXuanzhu({ success: true, banker: 0, flower: 2, step: 3, nextseat: 0, countdown: 30 });
|
||||
t.eq('闲家手牌不被抹', S.my.cards, [1, 2]);
|
||||
t.eq('闲家也拿到花色', S.aset.flower, 2);
|
||||
|
||||
// 【守卫】阶段与控制权都必须来自包,不得按 rpc 名硬编码、也不得用本地 banker 反推。
|
||||
// 真实链路里 nextseat 恒 == banker,相等时"读哪个"分辨不出来;这里刻意让它们不同,
|
||||
// 退回 `aset.step = 3` / `turn.seat = aset.banker` 的写法必转红。
|
||||
S.reset();
|
||||
EQW_MainHandler.handleXuanzhu({ success: true, banker: 0, flower: 2, step: 4, nextseat: 2, countdown: 30 });
|
||||
t.eq('xuanzhu step 照读包字段', S.aset.step, 4);
|
||||
t.eq('xuanzhu 控制权取 nextseat,不取 banker', S.turn.seat, 2);
|
||||
|
||||
// ================= maipai =================
|
||||
S.reset(); evts.length = 0;
|
||||
EQW_BuryHandler.handle({ success: true, cards: [1,2,3], burycards: [9,10,11,12,13,14,15,16],
|
||||
seat: 1, countdown: 20 });
|
||||
step: 5, seat: 1, countdown: 20 });
|
||||
t.eq('埋牌后手牌', S.my.cards, [1,2,3]);
|
||||
t.eq('埋牌底牌', S.my.buryCards, [9,10,11,12,13,14,15,16]);
|
||||
t.eq('step 置为出牌', S.aset.step, 5);
|
||||
t.eq('首出者', S.turn.seat, 1);
|
||||
t.eq('step 读包字段(出牌=5)', S.aset.step, 5);
|
||||
t.eq('首出者(控制权读包里的 seat)', S.turn.seat, 1);
|
||||
t.eq('埋牌发事件',
|
||||
['EQW_BURY_DONE','EQW_HAND_CHANGED','EQW_TURN_CHANGED'].every(e => evts.indexOf(e) >= 0), true);
|
||||
|
||||
// 闲家视角:无 cards/burycards,但可能有 liangpai
|
||||
S.reset(); S.my.cards = [4, 5]; evts.length = 0;
|
||||
EQW_BuryHandler.handle({ success: true, seat: 0, countdown: 20,
|
||||
EQW_BuryHandler.handle({ success: true, step: 5, seat: 0, countdown: 20,
|
||||
liangpai: { cards: [52, 53, 2, 15] } });
|
||||
t.eq('闲家手牌不被抹', S.my.cards, [4, 5]);
|
||||
t.eq('闲家无埋牌底牌', S.my.buryCards, []);
|
||||
@@ -52,14 +60,19 @@ t.eq('亮牌数据', S.table.liangpai, { cards: [52, 53, 2, 15] });
|
||||
|
||||
// 不达标/不查牌:无 liangpai 字段,保持 null
|
||||
S.reset();
|
||||
EQW_BuryHandler.handle({ success: true, seat: 0, countdown: 20 });
|
||||
EQW_BuryHandler.handle({ success: true, step: 5, seat: 0, countdown: 20 });
|
||||
t.eq('无亮牌时保持 null', S.table.liangpai, null);
|
||||
|
||||
// 【守卫】maipai 的 step 同样只读包字段
|
||||
S.reset();
|
||||
EQW_BuryHandler.handle({ success: true, step: 4, seat: 0, countdown: 20 });
|
||||
t.eq('maipai step 照读包字段(不按 rpc 名硬编码)', S.aset.step, 4);
|
||||
|
||||
// playproc:埋牌完成时服务端已就地开好 round-1 的进行态,恒有、原样拷贝进 table.playproc,
|
||||
// 与 chupai1/2/3.playproc 同源同结构(协议 §9),漏接会让「埋牌完成→庄家首出」这段窗口
|
||||
// 增量路径 table.playproc 停在上一阶段的 null、与重连路径不一致
|
||||
S.reset();
|
||||
EQW_BuryHandler.handle({ success: true, seat: 0, countdown: 20, cards: [1, 2, 3],
|
||||
EQW_BuryHandler.handle({ success: true, step: 5, seat: 0, countdown: 20, cards: [1, 2, 3],
|
||||
burycards: [9, 10, 11, 12, 13, 14, 15, 16],
|
||||
playproc: { round: 1, start: 0, currseat: 0, startcount: -1,
|
||||
startflower: -1, starttype: -1, maxseat: -1, maxcard: -1,
|
||||
|
||||
Reference in New Issue
Block a user