Skip to content

Commit

Permalink
Merge branch 'release/v1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
kobalab committed Dec 29, 2024
2 parents a253d26 + a9a59f3 commit 018dc83
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 46 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### v1.3.2 / 2024-12-29

- 伏せ牌の扱いを変更
- fromString() は記述順に14枚まで使用する(伏せ牌を優先しない)
- toString() は伏せ牌を右側に配置する
- パッケージを最新化
- mocha 10.7.3 → 11.0.1
- 脆弱性警告に対処
- cross-spawn 7.0.3 → 7.0.6

### v1.3.1 / 2024-10-27

- Majiang.Board が配牌にドラがない・ドラが複数ある場合を処理できるよう修正
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 v1.3.1
* @kobalab/majiang-core v1.3.2
*
* Copyright(C) 2021 Satoshi Kobayashi
* Released under the MIT license
Expand Down
8 changes: 5 additions & 3 deletions lib/shoupai.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ module.exports = class Shoupai {
let fulou = paistr.split(',');
let bingpai = fulou.shift();

let qipai = bingpai.match(/_/g) || [];
for (let suitstr of bingpai.match(/[mpsz]\d+/g) || []) {
let qipai = bingpai.match(/^_*/)[0].match(/_/g) || [];
for (let suitstr of bingpai.match(/[mpsz]\d+_*/g) || []) {
let s = suitstr[0];
for (let n of suitstr.match(/\d/g)) {
if (s == 'z' && (n < 1 || 7 < n)) continue;
qipai.push(s+n);
}
qipai = qipai.concat(suitstr.match(/_/g)||[]);
}
qipai = qipai.slice(0, 14 - fulou.filter(x=>x).length * 3);
let zimo = (qipai.length -2) % 3 == 0 && qipai.slice(-1)[0];
Expand All @@ -91,7 +92,7 @@ module.exports = class Shoupai {

toString() {

let paistr = '_'.repeat(this._bingpai._ + (this._zimo == '_' ? -1 : 0));
let paistr = '';

for (let s of ['m','p','s','z']) {
let suitstr = s;
Expand All @@ -110,6 +111,7 @@ module.exports = class Shoupai {
}
if (suitstr.length > 1) paistr += suitstr;
}
paistr += '_'.repeat(this._bingpai._ + (this._zimo == '_' ? -1 : 0));
if (this._zimo && this._zimo.length <= 2) paistr += this._zimo;
if (this._lizhi) paistr += '*';

Expand Down
Loading

0 comments on commit 018dc83

Please sign in to comment.