大幅调整杀order和酒result,bug修复

杀的order时间复杂度降下来了,基本可以避免用一卡一的情况了;
同时也降低了酒的result时间复杂度
This commit is contained in:
PZ157 2023-12-02 15:53:47 +08:00
parent d51551f734
commit b9d27a128a
2 changed files with 65 additions and 34 deletions

View File

@ -123,34 +123,58 @@ game.import('card',function(lib,game,ui,get,ai,_status){
return 0;
},
result:{
target:(player,target)=>{
target:(player,target,card)=>{
if(target&&target.isDying()) return 2;
if(!target || target._jiu_temp || !target.isPhaseUsing()) return 0;
if(!target.getCardUsable('sha') || lib.config.mode==='stone'&&!player.isMin()&&player.getActCount()+1>=player.actcount) return 0;
let shas = player.getCards('hs',card=>get.name(card)==='sha'&&!ui.selected.cards.includes(card)), card;
if(!shas.length || !target.hasSha() || shas.length>1&&(target.getCardUsable('sha')>1 || target.countCards('hs','zhuge'))) return 0;
target._jiu_temp = true;
shas.sort((a,b)=>get.order(b)-get.order(a));
for(let i=0; i<shas.length; i++){
let tars = [];
if(lib.filter.filterCard(shas[i],target)) tars = game.filterPlayer(current=>{
return get.attitude(target,current)<0&&target.canUse(shas[i],current,null,true)&&!current.hasSkillTag('filterDamage',null,{
let usable=target.getCardUsable('sha');
if(!usable || lib.config.mode==='stone'&&!player.isMin()&&player.getActCount()+1>=player.actcount || !target.mayHaveSha(player,'use',card)) return 0;
let effs=_status.event.getTempCache('jiu_result','effs');
if(effs&&effs[card.cardid]){
for(let i in effs){
if(effs[i].target&&effs[i].target.isIn()&&effs[i].eff>0) return 1;
}
return 0;
}
effs={};
let shas=target.getCards('hs',i=>{
if(get.name(i)!=='sha' || ui.selected.cards.includes(i)) return false;
effs[i.cardid]={
target:null,
eff:0
};
return true;
}),eff,id;
for(let i of shas){
id=i.cardid;
if(!lib.filter.filterCard(i,target)) continue;
game.filterPlayer(current=>{
if(get.attitude(target,current)>=0 || !target.canUse(i,current,null,true) || current.hasSkillTag('filterDamage',null,{
player:target,
card:shas[i],
card:i,
jiu:true
})&&get.effect(current,shas[i],target)>0;
})) return false;
eff=get.effect(current,i,target,player);
if(eff<=effs[id].eff) return false;
effs[id].target=current;
effs[id].eff=eff;
return false;
});
if(!tars.length) continue;
tars.sort((a,b)=>{
return get.effect(b,shas[i],target)-get.effect(a,shas[i],target);
});
if(!tars[0].mayHaveShan(player,'use') || target.hasSkillTag('directHit_ai',true,{
target:tars[0],
card:shas[i]
},true) || target.needsToDiscard()>Math.max(0,3-target.hp)){
if(effs[id].target&&(target.hasSkillTag('directHit_ai',true,{
target:effs[id].target,
card:i
},true) || target.needsToDiscard()>Math.max(0,3-target.hp) || !effs[id].target.mayHaveShan(player,'use'))){
if(card.cardid){
effs[card.cardid]={target:null};
_status.event.putTempCache('jiu_result','effs',effs);
}
delete target._jiu_temp;
return 1;
}
delete effs[id];
}
if(card.cardid){
effs[card.cardid]={target:null};
_status.event.putTempCache('jiu_result','effs',effs);
}
delete target._jiu_temp;
return 0;

View File

@ -263,23 +263,25 @@ game.import('card',function(lib,game,ui,get,ai,_status){
let res=3.2;
if(player.hasSkillTag('presha',true,null,true)) res=10;
if(get.itemtype(player)!=='player') return res;
let uv=player.getUseValue(item,true);
if(uv<=0) return res;
/*let uv=player.getUseValue(item,true);
if(uv<=0) return res;*/
let ignore=get.copy(ui.selected.cards),used=player.getCardUsable('sha')-1.5,ph=player.getCards('hs');
ignore.add(item);
if(typeof item==='object'&&item.cards) ignore.addArray(item.cards);
let na=get.natureList(item),number=get.number(item),natures=['thunder','fire','ice','kami'],nb;
for(let i of ph){
if(ignore.includes(i)||get.name(i)!=='sha'||!lib.filter.cardEnabled(i,player)) continue;
let usev=player.getUseValue(i,true);
if(usev<=0||used*(usev-uv)>0) continue;
if(used*(uv-usev)!==0) return res-0.15;
let na=get.natureList(uv),nb=get.natureList(usev);
nb=get.natureList(i);
if(na.length===nb.length&&(!na.length||na[0]===nb[0])){
if(number>get.number(i)) return res-0.15;
continue;
}
if(used*(na.length-nb.length)>0) return res-0.15;
if(na.length&&na.length===nb.length&&na[0]!==nb[0]){
let natures=['thunder','fire','ice','kami'];
if(na.length===nb.length){
if(used*(natures.indexOf(na[0])-natures.indexOf(nb[0]))>0) return res-0.15;
}
if(get.number(item)>get.number(i)) return res-0.15;
/*usev=player.getUseValue(i,true);
if(usev>0&&used*(uv-usev)>0) return res-0.15;*/
}
return res;
},
@ -304,6 +306,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
if(zhu) eff*=Math.max(1,9/target.hp/target.hp);
if(isLink){
let rate=_status.event.getTempCache('sha_result','mayShan');
if(rate&&rate.card===card) rate=rate.rate;
delete target._sha_result_temp;
if(typeof rate==='boolean'||typeof rate==='number'){
if(!rate) return basic*eff*1.3;
@ -326,7 +329,10 @@ game.import('card',function(lib,game,ui,get,ai,_status){
})) mayShan=true;
else mayShan=1-Math.pow(0.7,(target.hasSkillTag('respondShan',true,'use',true)?1:0)+target.countCards('hs')-temp.length);
}
_status.event.putTempCache('sha_result','mayShan',mayShan);
_status.event.putTempCache('sha_result','mayShan',{
card:card,
rate:mayShan
});
delete target._sha_result_temp;
if(!mayShan) return basic*eff;
if(mayShan>=1) return eff;
@ -1875,12 +1881,12 @@ game.import('card',function(lib,game,ui,get,ai,_status){
return num+get.value(i,player);
},0);
},
target:(player,target)=>{
target:(player,target,card)=>{
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;
let preTarget=targets.lastItem,pre=_status.event.getTempCache('jiedao_result',preTarget.playerid);
if(pre&&pre.card===card&&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)=>{
@ -1896,7 +1902,8 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},-100);
if(!addTar) return arms;
sha/=get.attitude(player,target);
_status.event.putTempCache('jiedao_result',target,{
_status.event.putTempCache('jiedao_result',target.playerid,{
card:card,
target:addTar,
eff:sha
});