猜杀猜闪函数业务拓展
新增形参rvt: return value type 可选'count'(估算数量) 'odds'(估算有的概率,可能是布尔值) ‘bool'(默认猜有无)
This commit is contained in:
parent
6b2d351092
commit
e20fb88219
74
game/game.js
74
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'){
|
||||
|
|
Loading…
Reference in New Issue