diff --git a/ChangeLog.md b/ChangeLog.md index 75a5c17..e65ef32 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,10 @@ +### v0.2.4 / 2022-03-13 + + - Majiang.Shoupai + - 伏せ牌をツモった状態の手牌で get_gang_mianzi() が null を返すバグを修正 + - Majiang.Game + - ノーテン罰なしのルールの場合、リーチ者と和了連荘の親以外は手牌を開かないよう修正 + ### v0.2.3 / 2022-03-09 - Majiang.Game diff --git a/lib/game.js b/lib/game.js index 3ad2cd3..2d576d3 100644 --- a/lib/game.js +++ b/lib/game.js @@ -516,8 +516,14 @@ module.exports = class Game { for (let l = 0; l < 4; l++) { if (this._rule['ノーテン宣言あり'] && ! shoupai[l] && ! model.shoupai[l].lizhi) continue; - if (Majiang.Util.xiangting(model.shoupai[l]) == 0 - && Majiang.Util.tingpai(model.shoupai[l]).length > 0) + if (! this._rule['ノーテン罰あり'] + && (this._rule['連荘方式'] != 2 || l != 0) + && ! model.shoupai[l].lizhi) + { + shoupai[l] = ''; + } + else if (Majiang.Util.xiangting(model.shoupai[l]) == 0 + && Majiang.Util.tingpai(model.shoupai[l]).length > 0) { n_tingpai++; shoupai[l] = model.shoupai[l].toString(); diff --git a/lib/index.js b/lib/index.js index 7300dce..cc7f9ae 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ /*! - * @kobalab/majiang-core v0.2.3 + * @kobalab/majiang-core v0.2.4 * * Copyright(C) 2021 Satoshi Kobayashi * Released under the MIT license diff --git a/lib/shoupai.js b/lib/shoupai.js index 0296441..44dea96 100644 --- a/lib/shoupai.js +++ b/lib/shoupai.js @@ -366,7 +366,7 @@ module.exports = class Shoupai { } else { if (! this._zimo) return null; - if (this._zimo.length != 2) return null; + if (this._zimo.length > 2) return null; let p = this._zimo.replace(/0/,'5'); for (let s of ['m','p','s','z']) { diff --git a/package-lock.json b/package-lock.json index d73c573..9bf10ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@kobalab/majiang-core", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@kobalab/majiang-core", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "devDependencies": { "mocha": "^9.2.0", diff --git a/package.json b/package.json index a9173f5..61b22d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kobalab/majiang-core", - "version": "0.2.3", + "version": "0.2.4", "description": "麻雀基本ライブラリ", "publishConfig": { "access": "public" diff --git a/test/game.js b/test/game.js index f5f6596..c012e85 100644 --- a/test/game.js +++ b/test/game.js @@ -959,7 +959,7 @@ suite('Majiang.Game', ()=>{ game.pingju(); assert.equal(last_paipu(game).pingju.name, '荒牌平局'); assert.equal(last_paipu(game).pingju.shoupai - .filter(s=>s).length, 2) + .filter(s=>s).length, 1) assert.deepEqual(game._fenpei, [0,0,0,0]); }); test('テンパイ連荘', ()=>{ @@ -1039,6 +1039,34 @@ suite('Majiang.Game', ()=>{ assert.equal(last_paipu(game).pingju.name, '流し満貫'); assert.deepEqual(game._fenpei, [8000,4000,-6000,-6000]); }); + test('ノーテン罰なしのルールの場合、' + + 'リーチ者と親以外は手牌を開かないこと',()=> + { + const game = init_game({rule:Majiang.rule({'流し満貫あり':false, + 'ノーテン罰あり':false}), + shoupai:['m567999s4466777', + 'm05p123s56z333*,s8888', + 'm11p789s06,z555-,p406-', + '']}); + game.pingju(); + assert.deepEqual(last_paipu(game).pingju.shoupai, + [ 'm567999s4466777', 'm05p123s56z333*,s8888', + '', '']) + }); + test('ノーテン罰なしで和了連荘のルールの場合、' + + 'リーチ者以外は手牌を開かないこと', ()=> + { + const game = init_game({rule:Majiang.rule({'流し満貫あり':false, + 'ノーテン罰あり':false, + '連荘方式':1}), + shoupai:['m567999s4466777', + 'm05p123s56z333*,s8888', + 'm11p789s06,z555-,p406-', + '']}); + game.pingju(); + assert.deepEqual(last_paipu(game).pingju.shoupai, + [ '', 'm05p123s56z333*,s8888', '', '']) + }); }); suite('last()', ()=>{ diff --git a/test/shoupai.js b/test/shoupai.js index e6187ce..38d39ae 100644 --- a/test/shoupai.js +++ b/test/shoupai.js @@ -628,10 +628,14 @@ suite('Majiang.Shoupai', ()=>{ assert.ifError(Shoupai('m123p456s789z12345').get_chi_mianzi('m1-')); assert.ifError(Shoupai('m123p456s789z12,z333=,') .get_chi_mianzi('m1-')); + assert.ifError(Shoupai('______________').get_chi_mianzi('m1-')); }); - test('チーできるメンツがない場合', ()=> + test('チーできるメンツがない場合', ()=>{ assert.deepEqual(Shoupai('m123p456s789z1234').get_chi_mianzi('m5-'), - [])); + []); + assert.deepEqual(Shoupai('_____________').get_chi_mianzi('m5-'), + []); + }); test('チーできるメンツが1つの場合', ()=> assert.deepEqual(Shoupai('m123p456s789z1234').get_chi_mianzi('m3-'), ['m123-'])); @@ -736,11 +740,15 @@ suite('Majiang.Shoupai', ()=>{ .get_peng_mianzi('m1+')); assert.ifError(Shoupai('m112p456s789z12,z333=,') .get_peng_mianzi('m1=')); + assert.ifError(Shoupai('______________').get_peng_mianzi('m1-')); }); - test('ポンできるメンツがない場合', ()=> + test('ポンできるメンツがない場合', ()=>{ assert.deepEqual(Shoupai('m123p456s789z1234') .get_peng_mianzi('m1+'), - [])); + []); + assert.deepEqual(Shoupai('_____________').get_peng_mianzi('m1='), + []); + }); test('下家からポンできること', ()=> assert.deepEqual(Shoupai('m112p456s789z1234') .get_peng_mianzi('m1+'), @@ -804,10 +812,14 @@ suite('Majiang.Shoupai', ()=>{ .get_gang_mianzi('m1+')); assert.ifError(Shoupai('m111p456s789z12,z333=,') .get_gang_mianzi('m1+')); + assert.ifError(Shoupai('______________').get_gang_mianzi('m1-')); }); - test('大明槓できるメンツがない場合', ()=> + test('大明槓できるメンツがない場合', ()=>{ assert.deepEqual(Shoupai('m123p456s789z1122') - .get_gang_mianzi('z1+'),[])); + .get_gang_mianzi('z1+'),[]); + assert.deepEqual(Shoupai('_____________') + .get_gang_mianzi('z1='),[]); + }); test('下家から大明槓できること', ()=> assert.deepEqual(Shoupai('m111p456s789z1234') .get_gang_mianzi('m1+'), ['m1111+'])); @@ -851,10 +863,14 @@ suite('Majiang.Shoupai', ()=>{ assert.ifError(Shoupai('m1111p555s999z123').get_gang_mianzi()); assert.ifError(Shoupai('m1111p555s999,z333=').get_gang_mianzi()); assert.ifError(Shoupai('m11112p555s999,z333=,').get_gang_mianzi()); + assert.ifError(Shoupai('_____________').get_gang_mianzi()); }); - test('暗槓できるメンツがない場合', ()=> + test('暗槓できるメンツがない場合', ()=>{ assert.deepEqual(Shoupai('m123p456s789z12345') - .get_gang_mianzi(), [])); + .get_gang_mianzi(), []); + assert.deepEqual(Shoupai('______________') + .get_gang_mianzi(), []); + }); test('萬子で暗槓できること', ()=> assert.deepEqual(Shoupai('m1111p456s789z1234') .get_gang_mianzi(), ['m1111'])); @@ -894,10 +910,15 @@ suite('Majiang.Shoupai', ()=>{ .get_gang_mianzi()); assert.ifError(Shoupai('m12p555s999,z333=,m111-,') .get_gang_mianzi()); + assert.ifError(Shoupai('__________,m111-,') + .get_gang_mianzi()); }); - test('加槓できるメンツがない場合', ()=> + test('加槓できるメンツがない場合', ()=>{ assert.deepEqual(Shoupai('m123p456s789z12,z777+') - .get_gang_mianzi(), [])); + .get_gang_mianzi(), []); + assert.deepEqual(Shoupai('___________,z777+') + .get_gang_mianzi(), []); + }); test('萬子で加槓できること', ()=> assert.deepEqual(Shoupai('m1p456s789z1234,m111+') .get_gang_mianzi(), ['m111+1']));