Files
youle_cocos/server/games/erqiwang/test/test_deal.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.
// §2 牌局构成:两副去3/4共92张、三家各28+底8、分值。期望取自 design §2/§6.1
require('./_shim');
const P = require('../class.paiju.js');
const t = require('./_assert')();
const pj = P.new({ paiju_list: [] }, 0); // 真实发牌(min_random 由 shim 提供)
// dealowner 统计:-1 去掉的3/4;0 底牌;1/2/3 三家
const cnt = {};
for (const c of pj.cards) cnt[c.dealowner] = (cnt[c.dealowner] || 0) + 1;
t.eq('发牌 三家各28', [P.get_seat_cards_deal(pj, 0).length, P.get_seat_cards_deal(pj, 1).length, P.get_seat_cards_deal(pj, 2).length], [28, 28, 28]);
t.eq('发牌 底牌8', P.get_bottomcards(pj).length, 8);
t.eq('发牌 总发出92(28×3+8)', (cnt[0] || 0) + (cnt[1] || 0) + (cnt[2] || 0) + (cnt[3] || 0), 92);
t.eq('去掉的3/4共16', cnt[-1], 16);
t.eq('无3/4被发出', pj.cards.filter(c => (c.number === 3 || c.number === 4) && c.dealowner !== -1).length, 0);
t.eq('牌对象总数108', pj.cards.length, 108);
// 分值 (§6.1):5→5、10→10、K(13)→10、其余0
const scoreOf = n => pj.cards.find(x => x.number === n).score;
t.eq('分值 5→5', scoreOf(5), 5);
t.eq('分值 10→10', scoreOf(10), 10);
t.eq('分值 K(13)→10', scoreOf(13), 10);
t.eq('分值 A(1)→0', scoreOf(1), 0);
t.eq('分值 6→0', scoreOf(6), 0);
t.eq('分值 大王→0', scoreOf(54), 0);
process.exit(t.done('deal') ? 0 : 1);