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

View File

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

View File

@ -1537,6 +1537,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}, },
content:function(){ content:function(){
player.draw(trigger.getl(player).cards2.length); 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:{ damage:{
@ -1555,10 +1562,24 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}, },
ai:{ ai:{
effect:{ effect:{
target:function(card,player,target){ target:(card,player,target)=>{
if(player.hasSkillTag('jueqing',false,target)) return; if(player.hasSkillTag('jueqing',false,target)||!get.tag(card,'damage')) return;
if(target.hasHistory('useSkill',evt=>evt.skill=='dczhengxu_damage')) return; if(target.hasHistory('useSkill',evt=>evt.skill=='dczhengxu_damage')||!target.hasHistory('lose',evt=>evt.cards2&&evt.cards2.length)) return;
if(get.tag(card,'damage')) return 0.6; 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:{ ai:{
effect:{ effect:{
target:function(card,player,target){ target:(card,player,target)=>{
if(player==target) return; if(player===target) return;
if(game.hasPlayer2(current=>{ if(game.hasPlayer2(current=>{
return current.hasHistory('useCard',evt=>evt.card.name==card.name&&evt.targets&&evt.targets.contains(player)); return current.hasHistory('useCard',evt=>evt.card.name==card.name&&evt.targets&&evt.targets.contains(player));
})) return 'zerotarget'; })) return 'zeroplayertarget';
} }
} }
} }