Merge pull request #628 from PZ157/PR-Branch

优化部分武将AI
This commit is contained in:
Spmario233 2023-11-13 19:06:25 +08:00 committed by GitHub
commit a39e9a7075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 21 deletions

View File

@ -1168,26 +1168,21 @@ game.import('card',function(lib,game,ui,get,ai,_status){
}
else{
var next=event.turn.chooseToRespond({name:'sha'});
if(event.shaRequired>1){
next.set('prompt2','共需打出'+event.shaRequired+'张杀')
}
if(event.shaRequired>1) next.set('prompt2','共需打出'+event.shaRequired+'张杀');
next.set('ai',function(card){
var event=_status.event;
var player=event.splayer;
var target=event.starget;
if(player.hasSkillTag('notricksource')) return 0;
if(target.hasSkillTag('notrick')) return 0;
let event=_status.event,player=event.splayer,target=event.starget;
if(player.hasSkillTag('notricksource')||target.hasSkillTag('notrick')) return 0;
if(event.shaRequired>1&&player.countCards('h','sha')<event.shaRequired) return 0;
if(event.player==target){
if(player.hasSkill('naman')) return -1;
if(get.attitude(target,player)<0||event.player.hp<=1&&get.damageEffect(target,player,event.player)<get.damageEffect(player,target,event.player)){
if(event.player===target){
if(_status.event.tdamage>=0||player.hasSkill('naman')) return -1;
if(get.attitude(target,player)<=0||event.player.hp<=1&&_status.event.tdamage<_status.event.pdamage){
return get.order(card);
}
return -1;
}
else{
if(target.hasSkill('naman')) return -1;
if(get.attitude(player,target)<0||event.player.hp<=1&&get.damageEffect(target,player,event.player)>get.damageEffect(player,target,event.player)){
if(_status.event.pdamage>=0||target.hasSkill('naman')) return -1;
if(get.attitude(player,target)<=0||event.player.hp<=1&&_status.event.tdamage>_status.event.pdamage){
return get.order(card);
}
return -1;
@ -1195,6 +1190,8 @@ game.import('card',function(lib,game,ui,get,ai,_status){
});
next.set('splayer',player);
next.set('starget',target);
next.set('pdamage',get.damageEffect(player,target,event.turn));
next.set('tdamage',get.damageEffect(target,player,event.turn));
next.set('shaRequired',event.shaRequired);
next.autochoose=lib.filter.autoRespondSha;
if(event.turn==target){

View File

@ -1035,7 +1035,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ai:{
effect:{
target:function(card,player,target){
let hs=player.getCards('h',i=>i!==card&&(!card.cards||!card.cards.contains(i))),num=player.getCardUsable('sha');
let hs=player.getCards('h',i=>i!==card&&(!card.cards||!card.cards.includes(i))),num=player.getCardUsable('sha');
if(card.name!=='sha'&&card.name!=='juedou'||hs.length<target.countCards('h')) return 1;
if(game.hasPlayer2(function(current){
return current.getHistory('useCard',function(evt){
@ -1044,6 +1044,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
})) return 1;
if(card.name==='sha') num--;
hs=hs.filter(i=>{
if(!player.canUse(i,target)) return false;
if(i.name==='juedou') return true;
if(num&&i.name==='sha'){
num--;

View File

@ -1537,6 +1537,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
content:function(){
player.draw(trigger.getl(player).cards2.length);
},
ai:{
effect:{
target:(card,player,target)=>{
if((get.tag(card,'lose')||get.tag(card,'discard'))&&target.getHistory('damage').length&&!target.hasHistory('useSkill',evt=>evt.skill=='dczhengxu_lose')) return [1,1];
}
}
}
},
damage:{
@ -1555,10 +1562,24 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
ai:{
effect:{
target:function(card,player,target){
if(player.hasSkillTag('jueqing',false,target)) return;
if(target.hasHistory('useSkill',evt=>evt.skill=='dczhengxu_damage')) return;
if(get.tag(card,'damage')) return 0.6;
target:(card,player,target)=>{
if(player.hasSkillTag('jueqing',false,target)||!get.tag(card,'damage')) return;
if(target.hasHistory('useSkill',evt=>evt.skill=='dczhengxu_damage')||!target.hasHistory('lose',evt=>evt.cards2&&evt.cards2.length)) return;
if(get.attitude(player,target)>=0) return 'zeroplayertarget';
let num=0,shas=player.getCardUsable('sha'),hs=player.getCards('hs',i=>{
if(i===card||card.cards&&card.cards.includes(i)||!get.tag(i,'damage')||!player.canUse(i,target)) return false;
if(get.name(i)==='sha'){
num++;
return false;
}
return true;
});
if(card.name==='sha') shas--;
num=Math.min(num,shas);
num+=hs.length;
if(!num) return 'zeroplayertarget';
num=1-2/3/num;
return [num,0,num,0];
}
}
}

View File

@ -5146,11 +5146,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
ai:{
effect:{
target:function(card,player,target){
if(player==target) return;
target:(card,player,target)=>{
if(player===target) return;
if(game.hasPlayer2(current=>{
return current.hasHistory('useCard',evt=>evt.card.name==card.name&&evt.targets&&evt.targets.contains(player));
})) return 'zerotarget';
})) return 'zeroplayertarget';
}
}
}