Skip to content

Commit

Permalink
Majiang.Board が配牌にドラがない・ドラが複数ある場合を処理できるよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kobalab committed Oct 24, 2024
1 parent 29accba commit 00f540d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Majiang = {
class Shan {
constructor(baopai) {
this.paishu = 136 - 13 * 4 - 14;
this.baopai = [ baopai ];
this.baopai = [].concat(baopai||[]);
this.fubaopai;
}
zimo(p) { this.paishu--; return p || '_' }
Expand Down
10 changes: 10 additions & 0 deletions test/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ suite('Majiang.Board', ()=>{
assert.equal(board.he.map(he=>he._pai.length)
.reduce((x,y)=>x+y), 0));
test('手番が初期化されること', ()=> assert.equal(board.lunban, -1));
test('ドラが未確定でも処理できること', ()=>{
qipai.baopai = '';
board.qipai(qipai);
assert.equal(board.shan.baopai.length, 0);
});
test('ドラが複数でも処理できること', ()=>{
qipai.baopai = ['s1','p9'];
board.qipai(qipai);
assert.deepEqual(board.shan.baopai, qipai.baopai);
});
});

suite('zimo(zimo)', ()=>{
Expand Down

0 comments on commit 00f540d

Please sign in to comment.