Skip to content

Commit 171ec32

Browse files
committed
Merge branch 'release/v1.2.1'
2 parents 0ea2d0a + 7540097 commit 171ec32

File tree

10 files changed

+30
-26
lines changed

10 files changed

+30
-26
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### v1.2.1 / 2024-02-25
2+
3+
- String の非推奨のメソッドを変更: substr() → slice()
4+
15
## v1.2.0 / 2024-02-03
26

37
- #5 麻雀サーバーに関する処理を追加

lib/board.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = class Board {
8686
this.lunban = dapai.l;
8787
this.shoupai[dapai.l].dapai(dapai.p, false);
8888
this.he[dapai.l].dapai(dapai.p);
89-
this._lizhi = dapai.p.substr(-1) == '*';
89+
this._lizhi = dapai.p.slice(-1) == '*';
9090
}
9191

9292
fulou(fulou) {

lib/game.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = class Game {
7272
}
7373

7474
say(name, l) {
75-
if (this._view) this._view.say(name, l);
75+
if (this._view) this._view.say(name, l);
7676
}
7777

7878
stop(callback = ()=>{}) {
@@ -298,12 +298,12 @@ module.exports = class Game {
298298

299299
if (this._diyizimo) {
300300
if (! dapai.match(/^z[1234]/)) this._fengpai = false;
301-
if (this._dapai && this._dapai.substr(0,2) != dapai.substr(0,2))
301+
if (this._dapai && this._dapai.slice(0,2) != dapai.slice(0,2))
302302
this._fengpai = false;
303303
}
304304
else this._fengpai = false;
305305

306-
if (dapai.substr(-1) == '*') {
306+
if (dapai.slice(-1) == '*') {
307307
this._lizhi[model.lunban] = this._diyizimo ? 2 : 1;
308308
this._yifa[model.lunban] = this._rule['一発あり'];
309309
}
@@ -448,8 +448,8 @@ module.exports = class Game {
448448
let menfeng = this._hule.length ? this._hule.shift() : model.lunban;
449449
let rongpai = menfeng == model.lunban ? null
450450
: (this._hule_option == 'qianggang'
451-
? this._gang[0] + this._gang.substr(-1)
452-
: this._dapai.substr(0,2)
451+
? this._gang[0] + this._gang.slice(-1)
452+
: this._dapai.slice(0,2)
453453
) + '_+=-'[(4 + model.lunban - menfeng) % 4];
454454
let shoupai = model.shoupai[menfeng].clone();
455455
let fubaopai = shoupai.lizhi ? model.shan.fubaopai : null;
@@ -728,7 +728,7 @@ module.exports = class Game {
728728
else if (reply.dapai) {
729729
let dapai = reply.dapai.replace(/\*$/,'');
730730
if (this.get_dapai().find(p => p == dapai)) {
731-
if (reply.dapai.substr(-1) == '*' && this.allow_lizhi(dapai)) {
731+
if (reply.dapai.slice(-1) == '*' && this.allow_lizhi(dapai)) {
732732
this.say('lizhi', model.lunban);
733733
return this.delay(()=>this.dapai(reply.dapai));
734734
}
@@ -770,7 +770,7 @@ module.exports = class Game {
770770
return this.delay(()=>this.hule());
771771
}
772772

773-
if (this._dapai.substr(-1) == '*') {
773+
if (this._dapai.slice(-1) == '*') {
774774
model.defen[model.player_id[model.lunban]] -= 1000;
775775
model.lizhibang++;
776776

@@ -872,7 +872,7 @@ module.exports = class Game {
872872
this._hule.push(l);
873873
}
874874
else {
875-
let p = this._gang[0] + this._gang.substr(-1);
875+
let p = this._gang[0] + this._gang.slice(-1);
876876
let shoupai = model.shoupai[l].clone().zimo(p);
877877
if (Majiang.Util.xiangting(shoupai) == -1)
878878
this._neng_rong[l] = false;
@@ -969,7 +969,7 @@ module.exports = class Game {
969969
}
970970
else {
971971
let p = (this._status == 'gang'
972-
? this._gang[0] + this._gang.substr(-1)
972+
? this._gang[0] + this._gang.slice(-1)
973973
: this._dapai
974974
) + '_+=-'[(4 + model.lunban - l) % 4];
975975
let hupai = model.shoupai[l].lizhi

lib/he.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = class He {
2323
if (! Majiang.Shoupai.valid_mianzi(m)) throw new Error(m);
2424
let p = m[0] + m.match(/\d(?=[\+\=\-])/), d = m.match(/[\+\=\-]/);
2525
if (! d) throw new Error(m);
26-
if (this._pai[this._pai.length - 1].substr(0,2) != p)
26+
if (this._pai[this._pai.length - 1].slice(0,2) != p)
2727
throw new Error(m);
2828
this._pai[this._pai.length - 1] += d;
2929
return this;

lib/hule.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function hule_mianzi_qidui(shoupai, hulepai) {
116116
for (let n = 1; n < bingpai.length; n++) {
117117
if (bingpai[n] == 0) continue;
118118
if (bingpai[n] == 2) {
119-
let m = (s+n == hulepai.substr(0,2))
119+
let m = (s+n == hulepai.slice(0,2))
120120
? s+n+n + hulepai[2] + '!'
121121
: s+n+n;
122122
mianzi.push(m);
@@ -140,14 +140,14 @@ function hule_mianzi_guoshi(shoupai, hulepai) {
140140
let nn = (s == 'z') ? [1,2,3,4,5,6,7] :[1,9];
141141
for (let n of nn) {
142142
if (bingpai[n] == 2) {
143-
let m = (s+n == hulepai.substr(0,2))
143+
let m = (s+n == hulepai.slice(0,2))
144144
? s+n+n + hulepai[2] + '!'
145145
: s+n+n;
146146
mianzi.unshift(m);
147147
n_duizi++;
148148
}
149149
else if (bingpai[n] == 1) {
150-
let m = (s+n == hulepai.substr(0,2))
150+
let m = (s+n == hulepai.slice(0,2))
151151
? s+n + hulepai[2] + '!'
152152
: s+n;
153153
mianzi.push(m);
@@ -177,7 +177,7 @@ function hule_mianzi_jiulian(shoupai, hulepai) {
177177
}
178178
}
179179
if (mianzi.length != 14) return [];
180-
mianzi += hulepai.substr(1) + '!';
180+
mianzi += hulepai.slice(1) + '!';
181181

182182
return [ [mianzi] ];
183183
}
@@ -684,7 +684,7 @@ function hule(shoupai, rongpai, param) {
684684

685685
if (rongpai) {
686686
if (! rongpai.match(/[\+\=\-]$/)) throw new Error(rongpai);
687-
rongpai = rongpai.substr(0,2) + rongpai.substr(-1);
687+
rongpai = rongpai.slice(0,2) + rongpai.slice(-1);
688688
}
689689

690690
let max;

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* @kobalab/majiang-core v1.2.0
2+
* @kobalab/majiang-core v1.2.1
33
*
44
* Copyright(C) 2021 Satoshi Kobayashi
55
* Released under the MIT license

lib/player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module.exports = class Player {
115115

116116
this._diyizimo = false;
117117
if (gang.l != this._menfeng && ! gang.m.match(/^[mpsz]\d{4}$/)) {
118-
let s = gang.m[0], n = +gang.m.substr(-1)||5;
118+
let s = gang.m[0], n = +gang.m.slice(-1)||5;
119119
if (this.hulepai.find(p=> p == s+n)) this._neng_rong = false;
120120
}
121121
}

lib/shoupai.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module.exports = class Shoupai {
8484
}
8585

8686
shoupai._zimo = shoupai._zimo || zimo || null;
87-
shoupai._lizhi = bingpai.substr(-1) == '*';
87+
shoupai._lizhi = bingpai.slice(-1) == '*';
8888

8989
return shoupai;
9090
}
@@ -194,7 +194,7 @@ module.exports = class Shoupai {
194194
let s = p[0], n = +p[1];
195195
this.decrease(s, n);
196196
this._zimo = null;
197-
if (p.substr(-1) == '*') this._lizhi = true;
197+
if (p.slice(-1) == '*') this._lizhi = true;
198198
return this;
199199
}
200200

@@ -224,11 +224,11 @@ module.exports = class Shoupai {
224224
this._fulou.push(m);
225225
}
226226
else if (m.match(/\d{3}[\+\=\-]\d$/)) {
227-
let m1 = m.substr(0,5);
227+
let m1 = m.slice(0,5);
228228
let i = this._fulou.findIndex(m2 => m1 == m2);
229229
if (i < 0) throw new Error([this, m]);
230230
this._fulou[i] = m;
231-
this.decrease(s, m.substr(-1));
231+
this.decrease(s, m.slice(-1));
232232
}
233233
else throw new Error([this, m]);
234234
this._zimo = null;
@@ -381,7 +381,7 @@ module.exports = class Shoupai {
381381
else {
382382
if (this._lizhi) continue;
383383
for (let m of this._fulou) {
384-
if (m.replace(/0/g,'5').substr(0,4) == s+n+n+n) {
384+
if (m.replace(/0/g,'5').slice(0,4) == s+n+n+n) {
385385
if (n == 5 && bingpai[0] > 0) mianzi.push(m+0);
386386
else mianzi.push(m+n);
387387
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kobalab/majiang-core",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "麻雀基本ライブラリ",
55
"publishConfig": {
66
"access": "public"

0 commit comments

Comments
 (0)