From 00f540dc1cca08b4755962208e69fdbc12a23657 Mon Sep 17 00:00:00 2001 From: Satoshi Kobayashi Date: Thu, 24 Oct 2024 19:59:38 +0800 Subject: [PATCH] =?UTF-8?q?Majiang.Board=20=E3=81=8C=E9=85=8D=E7=89=8C?= =?UTF-8?q?=E3=81=AB=E3=83=89=E3=83=A9=E3=81=8C=E3=81=AA=E3=81=84=E3=83=BB?= =?UTF-8?q?=E3=83=89=E3=83=A9=E3=81=8C=E8=A4=87=E6=95=B0=E3=81=82=E3=82=8B?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=82=92=E5=87=A6=E7=90=86=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/board.js | 2 +- test/board.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/board.js b/lib/board.js index ea0b86f..4ffb076 100644 --- a/lib/board.js +++ b/lib/board.js @@ -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 || '_' } diff --git a/test/board.js b/test/board.js index c442ddc..488c0c6 100644 --- a/test/board.js +++ b/test/board.js @@ -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)', ()=>{