diff --git a/server/games/erqiwang/class.paiju.js b/server/games/erqiwang/class.paiju.js index 7236a91..284b2ad 100644 --- a/server/games/erqiwang/class.paiju.js +++ b/server/games/erqiwang/class.paiju.js @@ -558,23 +558,29 @@ var cls_youle_erqiwang_paiju = cls_youle_erqiwang_paiju || { //进入出牌阶段 o_paiju.step = 5; - //是否报副处理 - if (o_paiju.seatlist[o_paiju.playproc.currseat][4][0] != 0){ - var _zhu = cls_youle_erqiwang_paiju.get_seat_zhucards(o_paiju, o_paiju.playproc.currseat); - if (_zhu.length == 0){ - o_paiju.seatlist[o_paiju.playproc.currseat][4][0] = 0; - o_paiju.seatlist[o_paiju.playproc.currseat][4][1] = 0; - } - if (o_paiju.method.have_baofu()){ - var _parilist = cls_youle_erqiwang_arith.get_pairlist(o_paiju.flower, _zhu); - o_paiju.seatlist[o_paiju.playproc.currseat][4][0] = _zhu.length; - o_paiju.seatlist[o_paiju.playproc.currseat][4][1] = _parilist.length; + //报无主处理(design §9) + //先看出牌者自己的主牌是否已出空(出空即"报无主"); + //一旦全场有人报无主,立即为【全体三人】刷新剩余主牌数/主对子数——design §9 要求 + //"一旦有玩家的主牌全部打空,系统就为全体三人显示另外两家各自的主牌数量与对子数", + //而不是等另外两家各自轮到出牌时才逐个补上。 + var _self = o_paiju.playproc.currseat; + if (cls_youle_erqiwang_paiju.get_seat_zhucards(o_paiju, _self).length == 0){ + o_paiju.seatlist[_self][4][0] = 0; + o_paiju.seatlist[_self][4][1] = 0; + } + if (o_paiju.method.have_baofu()){ + for (var _s = 0; _s < 3; _s++){ + var _zhu = cls_youle_erqiwang_paiju.get_seat_zhucards(o_paiju, _s); + var _zhupair = cls_youle_erqiwang_arith.get_pairlist(o_paiju.flower, _zhu); + o_paiju.seatlist[_s][4][0] = _zhu.length; + o_paiju.seatlist[_s][4][1] = _zhupair.length; - if (o_paiju.seatlist[o_paiju.playproc.currseat][4][0] == 0){ - o_paiju.seatlist[o_paiju.playproc.currseat][o_paiju.flower - 1][0] = 1; - o_paiju.seatlist[o_paiju.playproc.currseat][o_paiju.flower - 1][1] = 1; - } else if (o_paiju.seatlist[o_paiju.playproc.currseat][4][1] == 0){ - o_paiju.seatlist[o_paiju.playproc.currseat][o_paiju.flower - 1][1] = 1; + if (_zhu.length == 0){ + //主牌出空,等同于主花色也没有了、也没有主花色的对子 + o_paiju.seatlist[_s][o_paiju.flower - 1][0] = 1; + o_paiju.seatlist[_s][o_paiju.flower - 1][1] = 1; + } else if (_zhupair.length == 0){ + o_paiju.seatlist[_s][o_paiju.flower - 1][1] = 1; } } } diff --git a/server/games/erqiwang/test/test_input.js b/server/games/erqiwang/test/test_input.js index 1671652..c490edb 100644 --- a/server/games/erqiwang/test/test_input.js +++ b/server/games/erqiwang/test/test_input.js @@ -92,4 +92,24 @@ try { t.eq('出牌 反 非法入参不抛异常', threw, null); t.eq('出牌 反 非法入参不产生任何出牌', pj5.cards.filter(c => c.playround > 0).length, 0); + + +// ============ design §9:报无主后立即为全体三人刷新主牌统计 ============ +// 造 step5 牌局:seat0 手上只剩 1 张主牌(打掉即报无主),seat1/seat2 各持若干主牌 +const pj6 = newPaiju(5, 0, 0); +for (let i = 0; i < 108; i++) pj6.cards[i].dealowner = -1; // 先全部清空 +const give = (cid, seat) => { pj6.cards[cid].dealowner = seat + 1; pj6.cards[cid].playround = -1; }; +give(id(1, 1, 5), 0); // seat0:主♦5(唯一主牌) +give(id(1, 3, 9), 0); // seat0:副♥9(保证还有牌) +give(id(1, 1, 13), 1); give(id(2, 1, 13), 1); give(id(1, 1, 12), 1); // seat1:主♦K对 + 主♦Q +give(id(1, 1, 7), 2); // seat2:正7(固定主牌) +P.new_playround(pj6, 1, 0); +t.eq('报无主前 三家统计均为初始 [-1,-1]', pj6.seatlist.map(s => s[4]), [[-1, -1], [-1, -1], [-1, -1]]); +P.do_playcard(pj6, [id(1, 1, 5)]); // seat0 打出唯一主牌 → 报无主 +t.eq('报无主 seat0 主牌清空 [0,0]', pj6.seatlist[0][4], [0, 0]); +t.eq('报无主 立即刷新 seat1 [3张,1对]', pj6.seatlist[1][4], [3, 1]); +t.eq('报无主 立即刷新 seat2 [1张,0对]', pj6.seatlist[2][4], [1, 0]); +t.eq('报无主 seat0 主花色标志置1', pj6.seatlist[0][pj6.flower - 1], [1, 1]); +t.eq('报无主 seat2 无主对→无对标志置1', pj6.seatlist[2][pj6.flower - 1][1], 1); + process.exit(t.done('input') ? 0 : 1); diff --git a/server/games/erqiwang/test/test_rpc.js b/server/games/erqiwang/test/test_rpc.js index 0f3cf49..0db7345 100644 --- a/server/games/erqiwang/test/test_rpc.js +++ b/server/games/erqiwang/test/test_rpc.js @@ -46,6 +46,9 @@ function mkChupai(roomtype) { const lead = id(1, 3, 9); // 副9(flower3) 作单张首出 pj.cards[lead].dealowner = 1; // 归庄家 pj.cards[lead].playround = -1; + // seat1 报无主:必须让它【真的】打空主牌。do_playcard 会按各家实际手牌重算三家的主牌统计 + // (design §9:一旦有人报无主,立即为全体三人刷新),只置标志位会被重算纠正回去 + for (const c of P.get_seat_zhucards(pj, 1)) pj.cards[c].playround = 1; pj.seatlist[1][4][0] = 0; // seat1 报无主 → have_baofu()=true const c = setup(roomtype, pj); mod.chupai(pack(0, { cards: [lead] }));