mizzkey/packages/misskey-mahjong/test/yaku.ts
2024-02-11 14:23:37 +09:00

117 lines
3.2 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as assert from 'node:assert';
import { calcYakus } from '../src/common.yaku.js';
describe('Yaku', () => {
describe('Riichi', () => {
it('valid', () => {
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm2', 'm3', 'p6', 'p6', 'p6', 's6', 's7', 's8', 'n', 'n', 'n', 'm3', 'm3'],
huros: [],
riichi: true,
}), ['riichi']);
});
});
describe('churen', () => {
it('valid', () => {
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm3', 'm4', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm5'],
huros: [],
tsumoTile: 'm5',
}), ['churen']);
});
it('invalid', () => {
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm3', 'm4', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm2'],
huros: [],
tsumoTile: 'm2',
}).includes('churen'), false);
});
});
describe('churen-9', () => {
it('valid', () => {
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm1'],
huros: [],
tsumoTile: 'm1',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm2'],
huros: [],
tsumoTile: 'm2',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm3'],
huros: [],
tsumoTile: 'm3',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm4'],
huros: [],
tsumoTile: 'm4',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm5'],
huros: [],
tsumoTile: 'm5',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm6'],
huros: [],
tsumoTile: 'm6',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm7'],
huros: [],
tsumoTile: 'm7',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm8'],
huros: [],
tsumoTile: 'm8',
}), ['churen-9']);
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm9'],
huros: [],
tsumoTile: 'm9',
}), ['churen-9']);
});
it('invalid', () => {
assert.deepStrictEqual(calcYakus({
house: 'e',
handTiles: ['m1', 'm1', 'm1', 'm2', 'm3', 'm3', 'm4', 'm6', 'm7', 'm8', 'm9', 'm9', 'm9', 'm5'],
huros: [],
tsumoTile: 'm5',
}).includes('churen-9'), false);
});
});
});