Files
erqiwang_youle/server/games/erqiwang/test/_rpc.js
T
joywayerandClaude Opus 4.8 339e6e99e1 二七王测试:完成 P2 用例,达成测试计划 DoD
- test_deal.js(新):§2 发牌构成——92张/去3-4共16/三家各28+底8/分值(§6.1)
- test_arith.js:§3 编码排序(order_cards 降序=设计顺序、is_continuous 相邻链逐段+反例)、
  §7 每档小光/过庄分界+升3级补齐
- test_paiju.js:§8.2 亮牌更多边界(6个7仅qi、固定主9→null、固定主10仅zhu)
- test_config.js:§10 直接调 export.get_asetcount/get_needroomcard(_joinroom)
- test_rpc.js/_rpc.js:§12 端到端(真实驱动 叫分→上庄→选主→埋牌→出牌ready)、
  §9 maipai 亮牌门控 + get_deskinfo PushCards 门控
- 02-测试计划.md/README:P2 与 DoD 标记达成

全部单测 204 项断言全绿(node server/games/erqiwang/test/run.js)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 01:24:34 +08:00

57 lines
2.7 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.
// L3 RPC 测试脚手架:装配 mod.js(含 RPC 方法),捕获下发包
require('./_shim');
// mod.js 的 RPC handler 按全局名引用这些类,先挂到 global
global.cls_youle_erqiwang_config = require('../class.config.js');
global.cls_youle_erqiwang_pai = require('../class.pai.js');
global.cls_youle_erqiwang_arith = require('../class.arith.js');
global.cls_youle_erqiwang_paiju = require('../class.paiju.js');
global.cls_youle_erqiwang_desk = require('../class.desk.js');
// mod.js 顶部依赖:cls_mod.new 造模块对象、min_loadJsFile 置为同步 no-op(类已单独 require)
global.cls_mod = { new: (name, route, app) => ({ modname: name, routename: route, app }) };
global.youle_app = {};
global.min_loadJsFile = (p, cb) => { if (cb) cb(); };
const mod = require('../mod.js'); // = youle_erqiwang,含 jiaofen/xuanzhu/.../mingpai/zhunbei
const clone = m => JSON.parse(JSON.stringify(m));
// 装配一局:给定 roomtype 与 o_paiju,返回 { sent, o_room },并把 check_player/SendPack/sendpack_toother
// 全部指向同一个 sent 数组(快照每个下发包,因 mod 会跨座位改删字段)
function setup(roomtype, o_paiju, seatlist) {
const sent = [];
const o_desk = {
paiju_list: [o_paiju],
o_room: null,
seatlist: [[0, []], [0, []], [0, []]],
prepare: [0, 0, 0],
method: {
curr_paiju: () => o_paiju,
get_countdown_jiaofen: () => 15, get_countdown_xuanzhu: () => 20,
get_countdown_maipai: () => 25, get_countdown_chupai: () => 30,
do_prepare: () => { }, get_desk_account: m => m
}
};
const o_room = {
roomtype, asetcount: 6,
seatlist: seatlist || [{ conmode: 0, fromid: 0 }, { conmode: 0, fromid: 1 }, { conmode: 0, fromid: 2 }],
o_desk,
method: { sendpack_toother: m => sent.push(clone(m)) }
};
o_desk.o_room = o_room;
if (o_paiju) o_paiju.o_desk = o_desk;
mod.import = { check_player: () => o_room, deduct_roomcard: () => { }, save_grade: () => { } };
mod.app = { SendPack: m => sent.push(clone(m)) };
return { sent, o_room, o_desk };
}
// 构造 108 张牌(带 flower/number/dealowner/playround),供 get_seat_zhucards / get_seat_cards 用
function make108(deal) {
const A = global.cls_youle_erqiwang_arith;
const cards = [];
for (let i = 0; i < 108; i++) cards[i] = { id: i, dealowner: 1, playround: -1, playowner: -1, score: 0, flower: A.id_to_flower(i), number: A.id_to_number(i) };
if (deal) for (const [cid, owner] of deal) cards[cid].dealowner = owner;
return cards;
}
module.exports = { mod, setup, make108, id: (d, f, n) => (d - 1) * 54 + (f - 1) * 13 + (n - 1) };