Skip to content

Commit

Permalink
Merge branch 'release/v0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
kobalab committed Mar 13, 2022
2 parents aa08962 + 2948e8c commit 155a90c
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 18 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions lib/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/shoupai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kobalab/majiang-core",
"version": "0.2.3",
"version": "0.2.4",
"description": "麻雀基本ライブラリ",
"publishConfig": {
"access": "public"
Expand Down
30 changes: 29 additions & 1 deletion test/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('テンパイ連荘', ()=>{
Expand Down Expand Up @@ -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()', ()=>{
Expand Down
41 changes: 31 additions & 10 deletions test/shoupai.js
Original file line number Diff line number Diff line change
Expand Up @@ -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-']));
Expand Down Expand Up @@ -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+'),
Expand Down Expand Up @@ -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+']));
Expand Down Expand Up @@ -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']));
Expand Down Expand Up @@ -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']));
Expand Down

0 comments on commit 155a90c

Please sign in to comment.