Files
erqiwang_youle/client/js/01_SubGame/codes/net/handlers/MainHandler.js
T
joywayerandClaude Opus 5 8b2cfdaf27 二七王:前端删掉 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>
2026-08-27 21:31:20 +08:00

40 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
///////////////////////////////////////////////////////////////
////////// EQW_MainHandler: 选主(xuanzhu)///////////////////
///////////////////////////////////////////////////////////////
// 协议 §7:banker 庄家 / flower 主牌花色(1方块 2梅花 3红心 4黑桃) /
// step 阶段(=3 埋牌) / nextseat 控制权(=庄家,埋牌由庄家做) /
// countdown 埋牌倒计时 / cards 选主后自己手上的牌
//
// 【step 与 nextseat 只读包字段】曾经这里写死 step=3 且 turn.seat = aset.banker:
// 阶段与「埋牌 = 庄家」两条规则都被搬到了前端(前端红线「数据驱动、前端无对局状态机」)。
//
// 选主后正 2 / 正 7 升格、主花色普通牌并入主牌段(design §3),手牌需整体重排——
// 但【重排是渲染时的事】,由 core/CardOrder 现算,不在这里落地成状态。
//
// 投降(touxiang)没有成功推送:点投降后服务端直接结算,前端收到的是 jiesuan。
// 失败时才回一个同名的 touxiang 失败包,由 FailHandler 统一处理。
var EQW_MainHandler = EQW_MainHandler || {
handleXuanzhu: function (data) {
if (!data.hasOwnProperty('flower')) {
console.error('[EQW_MainHandler] xuanzhu 缺 flower,已跳过该包');
return;
}
EQW_GameState._apply(EQW_GameState.aset, data, {
banker: 'banker',
flower: 'flower',
step: 'step'
});
EQW_GameState._apply(EQW_GameState.my, data, { cards: 'cards' });
EQW_GameState._apply(EQW_GameState.turn, data, {
seat: 'nextseat',
countdown: 'countdown'
});
EventBus.emit(EQW_Events.EQW_MAIN_SET);
if (data.hasOwnProperty('cards')) { EventBus.emit(EQW_Events.EQW_HAND_CHANGED); }
EventBus.emit(EQW_Events.EQW_TURN_CHANGED);
}
};