From 3b763569ecd28e8bd3550bf6e9b4fecdb5f81f2f Mon Sep 17 00:00:00 2001 From: PZ157 <3619242020@qq.com> Date: Thu, 23 Nov 2023 11:48:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit filter: 数字则加减等量“手牌”再计算; 函数则剔除不符合条件的手牌计算 add: 卡牌或牌组,类似数字 --- game/game.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/game/game.js b/game/game.js index fe46763fe..37cb4ab73 100644 --- a/game/game.js +++ b/game/game.js @@ -28656,9 +28656,15 @@ new Promise(resolve=>{ } return false; } - needsToDiscard(num){ - if(typeof num!='number') num=0; - return Math.max(0,num+this.countCards('h',card=>!this.canIgnoreHandcard(card))-this.getHandcardLimit()); + needsToDiscard(filter,add){ + let cards=this.getCards('h',card=>!this.canIgnoreHandcard(card)),num=0; + if(get.itemtype(add)==='cards') cards.addArray(add); + else if(get.itemtype(add)==='card') cards.push(add); + if(typeof filter==='number') num=filter; + else if(typeof filter==='function') cards=cards.filter(card=>{ + return filter(card); + }); + return Math.max(0,num+cards.length-this.getHandcardLimit()); } distanceTo(target,method){ return get.distance(this,target,method);