From af9ebf7034281e39a6cd6e78d2139009aee947e0 Mon Sep 17 00:00:00 2001 From: im_tan Date: Mon, 12 Feb 2024 18:38:55 +0900 Subject: [PATCH] =?UTF-8?q?test:=20[Mi=E9=BA=BB=E9=9B=80]=20=E5=BD=B9?= =?UTF-8?q?=E6=BA=80=EF=BC=88=E5=A4=A9=E5=92=8C=E3=80=81=E5=9C=B0=E5=92=8C?= =?UTF-8?q?=E3=82=92=E9=99=A4=E3=81=8F=EF=BC=89=E3=81=AE=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=20(#13263)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add daisangen test * add suanko test * add suanko-tanki test * add tsuiso test * fix typo * add test-shosushi * add test-daisushi * add ryuiso-test * add chinroto-test * add sukantsu-test * add kokushi-13-test --- packages/misskey-mahjong/test/yaku.ts | 293 +++++++++++++++++++++++++- 1 file changed, 291 insertions(+), 2 deletions(-) diff --git a/packages/misskey-mahjong/test/yaku.ts b/packages/misskey-mahjong/test/yaku.ts index a7e2b8ffd9..0eb92893b9 100644 --- a/packages/misskey-mahjong/test/yaku.ts +++ b/packages/misskey-mahjong/test/yaku.ts @@ -22,11 +22,12 @@ describe('Yaku', () => { it('valid', () => { assert.deepStrictEqual(calcYakus({ house: 'e', - handTiles: ['m1', 'm9', 's1', 's9', 'p1', 'p9', 'haku', 'hatsu', 'chun', 'n', 'w', 's', 'e'] , + handTiles: ['m1', 'm1', 's1', 's9', 'p1', 'p9', 'haku', 'hatsu', 'chun', 'n', 'w', 's', 'e', 'm9'] , huros: [], - tumoTiles: 'm1', + tumoTiles: 'm9', }), ['kokushi']); }); + it('invalid', () => { assert.deepStrictEqual(calcYakus({ house: 'e', @@ -37,6 +38,294 @@ describe('Yaku', () => { }); }); + describe('kokushi-13', () => { + it('valid', () => { + assert.deepStrictEqual(calcYakus({ + house: 'e', + handTiles: ['m1', 'm9', 's1', 's9', 'p1', 'p9', 'haku', 'hatsu', 'chun', 'n', 'w', 's', 'e', 'm1'] , + huros: [], + tumoTiles: 'm1', + }), ['kokushi-13']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: 'e', + handTiles: ['m1', 'm1', 's1', 's9', 'p1', 'p9', 'haku', 'hatsu', 'chun', 'n', 'w', 's', 'e', 'm9'] , + huros: [], + tumoTiles: 'm1', + }).includes('kokushi-13'), false); + }); + }); + + describe('suanko', () => { + it('valid',() => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'm2', 'm2', 'm2', 'hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'e', 'e'], + huros: [], + tsumoTile: 'chun', + }), ['suanko']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m2', 'm2', 'm2', 'hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'e', 'e'], + huros: [{type: 'ankan', :tile: 'm1'}], + tsumoTile: 'chun', + }), ['suanko']); + }); + + it('invalid',() => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'm2', 'm2', 'e', 'e', 'e'], + huros: [{type: 'pom', tile: 'm1'}], + ronTile: 'e', + }).includes('suanko'), false); + + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'm2', 'm2', 'e', 'e', 'e'], + huros: [], + ronTile: 'e', + }).includes('suanko'), false); + + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'm2', 'm2', 'e', 'e', 'e'], + huros: [], + ronTile: 'e', + }).includes('suanko'), false); + }); + }); + + describe('suanko-tanki', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'm2', 'm2', 'm2', 'm3', 'm3', 'm3', 'haku', 'haku', 'haku', 'e', 'e'], + huros: [], + tsumoTile: 'e', + }), ['suanko-tanki']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m2', 'm2', 'm2', 'm3', 'm3', 'm3', 'haku', 'haku', 'haku', 'e', 'e'], + huros: [{type: 'ankan', tile: 'm1'}], + tsumoTile: 'e', + }), ['suanko-tanki']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'm2', 'm2', 'm2', 'hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'e', 'e'], + huros: [], + tsumoTile: 'chun', + }).includes('suanko-tanki'), false); + }); + }) + + describe('daisangen', () => { + it('valid', () => { + assert.deepStrictEqual(calcYakus({ + house: 'e', + handTiles: ['haku', 'haku', 'haku', 'hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'p2', 'p2', 'p2', 's2', 's2'], + huros: [], + tsumoTile: 's2', + }), ['daisangen']); + + assert.deepStrictEqual(calcYakus({ + house: 'e', + handTiles: ['hatsu', 'hatsu', 'hatsu', 'chun', 'chun', 'chun', 'p2', 'p2', 'p2', 's2', 's2'], + huros: [{type: 'pon', tile: 'haku'}], + tsumoTile: 's2', + }), ['daisangen']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: 'e', + handTiles: ['haku', 'haku', 'haku', 'chun', 'chun', 'hatsu', 'hatsu', 'hatsu', 'm1', 'm1', 'm1', 'm2', 'm2', 'm2'] , + huros: [], + tumoTiles: 'm2', + }).includes('daisangen'), false); + }); + }); + + describe('tsuiso', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['haku', 'haku', 'haku', 'hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [], + tsumoTile: 's', + }), ['tsuiso']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [{type: 'pon', tile: 'haku'}], + tsumoTile: 's', + }), ['tsuiso']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [], + tsumoTile: 's', + }).includes('tsuiso'), false); + + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [{type: 'pon', tile: 'm1'}], + tsumoTile: 's', + }).includes('tuiso'), false); + }); + }) + + describe('shosushi', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'n', 'n', 'n', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [], + tsumoTile: 's', + }), ['shosushi']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'n', 'n', 'n', 'w', 'w', 'w', 's', 's'], + huros: [{type: 'pon', tile: 'e'}], + tsumoTile: 's', + }), ['shosushi']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [], + tsumoTile: 's', + }).includes('shosushi'), false); + + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [{type: 'pon', tile: 'm1'}], + tsumoTile: 's', + }).includes('shosushi'), false); + }); + }) + + describe('daisushi', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'n', 'n', 'n', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's', 's'], + huros: [], + tsumoTile: 's', + }), ['daisushi']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'n', 'n', 'n', 'w', 'w', 'w', 's', 's', 's'], + huros: [{type: 'pon', tile: 'e'}], + tsumoTile: 'e', + }), ['daisushi']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1', 'm1', 'm1', 'n', 'n', 'n', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [], + tsumoTile: 's', + }).includes('daisushi'), false); + + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['hatsu', 'hatsu', 'hatsu', 'e', 'e', 'e', 'w', 'w', 'w', 's', 's'], + huros: [{type: 'pon', tile: 'm1'}], + tsumoTile: 'e', + }).includes('daisushi'), false); + }); + }) + + describe('ryuiso', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['s2', 's2', 's2', 's2', 's3', 's4', 's6', 's6', 's6', 's8', 's8', 's8', 'hatsu', 'hatsu'], + huros: [], + tsumoTile: 'hatsu', + }), ['ryuiso']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['s2', 's2', 's2', 's2', 's3', 's3', 's3', 's3', 's4', 's8', 's8'], + huros: [{type: 'pon', tile: 'hatsu'}], + tsumoTile: 's8', + }), ['ryuiso']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['s2', 's2', 's2', 's2', 's3', 's3', 's3', 's3', 's4', 's8', 's8','haku','haku','haku'], + huros: [], + tsumoTile: 's', + }).includes('ryuiso'), false); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['s2', 's2', 's2', 's2', 's3', 's3', 's3', 's3', 's4', 's8', 's8'], + huros: [{type: 'pon', tile: 'haku'}], + tsumoTile: 's', + }).includes('ryuiso'), false); + }); + }) + + describe('chinroto', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m1','m1','m1''m9', 'm9', 'm9', 's1', 's1', 's1', 's9', 's9', 's9', 'p1', 'p1'], + huros: [], + tsumoTile: 'p1', + }), ['chinroto']); + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['m9', 'm9', 'm9', 's1', 's1', 's1', 's9', 's9', 's9', 'p1', 'p1'], + huros: [{type: 'pon', tile: 'm1'}], + tsumoTile: 'p1', + }), ['chinroto']); + }); + + it('invalid', () => { + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['s2', 's2', 's2', 's2', 's3', 's3', 's3', 's3', 's4', 's8', 's8','haku','haku','haku'], + huros: [], + tsumoTile: 's', + }).includes('chinroto'), false); + }); + }) + + describe('sukantsu', () => { + it('valid', () =>{ + assert.deepStrictEqual(calcYakus({ + house: '', + handTiles: ['p1', 'p1'], + huros: [{type: 'ankan', tile: 'm1'}, {type: 'ankan', tile: 'm2'}, {type: 'minkan', tile: 'm3'}, {type: 'minkan', tile: 'chun'}], + tsumoTile: 'p1', + }), ['sukantsu']); + }); + 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('sukantsu'), false); + }); + }) describe('churen', () => { it('valid', () => {