Merge pull request #668 from PZ157/PR-Branch

函数修改、ai优化
This commit is contained in:
Spmario233 2023-11-24 00:32:15 +08:00 committed by GitHub
commit e05c9d2753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 23 deletions

View File

@ -474,12 +474,13 @@ game.import('card',function(lib,game,ui,get,ai,_status){
return;
}
else target.chooseControl('discard_card','take_damage',function(event,player){
if(get.damageEffect(player,event.player,player,'thunder')>=0){
return 'take_damage';
}
if(player.hp>=3&&player.countCards('e')>=2){
return 'take_damage';
}
let eff=get.damageEffect(player,event.player,player,'thunder');
if(eff>0) return 'take_damage';
if(player.hasSkillTag('noe')) return 'discard_card';
if(!eff) return 'take_damage';
if(player.isDamaged()&&player.hasCard((card)=>get.name(card)=='baiyin'&&get.recoverEffect(player,player,_status.event.player)>0,'e')) return 'discard_card';
if(player.hasCard((card)=>get.value(card,player)<=0,'e')&&!player.hasCard((card)=>get.value(card,player)>Math.max(7,12-player.hp),'e')) return 'discard_card';
if(player.hp>2&&player.countCards('e')>2||player.hp>1&&player.countCards('e')>3) return 'take_damage';
return 'discard_card';
}).set('prompt','水淹七军').set('prompt2','请选择一项:⒈弃置装备区里的所有牌;⒉受到'+get.translation(player)+'造成的1点雷电伤害。');
'step 1'
@ -534,12 +535,14 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},
result:{
target:function(player,target,card,isLink){
if(isLink) return -1.5;
var es=target.getCards('e');
if(!es.length) return -1.5;
var val=0;
for(var i of es) val+=get.value(i,target);
return -Math.min(1.5,val/5);
let es=target.getCards('e'), eff=2*get.sgn(get.damageEffect(target,player,target,'thunder'));
if(isLink || !es.length) return eff;
let val=0;
for(let i of es){
if(i.name=='baiyin'&&target.isDamaged()&&get.recoverEffect(target)) val+=6;
else val-=get.value(i,target);
}
return Math.max(eff,0.15*val);
}
}
}

View File

@ -227,18 +227,18 @@ game.import('card',function(lib,game,ui,get,ai,_status){
var base=0,hit=false;
if(get.cardtag(card,'yingbian_hit')){
hit=true;
if(targets.filter(function(target){
return target.hasShan()&&get.attitude(viewer,target)<0&&get.damageEffect(target,player,viewer,get.nature(card))>0;
if(targets.some(target=>{
return target.mayHaveShan(viewer)&&get.attitude(viewer,target)<0&&get.damageEffect(target,player,viewer,get.natureList(card))>0;
})) base+=5;
}
if(get.cardtag(card,'yingbian_all')){
if(get.cardtag(card,'yingbian_add')){
if(game.hasPlayer(function(current){
return !targets.contains(current)&&lib.filter.targetEnabled2(card,player,current)&&get.effect(current,card,player,player)>0;
})) base+=5;
}
if(get.cardtag(card,'yingbian_damage')){
if(targets.filter(function(target){
return get.attitude(player,target)<0&&(hit||!target.mayHaveShan()||player.hasSkillTag('directHit_ai',true,{
if(targets.some(target=>{
return get.attitude(player,target)<0&&(hit||!target.mayHaveShan(viewer)||player.hasSkillTag('directHit_ai',true,{
target:target,
card:card,
},true))&&!target.hasSkillTag('filterDamage',null,{

View File

@ -9860,7 +9860,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var target=trigger.player;
event.target=target;
if(player.storage.twzhengjian){
player.chooseBool('征建:是否对'+get.translation(target)+'造成1点伤害').set('ai',()=>_status.event.goon).set('goon',get.damageEffect(target,player,player)>0);
player.chooseBool('征建:是否对'+get.translation(target)+'造成1点伤害').set('ai',()=>_status.event.goon).set('goon',get.damageEffect(target,player,_status.event.player)>0);
}
else{
target.chooseCard('he',true,'交给'+get.translation(player)+'一张牌');
@ -9872,7 +9872,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
else target.damage();
}
player.chooseBool('是否变更【征建】的效果?');
player.chooseBool('是否变更【征建】的效果?').set('ai',()=>Math.random()>0.5);
'step 2'
if(result.bool){
player.removeSkill('twzhengjian_eff0');
@ -9908,7 +9908,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var target=trigger.player;
event.target=target;
if(player.storage.twzhengjian){
player.chooseBool('征建:是否对'+get.translation(target)+'造成1点伤害');
player.chooseBool('征建:是否对'+get.translation(target)+'造成1点伤害').set('ai',()=>_status.event.goon).set('goon',get.damageEffect(target,player,_status.event.player)>0);
}
else{
target.chooseCard('he',true,'交给'+get.translation(player)+'一张牌');

View File

@ -28712,9 +28712,15 @@ new Promise(resolve=>{
}
return false;
}
needsToDiscard(num){
if(typeof num!='number') num=0;
return Math.max(0,num+this.countCards('h',card=>!this.canIgnoreHandcard(card))-this.getHandcardLimit());
needsToDiscard(filter,add){
let cards=this.getCards('h',card=>!this.canIgnoreHandcard(card)),num=0;
if(get.itemtype(add)==='cards') cards.addArray(add);
else if(get.itemtype(add)==='card') cards.push(add);
if(typeof filter==='number') num=filter;
else if(typeof filter==='function') cards=cards.filter(card=>{
return filter(card);
});
return Math.max(0,num+cards.length-this.getHandcardLimit());
}
distanceTo(target,method){
return get.distance(this,target,method);