二七王:result.chupai 移出 GameState,本墩结果改走 EQW_TRICK_END 事件载荷
谁最大、这墩闲家得几分是【一次性表现】(收牌动画、得分飘字),任何 deskinfo 都不下发它,
写进 GameState 就多出一处「只活在前端、服务端不知道」的对局态——出牌中途断线重连即归零,
违反红线「丢弃 this.data、仅凭最近一次服务端快照重画,界面必须一致」。
三处一起改,缺一不可:
- PlayHandler chupai3:删 result.chupai 写入,改随 EQW_TRICK_END 下发 {seat,cards,maxseat?,grade?};
aset.grade 的累加保留(它有服务端来源 PushCards.grade / chupai3.grade,是镜像量)
- ResultHandler:_apply 的 map 删掉 chupai。收尾墩不发 chupai3、整包换成 jiesuan,
不改这里则删 EXCLUDE 后必转红。收尾墩改为与 chupai3 走同一对事件、同一份载荷字段
(补 emit EQW_TRICK_END 并带上 grade),否则最后一墩的得分没有出口
- GameState:删掉 result.chupai 字段本身(声明 + reset),不留永远为 null 的死字段
test_consistency 的 EXCLUDE 随之删到只剩 table.ancard3s 一条,27 checks 仍全绿;
该条改注释标明「当前夹具(65 分坐庄、单局)无法触发,此条未经验证」,不假装它在守什么。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,13 +23,15 @@ const fx = JSON.parse(fs.readFileSync(path.join(ROOT, 'client/tests/fixtures/pac
|
||||
|
||||
// 这些字段是「一次性事件」或「重连不重放」的,不参与一致性比对。
|
||||
// 每加一条都必须写清理由——这个白名单是本测试唯一的松口处,滥用它等于废掉这条守卫。
|
||||
//
|
||||
// 【清单历史】result.bottom / result.account 已随服务端 Balance 补发而删除;
|
||||
// result.chupai 已随「本墩结果改走 EQW_TRICK_END 事件载荷、不进 GameState」而删除。
|
||||
// 现在只剩下面这一条。
|
||||
const EXCLUDE = [
|
||||
// 70 分坐庄的 3 秒开底是上庄时的一次性事件,协议明确 deskinfo 不重放
|
||||
'table.ancard3s',
|
||||
// 收尾墩:牌局最后一手不发 chupai3,整包换成 jiesuan,其 data.chupai 由 ResultHandler
|
||||
// 归档进 result.chupai;deskinfo 的 Balance 不带这一墩(它属于「出牌过程」而非结算数据)。
|
||||
// 【本条是本清单仅剩的松口处】result.bottom / result.account 已随服务端 Balance 补发而移除。
|
||||
'result.chupai'
|
||||
// 70 分坐庄的 3 秒开底是上庄时的一次性事件,协议明确 deskinfo 不重放。
|
||||
// ⚠️ 当前夹具无法触发(65 分坐庄、单局),此条未经验证——保留是因为删掉之后
|
||||
// 将来真出现不一致会静默通过;但它此刻并没有在守住任何东西,不要当成已验证的豁免。
|
||||
'table.ancard3s'
|
||||
];
|
||||
|
||||
function pick(snap, exclude) {
|
||||
|
||||
@@ -47,22 +47,27 @@ t.eq('无 mustcard 时清空', S.my.mustCard, []);
|
||||
// ================= chupai3(末家出牌,本轮结束)=================
|
||||
// 真实的 chupai3 也带 nextseat(下一轮首家):服务端在 switch 前统一设置,
|
||||
// 只有整轮结束进入结算时才会整体换成 jiesuan rpc(不会以 chupai3 到达 handler)
|
||||
// 本墩结果(谁最大 / 这墩得几分)是一次性表现,走 EQW_TRICK_END 事件载荷,【不进 GameState】——
|
||||
// 任何 deskinfo 都不下发它,存进来就是一处服务端不知道的私有对局态(出牌中途重连即归零)
|
||||
S.reset(); evts.length = 0;
|
||||
let lastTrick = null;
|
||||
EventBus.on(EQW_Events.EQW_TRICK_END, function (p) { lastTrick = p; });
|
||||
EQW_PlayHandler.handle({ success: true, seat: 2, cards: [9,10], maxseat: 0, grade: 25,
|
||||
nextseat: 0, countdown: 15, baozhu: 1, curmultiple: -2 }, 3);
|
||||
t.eq('本轮最大者', S.result.chupai.maxseat, 0);
|
||||
t.eq('本轮闲家得分', S.result.chupai.grade, 25);
|
||||
t.eq('本墩结果走事件载荷', lastTrick, { seat: 2, cards: [9,10], maxseat: 0, grade: 25 });
|
||||
t.eq('本墩结果不进 GameState', S.result.hasOwnProperty('chupai'), false);
|
||||
t.eq('累计捡分', S.aset.grade, 25);
|
||||
t.eq('报无主标志', S.aset.baozhu, 1);
|
||||
t.eq('抓分倍数(带符号)', S.aset.curmultiple, -2);
|
||||
t.eq('下一轮首家', S.turn.seat, 0);
|
||||
t.eq('本轮结束发事件', evts.indexOf('EQW_TRICK_END') >= 0, true);
|
||||
|
||||
// 本轮闲家没得分时不带 grade,累计分不该被抹
|
||||
S.reset(); S.aset.grade = 40;
|
||||
// 本轮闲家没得分时不带 grade,累计分不该被抹;事件载荷也不得凭空补 grade(缺字段不兜底)
|
||||
S.reset(); S.aset.grade = 40; lastTrick = null;
|
||||
EQW_PlayHandler.handle({ success: true, seat: 2, cards: [9,10], maxseat: 1,
|
||||
nextseat: 1, countdown: 15 }, 3);
|
||||
t.eq('无 grade 时累计分保持', S.aset.grade, 40);
|
||||
t.eq('无 grade 时事件载荷不带该键', lastTrick.hasOwnProperty('grade'), false);
|
||||
t.eq('无 grade 时仍推进控制权', S.turn.seat, 1);
|
||||
|
||||
// grade 是「本轮」得分,要跨包累加进小局捡分,不是赋值——
|
||||
|
||||
@@ -10,13 +10,15 @@ load('client/js/01_SubGame/codes/net/handlers/ResultHandler.js');
|
||||
const S = EQW_GameState;
|
||||
const evts = [];
|
||||
Object.keys(EQW_Events).forEach(k => EventBus.on(EQW_Events[k], () => evts.push(k)));
|
||||
let lastTrick = null;
|
||||
EventBus.on(EQW_Events.EQW_TRICK_END, p => { lastTrick = p; });
|
||||
|
||||
const ASET = { banker: 0, call: 60, multiple: 3, flower: 3, grade: 45, upgrade: 1,
|
||||
bangwang: 0, climb: 0,
|
||||
seatlist: [{ grade: 6, score: 6 }, { grade: -3, score: -3 }, { grade: -3, score: -3 }] };
|
||||
|
||||
// ================= 正常出牌结算 =================
|
||||
S.reset(); evts.length = 0;
|
||||
S.reset(); evts.length = 0; lastTrick = null;
|
||||
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 },
|
||||
@@ -24,17 +26,21 @@ EQW_ResultHandler.handleJiesuan({ success: true, step: 6,
|
||||
|
||||
t.eq('小局结算入状态', S.result.aset, ASET);
|
||||
t.eq('抠底入状态', S.result.bottom.grade2, 40);
|
||||
t.eq('最后一手入状态', S.result.chupai.maxseat, 0);
|
||||
// 收尾墩(服务端不发 chupai3,整包换成 jiesuan)走事件载荷,与 chupai3 同一对事件、同一份字段;
|
||||
// 【不进 GameState】——deskinfo step6 的 Balance 只有 aset/bottom/account,多存就是私有对局态
|
||||
t.eq('收尾墩走事件载荷', lastTrick, { seat: 2, cards: [9], maxseat: 0, grade: 10 });
|
||||
t.eq('收尾墩也发本墩结束事件', evts.indexOf('EQW_TRICK_END') >= 0, true);
|
||||
t.eq('收尾墩不进 GameState', S.result.hasOwnProperty('chupai'), false);
|
||||
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;
|
||||
S.reset(); evts.length = 0; lastTrick = null;
|
||||
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);
|
||||
t.eq('投降无 chupai → 不发本墩结束事件', lastTrick, null);
|
||||
t.eq('投降无 bottom', S.result.bottom, null);
|
||||
t.eq('投降也发结算事件', evts.indexOf('EQW_ASET_RESULT') >= 0, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user