Merge pull request #431 from PZ157/PR-Branch

增加谋貂蝉【离间】ai
This commit is contained in:
Spmario233 2023-09-30 18:05:23 +08:00 committed by GitHub
commit 2f06282bea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 113 additions and 10 deletions

View File

@ -2108,8 +2108,14 @@ game.import('card',function(lib,game,ui,get,ai,_status){
audio:true,
prompt:'将两张手牌当杀使用或打出',
check:function(card){
if(card.name=='sha') return 0;
return 5-get.value(card)
let player=_status.event.player;
if(player.hasCard(function(card){
return get.name(card)=='sha';
})) return 0;
if(_status.event&&_status.event.name=='chooseToRespond'&&player.hp<3&&!player.countCards('hs',function(card){
return get.name(card)!='tao'&&get.name(card)!='jiu';
})) return (player.hp>1?10:8)-get.value(card);
return Math.max(5,8-0.7*player.hp)-get.value(card);
},
ai:{
respondSha:true,
@ -2144,10 +2150,9 @@ game.import('card',function(lib,game,ui,get,ai,_status){
next.set('ai',function(card){
var evt=_status.event.getTrigger();
if(get.attitude(evt.player,evt.target)<0){
if(evt.baseDamage+evt.extraDamage>=Math.min(2,evt.target.hp)){
return 8-get.value(card)
}
return 5-get.value(card)
if(player.needsToDiscard()) return 15-get.value(card);
if(evt.baseDamage+evt.extraDamage>=Math.min(2,evt.target.hp)) return 8-get.value(card);
return 5-get.value(card);
}
return -1;
});

View File

@ -768,9 +768,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
sblijian:{
audio:2,
enable:'phaseUse',
usable:1,
filter:function(event,player){
return game.countPlayer(current=>{
return !player.getStat('skill').sblijian&&game.countPlayer(current=>{
return current!=player;
})>1;
},
@ -784,6 +783,59 @@ game.import('character',function(lib,game,ui,get,ai,_status){
filterOk:function(){
return ui.selected.targets.length==ui.selected.cards.length+1;
},
check:function(card){
let player=get.owner(card),targets=_status.event.getTempCache('sblijian','targets');
if(!Array.isArray(targets)){
lib.skill.sblijian.selectTargetAi(_status.event,player);
targets=_status.event.getTempCache('sblijian','targets');
}
targets=Math.min(player.countCards('he')+1,targets.length);
if(ui.selected.cards.length<targets-1){
if(player.hasSkill('sbbiyue')) return 4*targets-get.value(card);
return 6+targets-get.value(card);
}
return 0;
},
selectTargetAi:function(event,player){
let id=[null,0],players=game.filterPlayer(current=>current!==player),res;
for(let i of players){
res=get.attitude(event.player,i);
if(res<id[1]) id=[i,res];
}
if(id[0]) id=id[0].identity;
else{
event.putTempCache('sblijian','targets',[]);
return;
}
let vp=ui.create.player().init('sunce'),target=[null,0];
vp.skills=[];
if(id.endsWith('zhu')||id.endsWith('Zhu')) id=id.slice(0,-1)+'ong';
vp.identity=id;
vp.showIdentity();
game.players.push(vp);
for(let i of players){
res=get.effect(i,{name:'juedou',isCard:true},vp,event.player)+get.effect(vp,{name:'juedou',isCard:true},i,event.player);
if(res>target[1]) target=[i,res];
}
game.players.remove(vp);
if(target[1]<=0){
event.putTempCache('sblijian','targets',[]);
return;
}
let targets=[],idx=-1;
do{
idx++;
targets.push(target.concat([get.sgn(get.attitude(player,target[0]))]));
players.remove(target[0]);
target[1]=0;
for(let i of players){
res=get.effect(i,{name:'juedou',isCard:true},targets[idx][0],event.player);
if(res>target[1]) target=[i,res];
}
}while(target[1]>0);
if(!player.hasSkill('sbbiyue')) targets=targets.filter(i=>i[2]!==0);
event.putTempCache('sblijian','targets',targets);
},
multiline:true,
content:function(){
var targetx=targets.slice().sortBySeat(target)[1];
@ -793,7 +845,30 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ai:{
threaten:3,
order:7,
result:{target:-1}
result:{
player:function(player,target){
if(!player.hasSkill('sbbiyue') return 0;
let targets=_status.event.getTempCache('sblijian','targets');
if(Array.isArray(targets)) for(let i=0;i<targets.length;i++){
if(target===targets[i][0]&&targets[i][2]===0) return 1;
}
return 0;
},
target:function(player,target){
let targets=_status.event.getTempCache('sblijian','targets');
if(Array.isArray(targets)) for(let i=0;i<targets.length;i++){
if(target===targets[i][0]){
if(targets[i][2]>0) return targets[i][1]/5;
return -targets[i][1];
}
}
if(ui.selected.targets.length){
let tars=ui.selected.targets.concat([target]);
return get.effect(target,{name:'juedou',isCard:true},tars[tars.length-2],target)+get.effect(tars[0],{name:'juedou',isCard:true},target,target);
}
return 0;
}
}
}
},
sbbiyue:{

View File

@ -8452,6 +8452,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
ai:{
result:{
order:10,
player:function(player,target){
if(player.countCards('hs',function(card){
return get.tag(card,'damage')&&player.canUse(card,target);
@ -8499,7 +8500,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
player:function(card,player,target){
if(target!=player.storage.yinju2) return;
if(card.name=='lebu') return;
return [0,0.5,0,0.5];
if(card.name!=='huogong'&&get.tag(card,'damage')&&target.isDamaged()) [1,0.6,0,2.4];
return [1,0.6,1,0.6];
},
},
},

View File

@ -11806,6 +11806,27 @@ game.import('character',function(lib,game,ui,get,ai,_status){
player.addSkill('zhafu_hf');
target.addMark('zhafu_hf',1);
},
ai:{
order:1,
result:{
player:function(player,target){
return Math.max(0,1+target.countCards('h')-game.countPlayer(current=>{
if(get.attitude(target,current)>0) return 0.3;
if(target.hasJudge('lebu')) return 0.6;
if(target.inRange(current)) return 1.5;
return 1;
}));
},
target:function(player,target){
return -Math.max(0,1+target.countCards('h')-game.countPlayer(current=>{
if(get.attitude(target,current)>0) return 0.3;
if(target.hasJudge('lebu')) return 0.6;
if(target.inRange(current)) return 1.5;
return 1;
}));
}
}
},
subSkill:{
hf:{
trigger:{