/////////////////////////////////////////////////////////////// ////////// EQW_ResultHandler: 结算(jiesuan)与解散(Free)/// /////////////////////////////////////////////////////////////// // 协议 §14:结算包由 chupai + bottom + aset 拼装,末局再加 account。 // 三种来源的组成不同: // 正常出牌结算:chupai + bottom + aset(末局加 account) // 投降结算: 只有 aset(末局加 account),无 chupai、无 bottom // 解散结算: 只有 aset + account,且【走另一个入口】,见下 // // 【解散的特殊性】(协议 §14.1,已对平台代码核实): // 解散包的 route 是平台的 "room",平台 12_Logic.js 按 route 分流时把它交给 // Net[rpc] 而【不是】Game_Modify._ReceiveData——所以它根本进不了子游戏的分发表。 // 平台另有专门入口:07_Desk.js 的 Game_Modify.Free(Desk.deskfree)。 // 两个后果: // 1. 取值路径比协议文档少一层——平台已把 deskfree 取出来传进来, // 所以是 deskfree.data.aset,不是 data.deskfree.data.aset; // 2. 参数可能是 null——解散若发生在开战后、首局发牌前,服务端 get_disbandRoom // 返回 null,平台走「不带 deskfree」分支。这时只做房间收尾、不弹结算。 var EQW_ResultHandler = EQW_ResultHandler || { handleJiesuan: function (data) { if (!data.hasOwnProperty('aset')) { console.error('[EQW_ResultHandler] jiesuan 缺 aset,已跳过该包'); return; } this._applyResult(data); }, //平台解散入口。deskfree = { rpc:"jiesuan", data:{ success, aset, account } },可能为 null handleFree: function (deskfree) { if (!deskfree || !deskfree.data) { //首局发牌前解散:没有结算数据,只做房间收尾,不弹结算面板 console.warn('[EQW_ResultHandler] 解散包无 deskfree 数据(首局发牌前解散)'); return; } var d = deskfree.data; if (!d.hasOwnProperty('aset')) { console.error('[EQW_ResultHandler] 解散包缺 aset,已跳过'); return; } this._applyResult(d); }, //三种来源共用的落地逻辑:有哪组就写哪组,缺的保持 null _applyResult: function (d) { EQW_GameState._apply(EQW_GameState.result, d, { chupai: 'chupai', bottom: 'bottom', aset: 'aset', account: 'account' }); EQW_GameState.aset.step = 6; EventBus.emit(EQW_Events.EQW_ASET_RESULT); //account 只在末局或解散时才有 if (d.hasOwnProperty('account')) { EventBus.emit(EQW_Events.EQW_ACCOUNT_RESULT); } } };