修复addExtraTarget的ai问题

This commit is contained in:
PZ157 2023-11-24 17:17:49 +08:00
parent 4776f22f4d
commit 11cdf9c601
3 changed files with 45 additions and 32 deletions

View File

@ -268,10 +268,10 @@ game.import('card',function(lib,game,ui,get,ai,_status){
multitarget:true, multitarget:true,
targetprompt:['给一张牌','得两张牌'], targetprompt:['给一张牌','得两张牌'],
filterTarget:function(card,player,target){ filterTarget:function(card,player,target){
return target!=player; return target!==player;
}, },
filterAddedTarget:function(card,player,target){ filterAddedTarget:function(card,player,target,preTarget){
return target!=player; return target!==preTarget&&target!==player;
}, },
content:function(){ content:function(){
'step 0' 'step 0'
@ -313,21 +313,17 @@ game.import('card',function(lib,game,ui,get,ai,_status){
}, },
result:{ result:{
target:function(player,target){ target:function(player,target){
var ok=false; let hs=player.getCards('h');
var hs=player.getCards('h'); if(hs.length<=1 || !hs.some(i=>{
if(hs.length<=1) return 0; return get.value(hs[i])<5.5;
for(var i=0;i<hs.length;i++){ })) return 0;
if(get.value(hs[i])<=5){ let targets=get.copy(ui.selected.targets);
ok=true; if(_status.event.preTarget) targets.add(_status.event.preTarget);
break; if(targets.length){
} if(target.hasSkillTag('nogain')) return 0.01;
}
if(!ok) return 0;
if(ui.selected.targets.length==1){
if(target.hasSkillTag('nogain')) return 0;
return 2; return 2;
} }
if(target.countCards('he')==0) return 0; if(!target.countCards('he')) return 0;
if(player.hasFriend()) return -1; if(player.hasFriend()) return -1;
return 0; return 0;
} }

View File

@ -1838,23 +1838,39 @@ game.import('card',function(lib,game,ui,get,ai,_status){
useful:1, useful:1,
}, },
result:{ result:{
target:function(player,target){ player:(player,target)=>{
if(ui.selected.targets.length){ if(!target.hasSkillTag('noe')&&get.attitude(player,target)>0) return 0;
const preTarget=ui.selected.targets.lastItem; return (player.hasSkillTag('noe')?0.32:0.15)*target.getEquips(1).reduce((num,i)=>{
const eff=get.effect(target,{name:'sha'},preTarget,player); return num+get.value(i,player);
return Math.sign(eff)*get.sgnAttitude(player,target); },0);
},
target:(player,target)=>{
let targets=get.copy(ui.selected.targets);
if(_status.event.preTarget) targets.add(_status.event.preTarget);
if(targets.length){
let preTarget=targets.lastItem,pre=_status.event.getTempCache('jiedao_result',preTarget);
if(pre&&pre.target.isIn()) return target===pre.target?pre.eff:0;
return get.effect(target,{name:'sha'},preTarget,player)/get.attitude(player,target);
} }
const filter=get.info({name:'jiedao'}).filterAddedTarget; let arms=(target.hasSkillTag('noe')?0.32:-0.15)*target.getEquips(1).reduce((num,i)=>{
if(game.hasPlayer(current=>{ return num+get.value(i,target);
return filter(null,null,current,target)&&get.effect(current,{name:'sha'},target,player)>=0; },0);
})) return -1; if(!target.mayHaveSha(player,'use')) return arms;
if(target.mayHaveSha(player,'use')) return 0.25; let sha=game.filterPlayer(get.info({name:'jiedao'}).filterAddedTarget),addTar=null;
return -1; sha=sha.reduce((num,current)=>{
}, let eff=get.effect(current,{name:'sha'},target,player);
player:function(player){ if(eff<=num) return num;
if(player.getCards('he',{subtype:'equip1'}).length) return 0; addTar=current;
return 1.25; return eff;
}, },-100);
if(!addTar) return arms;
sha/=get.attitude(player,target);
_status.event.putTempCache('jiedao_result',target,{
target:addTar,
eff:sha
});
return Math.max(arms,sha);
}
}, },
tag:{ tag:{
gain:1, gain:1,

View File

@ -14497,6 +14497,7 @@ new Promise(resolve=>{
},true); },true);
next.set('_get_card',card); next.set('_get_card',card);
next.set('preTarget',targets[num]); next.set('preTarget',targets[num]);
next.set('ai',target=>get.effect(target,get.card(),player,_status.event.player));
} }
else{ else{
event.addedTargets[num]=false; event.addedTargets[num]=false;