修复addExtraTarget的ai问题
This commit is contained in:
parent
4776f22f4d
commit
11cdf9c601
28
card/sp.js
28
card/sp.js
|
@ -268,10 +268,10 @@ game.import('card',function(lib,game,ui,get,ai,_status){
|
|||
multitarget:true,
|
||||
targetprompt:['给一张牌','得两张牌'],
|
||||
filterTarget:function(card,player,target){
|
||||
return target!=player;
|
||||
return target!==player;
|
||||
},
|
||||
filterAddedTarget:function(card,player,target){
|
||||
return target!=player;
|
||||
filterAddedTarget:function(card,player,target,preTarget){
|
||||
return target!==preTarget&&target!==player;
|
||||
},
|
||||
content:function(){
|
||||
'step 0'
|
||||
|
@ -313,21 +313,17 @@ game.import('card',function(lib,game,ui,get,ai,_status){
|
|||
},
|
||||
result:{
|
||||
target:function(player,target){
|
||||
var ok=false;
|
||||
var hs=player.getCards('h');
|
||||
if(hs.length<=1) return 0;
|
||||
for(var i=0;i<hs.length;i++){
|
||||
if(get.value(hs[i])<=5){
|
||||
ok=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!ok) return 0;
|
||||
if(ui.selected.targets.length==1){
|
||||
if(target.hasSkillTag('nogain')) return 0;
|
||||
let hs=player.getCards('h');
|
||||
if(hs.length<=1 || !hs.some(i=>{
|
||||
return get.value(hs[i])<5.5;
|
||||
})) return 0;
|
||||
let targets=get.copy(ui.selected.targets);
|
||||
if(_status.event.preTarget) targets.add(_status.event.preTarget);
|
||||
if(targets.length){
|
||||
if(target.hasSkillTag('nogain')) return 0.01;
|
||||
return 2;
|
||||
}
|
||||
if(target.countCards('he')==0) return 0;
|
||||
if(!target.countCards('he')) return 0;
|
||||
if(player.hasFriend()) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1838,23 +1838,39 @@ game.import('card',function(lib,game,ui,get,ai,_status){
|
|||
useful:1,
|
||||
},
|
||||
result:{
|
||||
target:function(player,target){
|
||||
if(ui.selected.targets.length){
|
||||
const preTarget=ui.selected.targets.lastItem;
|
||||
const eff=get.effect(target,{name:'sha'},preTarget,player);
|
||||
return Math.sign(eff)*get.sgnAttitude(player,target);
|
||||
player:(player,target)=>{
|
||||
if(!target.hasSkillTag('noe')&&get.attitude(player,target)>0) return 0;
|
||||
return (player.hasSkillTag('noe')?0.32:0.15)*target.getEquips(1).reduce((num,i)=>{
|
||||
return num+get.value(i,player);
|
||||
},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);
|
||||
}
|
||||
let arms=(target.hasSkillTag('noe')?0.32:-0.15)*target.getEquips(1).reduce((num,i)=>{
|
||||
return num+get.value(i,target);
|
||||
},0);
|
||||
if(!target.mayHaveSha(player,'use')) return arms;
|
||||
let sha=game.filterPlayer(get.info({name:'jiedao'}).filterAddedTarget),addTar=null;
|
||||
sha=sha.reduce((num,current)=>{
|
||||
let eff=get.effect(current,{name:'sha'},target,player);
|
||||
if(eff<=num) return num;
|
||||
addTar=current;
|
||||
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);
|
||||
}
|
||||
const filter=get.info({name:'jiedao'}).filterAddedTarget;
|
||||
if(game.hasPlayer(current=>{
|
||||
return filter(null,null,current,target)&&get.effect(current,{name:'sha'},target,player)>=0;
|
||||
})) return -1;
|
||||
if(target.mayHaveSha(player,'use')) return 0.25;
|
||||
return -1;
|
||||
},
|
||||
player:function(player){
|
||||
if(player.getCards('he',{subtype:'equip1'}).length) return 0;
|
||||
return 1.25;
|
||||
},
|
||||
},
|
||||
tag:{
|
||||
gain:1,
|
||||
|
|
|
@ -14497,6 +14497,7 @@ new Promise(resolve=>{
|
|||
},true);
|
||||
next.set('_get_card',card);
|
||||
next.set('preTarget',targets[num]);
|
||||
next.set('ai',target=>get.effect(target,get.card(),player,_status.event.player));
|
||||
}
|
||||
else{
|
||||
event.addedTargets[num]=false;
|
||||
|
|
Loading…
Reference in New Issue