Files
youle_cocos/server/games/erqiwang/test/test_callgrade.js
T

29 lines
1.3 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.
// §4.2 叫分坐庄 do_callgrade(纯函数,operate on 最小 o_paiju)。期望取自 design §4.2
require('./_shim');
const P = require('../class.paiju.js');
const t = require('./_assert')();
const mkCall = fs => ({ callproc: [{ seat: fs, call: null }], banker: -1, call: -1, step: 1 });
// 依次叫分序列(calls 里每个值 = 当前轮到者的叫分,0=不叫)
function seq(firstseat, calls) {
const p = mkCall(firstseat);
for (const c of calls) P.do_callgrade(p, c);
return p;
}
const bcs = p => [p.banker, p.call, p.step];
// 叫5立即上庄
t.eq('叫5立即上庄', bcs(seq(0, [5])), [0, 5, 2]);
// 暂定庄叫65,另两家都不叫 → 暂定庄(0)上庄
t.eq('0叫65 两家不叫→0上庄', bcs(seq(0, [65, 0, 0])), [0, 65, 2]);
// 0叫65、1叫更低60、2不叫、0不叫 → 60 最低者(1)上庄
t.eq('0叫65 1叫60 余不叫→1上庄', bcs(seq(0, [65, 60, 0, 0])), [1, 60, 2]);
// 首家叫5路径:0叫5 → 0直接上庄(其余无需叫)
t.eq('首家叫5直接坐庄', bcs(seq(0, [5])), [0, 5, 2]);
// 递减到5:0叫65,1叫60,2叫5 → 2上庄(叫5立即)
t.eq('2叫5立即上庄', bcs(seq(0, [65, 60, 5])), [2, 5, 2]);
// 不同首家:1起叫,1叫50,2不叫,0不叫 → 1上庄
t.eq('首家1叫50 余不叫→1上庄', bcs(seq(1, [50, 0, 0])), [1, 50, 2]);
process.exit(t.done('callgrade') ? 0 : 1);