From e20fb882196678ffdba9b66242153792803f22ff Mon Sep 17 00:00:00 2001 From: PZ157 <3619242020@qq.com> Date: Mon, 4 Dec 2023 17:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8C=9C=E6=9D=80=E7=8C=9C=E9=97=AA=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=9A=E5=8A=A1=E6=8B=93=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增形参rvt: return value type 可选'count'(估算数量) 'odds'(估算有的概率,可能是布尔值) ‘bool'(默认猜有无) --- game/game.js | 74 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/game/game.js b/game/game.js index 65f37e630..8eec61474 100644 --- a/game/game.js +++ b/game/game.js @@ -28790,20 +28790,20 @@ new Promise(resolve=>{ if(this.hasSkillTag('respondShan',true,null,true)) return true; return this.hasUsableCard('shan'); } - mayHaveSha(viewer,type,ignore){ - if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondSha',true,type,true)) return true; + mayHaveSha(viewer,type,ignore,rvt){ + //rvt: return value type 'count', 'odds', 'bool'(default) + let count=0; + if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondSha',true,type,true)){ + if(rvt==='count') count++; + else return true; + } if(get.itemtype(viewer)!=='player') viewer=_status.event.player; let cards,selected=get.copy(ui.selected.cards); if(get.itemtype(ignore)==='cards') selected.addArray(ignore); else if(get.itemtype(ignore)==='card') selected.add(ignore); - /*if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h'); - else cards=this.getShownCards();*/ - if(this === viewer || get.itemtype(viewer) == 'player'){ - cards = this.getKnownCards(viewer); - }else{ - cards = this.getShownCards(); - } - if(cards.some(card=>{ + if(this === viewer || get.itemtype(viewer) == 'player') cards = this.getKnownCards(viewer); + else cards = this.getShownCards(); + count+=cards.filter(card=>{ if(selected.includes(card)) return false; let name=get.name(card,this); if(name=='sha'||name=='hufu'||name=='yuchanqian'){ @@ -28812,25 +28812,36 @@ new Promise(resolve=>{ return true; } return false; - })) return true; + }).length; + if(count&&rvt!=='count') return true; let hs=this.getCards('hs').filter(i=>!cards.includes(i)&&!selected.includes(i)).length; - if(hs===0) return false; - return Math.pow(hs+(this.isPhaseUsing()?6:4),2)>100*_status.event.getRand('mayHaveSha'); + if(!hs){ + if(rvt==='count') return count; + return false; + } + if(rvt==='count'){ + if(this.isPhaseUsing()) return count+hs/4; + return count+hs/4.8; + } + if(this.isPhaseUsing()) count+=Math.pow(2+hs,2)/40; + else count+=-1.5*Math.log(1-hs/10); + if(rvt==='odds') return Math.min(1,count); + return count>_status.event.getRand('mayHaveSha'+hs+this.playerid); } - mayHaveShan(viewer,type,ignore){ - if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondShan',true,type,true)) return true; + mayHaveShan(viewer,type,ignore,rvt){ + //rvt: return value type 'count', 'odds', 'bool'(default) + let count=0; + if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondShan',true,type,true)){ + if(rvt==='count') count++; + else return true; + } if(get.itemtype(viewer)!=='player') viewer=_status.event.player; let cards,selected=get.copy(ui.selected.cards); if(get.itemtype(ignore)==='cards') selected.addArray(ignore); else if(get.itemtype(ignore)==='card') selected.add(ignore); - /*if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h'); - else cards=this.getShownCards();*/ - if(this === viewer || get.itemtype(viewer) == 'player'){ - cards = this.getKnownCards(viewer); - }else{ - cards = this.getShownCards(); - } - if(cards.some(card=>{ + if(this === viewer || get.itemtype(viewer) == 'player') cards = this.getKnownCards(viewer); + else cards = this.getShownCards(); + count+=cards.filter(card=>{ if(selected.includes(card)) return false; let name=get.name(card,this); if(name==='shan'||name==='hufu'){ @@ -28839,10 +28850,21 @@ new Promise(resolve=>{ return true; } return false; - })) return true; + }).length; + if(count&&rvt!=='count') return true; let hs=this.getCards('hs').filter(i=>!cards.includes(i)&&!selected.includes(i)).length; - if(hs===0) return false; - return Math.pow(hs+(this.isPhaseUsing()?3:5),2)>100*_status.event.getRand('mayHaveShan'); + if(!hs){ + if(rvt==='count') return count; + return false; + } + if(rvt==='count'){ + if(this.isPhaseUsing()) return count+hs/6; + return count+hs/3.5; + } + if(this.isPhaseUsing()) count+=-1.5*Math.log(1-hs/10); + else count+=2*hs/(5+hs); + if(rvt==='odds') return Math.min(1,count); + return count>_status.event.getRand('mayHaveShan'+hs+this.playerid); } hasCard(name,position){ if(typeof name=='function'){