Merge pull request #689 from PZ157/PR-Branch

杀ai
This commit is contained in:
Spmario233 2023-12-20 23:13:31 +08:00 committed by GitHub
commit f7495db4b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 67 deletions

View File

@ -123,31 +123,43 @@ 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={order:0},temp;
target.getCards('hs',i=>{
if(get.name(i)!=='sha' || ui.selected.cards.includes(i)) return false;
temp=get.order(i,target);
if(temp<effs.order) return false;
if(temp>effs.order) effs={order:temp};
effs[i.cardid]={
card:i,
target:null,
eff:0
};
});
delete effs.order;
for(let i in effs){
if(!lib.filter.filterCard(effs[i].card,target)) continue;
game.filterPlayer(current=>{
if(get.attitude(target,current)>=0 || !target.canUse(effs[i].card,current,null,true) || current.hasSkillTag('filterDamage',null,{
player:target,
card:shas[i],
card:effs[i].card,
jiu:true
})&&get.effect(current,shas[i],target)>0;
})) return false;
temp=get.effect(current,effs[i].card,target,player);
if(temp<=effs[i].eff) return false;
effs[i].target=current;
effs[i].eff=temp;
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[i].target) continue;
if(target.hasSkillTag('directHit_ai',true,{
target:effs[i].target,
card:i
},true) || usable===1&&(target.needsToDiscard()>Math.max(0,3-target.hp) || !effs[i].target.mayHaveShan(player,'use'))){
delete target._jiu_temp;
return 1;
}

View File

