函数修改
filter: 数字则加减等量“手牌”再计算; 函数则剔除不符合条件的手牌计算 add: 卡牌或牌组,类似数字
This commit is contained in:
parent
c5dd53b389
commit
3b763569ec
12
game/game.js
12
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);
|
||||
|
|
Loading…
Reference in New Issue