@ -252,10 +252,6 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},
canLink:function(player,target,card){
if(!target.isLinked()&&!player.hasSkill('wutiesuolian_skill')) return false;
if(target.mayHaveShan()&&!player.hasSkillTag('directHit_ai',true,{
target:target,
card:card,
},true)) return false;
if(player.hasSkill('jueqing')||player.hasSkill('gangzhi')||target.hasSkill('gangzhi')) return false;
return true;
},
@ -264,42 +260,87 @@ game.import('card',function(lib,game,ui,get,ai,_status){
value:[5,3,1],
},
order:function(item,player){
if(player.hasSkillTag('presha',true,null,true)) return 10;
if(game.hasNature(item,'linked')){
if(game.hasPlayer(function(current){
return current!=player&&current.isLinked()&&player.canUse(item,current,null,true)&&get.effect(current,item,player,player)>0&&lib.card.sha.ai.canLink(player,current,item);
})&&game.countPlayer(function(current){
return current.isLinked()&&get.damageEffect(current,player,player,get.nature(item))>0;
})>1) return 3.1;
return 3;
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 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;
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===nb.length){
if(used*(natures.indexOf(na[0])-natures.indexOf(nb[0]))>0) return res-0.15;
}
/*usev=player.getUseValue(i,true);
if(usev>0&&used*(uv-usev)>0) return res-0.15;*/
}
return 3.05;
return res;
},
result:{
target:function(player,target,card,isLink){
var eff=function(){
if(!isLink&&player.hasSkill('jiu')){
if(!target.hasSkillTag('filterDamage',null,{
player:player,
card:card,
jiu:true,
})){
if(get.attitude(player,target)>0){
return -7;
}
else{
return -4;
}
}
return -0.5;
target:(player,target,card,isLink)=>{
if(target._sha_result_temp) return -1.5;
target._sha_result_temp=true;
let basic=1,eff=-1.5,zhu=target.isZhu&&target.identityShown;
if(!target.hasSkillTag('filterDamage',null,{
player:player,
card:card,
jiu:player.hasSkill('jiu'),
})&&(player.hasSkill('jiu')||player.hasSkillTag('damageBonus',true,{
target:target,
card:card
}))){
if(target.hp<2) basic=5;
else if(target.hp===2) basic=3;
else basic=2;
}
else if(target.hp<2) basic*=3;
if(zhu) eff*=Math.max(1,9/target.hp/target.hp);
if(isLink){
let rate=_status.event.getTempCache('sha_result','mayShan');
if(rate&&rate.id===card.sha_ai_id) rate=rate.rate;
delete target._sha_result_temp;
if(typeof rate==='boolean'||typeof rate==='number'){
if(rate>=1) return eff;
return basic*eff*(1.3-0.9*rate);
}
return -1.5;
}();
if(!isLink&&target.mayHaveShan()&&!player.hasSkillTag('directHit_ai',true,{
delete _status.event._tempCache['sha_result']['mayShan'];
return basic*eff;
}
let mayShan;
if(player.hasSkillTag('directHit_ai',true,{
target:target,
card:card,
},true)) return eff/1.2;
return eff;
},true)||game.hasNature(card,'stab')&&target.countCards('he')<2&&!target.hasSkillTag('noh')) mayShan=false;
else{
let temp=target.getKnownCards(player);
if(temp.some(i=>{
let name=get.name(i,target);
if(name==='shan'||name==='hufu') return lib.filter.cardEnabled(i,target,'forceEnable');
return false;
})) mayShan=true;
else mayShan=1-Math.pow(0.7,(target.hasSkillTag('respondShan',true,'use',true)?1:0)+target.countCards('hs')-temp.length);
}
if(game.hasNature(card,'linked',player)){
if(!_status.sha_ai_id) _status.sha_ai_id=1;
else _status.sha_ai_id++;
card.sha_ai_id=_status.sha_ai_id;
_status.event.putTempCache('sha_result','mayShan',{
id:_status.sha_ai_id,
rate:mayShan
});
}
delete target._sha_result_temp;
if(mayShan>=1) return eff;
return basic*eff*(1.3-0.9*mayShan);
},
},
tag:{
@ -457,7 +498,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
if(target.hp>0){
if(!player.isPhaseUsing()) return 0;
let min = 7.2-4*player.hp/player.maxHp,
nd = player.needsToDiscard(-player.countCards('h',i=>!taos.includes(i)&&get.value(i)<min)),
nd = player.needsToDiscard(i=>taos.includes(i)||get.value(i)>=min),
keep = nd?0:2;
if(nd>2 || taos.length>1&&(nd>1||nd&&player.hp<1+taos.length) || target.identity==='zhu'&&(nd||target.hp<3)&&(mode==='identity'||mode==='versus'||mode==='chess') || !player.hasFriend()) return 2;
if(game.hasPlayer(current=>{
@ -1844,12 +1885,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)=>{
@ -1865,7 +1906,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
});

View File

@ -372,10 +372,21 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
},
ai:{
order:1,
order:function(item,player){
if(player.hasCard((i)=>{
return get.value(i)>Math.max(6,9-player.hp);
},'he')) return 1;
return 10;
},
result:{
player:1
},
nokeep:true,
skillTagFilter:function(player,tag,arg){
if(tag==='nokeep') return (!arg||arg&&arg.card&&get.name(arg.card)==='tao')&&player.isPhaseUsing()&&player.countSkill('dczhiheng')<1+player.getStorage('dczhiheng_hit').length&&player.hasCard((card)=>{
return get.name(card)!=='tao';
},'h');
},
threaten:1.55
},
},

View File

@ -5440,7 +5440,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
effect:{
player:(card,player,target)=>{
if(player.hasSkill('rewansha')&&target.hp<=1&&get.tag(card,'damage')) return [1,0,1.5,-1.5];
if(target&&player.hasSkill('rewansha')&&target.hp<=1&&get.tag(card,'damage')) return [1,0,1.5,-1.5];
}
}
}

View File

@ -5399,11 +5399,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){
effect:{
target:function(card,player,target){
if(player._jsrgzhenqiao_aiChecking) return;
if(target==player&&get.subtype(card)=='equip1'&&!player.getEquip(1)){
player._jsrgzhenqiao_aiChecking=true;
var eff=get.effect(target,card,player,player);
delete player._jsrgzhenqiao_aiChecking;
if(eff<3) return 'zerotarget';
if(target===player&&get.subtype(card)==='equip1'&&!player.getEquip(1)){
if(card.name!=='zhuge'||target.getCardUsable('sha')||!target.needsToDiscard()) return;
if(target.countCards('hs',i=>{
return get.name(i)==='sha'&&lib.filter.cardEnabled(i,target);
})>1) return 'zeroplayertarget';
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 KiB

After

Width:  |  Height:  |  Size: 534 KiB

View File

@ -13357,7 +13357,13 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
var target=targets.shift();
event.target=target;
source.line(target,'green');
target.chooseBool('是否响应'+get.translation(source)+'发起的【拉拢人心】?','将势力改为'+event.text).set('choice',Math.random()<=0.98);//反骨[doge]
target.chooseBool('是否响应'+get.translation(source)+'发起的【拉拢人心】?','将势力改为'+event.text).set('ai',_status.event.choice).set('choice',function(){
let fs=target.getFriends(true).length;
if(game.players.length<=2*fs) return false;
if(source.getFriends(true).length+fs>game.players.length/2) return true;
if(target.isDamaged()||target.countCards('h')<4) return false;
return true;
}());
'step 6'
if(result.bool){
target.chat('加入');