优化get.skillRank函数,优化〖托孤〗AI,增加〖地法〗AI;其他bug修复

This commit is contained in:
copcap 2023-07-24 04:31:23 +08:00
parent 6f0c119217
commit 5d1a8e050f
7 changed files with 88 additions and 20 deletions

View File

@ -624,6 +624,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
} }
player.gain(cards,'gain2'); player.gain(cards,'gain2');
} }
},
ai:{
combo:'yizhao',
} }
}, },
sanshou:{ sanshou:{

View File

@ -773,7 +773,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ai:{ ai:{
effect:{ effect:{
player:function(card,player,target){ player:function(card,player,target){
if(player!=target&&target&&target.group=='qun') return [1,0.2]; if(player!=target&&target&&target.group=='qun'&&card.name!='tao') return [1,0.1];
}, },
}, },
} }

View File

@ -9994,6 +9994,24 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}).length>0; }).length>0;
}, },
logTarget:'player', logTarget:'player',
check:function(event,player){
var list=event.player.getStockSkills('仲村由理','天下第一').filter(function(skill){
var info=get.info(skill);
return info&&!info.juexingji&&!info.hiddenSkill&&!info.zhuSkill&&!info.charlotte&&!info.limited&&!info.dutySkill;
});
var negSkill=list.some(function(skill){
return get.skillRank(skill,'inout')<=0;
});
var att=get.sgnAttitude(event.player,player);
if(!player.storage.retuogu){
if(negSkill&&att<0) return false;
return true;
}
list.sort(function(a,b){
return att*(get.skillRank(b,'inout')-get.skillRank(a,'inout'));
})[0];
return get.skillRank(list[0],'inout')>=get.skillRank(player.storage.retuogu,'inout');
},
content:function(){ content:function(){
'step 0' 'step 0'
var list=trigger.player.getStockSkills('仲村由理','天下第一').filter(function(skill){ var list=trigger.player.getStockSkills('仲村由理','天下第一').filter(function(skill){
@ -10002,7 +10020,16 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}); });
if(list.length==1) event._result={control:list[0]}; if(list.length==1) event._result={control:list[0]};
else trigger.player.chooseControl(list).set('prompt','选择令'+get.translation(player)+'获得一个技能').set('forceDie',true).set('ai',function(){ else trigger.player.chooseControl(list).set('prompt','选择令'+get.translation(player)+'获得一个技能').set('forceDie',true).set('ai',function(){
return list.randomGet(); var att=get.sgnAttitude(_status.event.getTrigger().player,player);
if(att==0) return list.randomGet();
var listx=list.map(function(skill){
return [skill,get.skillRank(skill,'inout')];
}).sort(function(a,b){
return att*(b[1]-a[1]);
}).slice(0,2);
var listx2=[0];
if(Math.abs(listx[0][1]-listx[1][1])<=0.5&&Math.sign(listx[0][1])==Math.sign(listx[1][1])) listx2.push(1);
return listx[listx2.randomGet()][0];
}); });
'step 1' 'step 1'
if(player.storage.retuogu) player.removeSkill(player.storage.retuogu); if(player.storage.retuogu) player.removeSkill(player.storage.retuogu);

View File

@ -1356,7 +1356,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
lose:false, lose:false,
delay:false, delay:false,
skillAnimation:true, skillAnimation:true,
animationColor:'legend', animationColor:'metal',
check:function(card){ check:function(card){
if(get.type(card)!='basic'&&get.type(card)!='trick') return 0; if(get.type(card)!='basic'&&get.type(card)!='trick') return 0;
return get.value(card)-7.5; return get.value(card)-7.5;
@ -18435,7 +18435,15 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return false; return false;
}, },
usable:1, usable:1,
check:()=>false, check:function(event,player){
var hs=player.getCards('h'),cards=event.cards.filter(function(i){
return (hs.contains(i)&&get.color(i,player)=='red'&&lib.filter.cardDiscardable(i,player,'difa'));
});
var value=get.value(hs,player);
return Array.from(ui.cardPile.childNodes).some(function(card){
return get.type2(card,false)=='trick'&&get.value(card,player)>value;
});
},
content:function(){ content:function(){
'step 0' 'step 0'
var hs=player.getCards('h'),cards=trigger.cards.filter(function(i){ var hs=player.getCards('h'),cards=trigger.cards.filter(function(i){
@ -18451,7 +18459,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return get.type2(i,false)=='trick'; return get.type2(i,false)=='trick';
}); });
if(!list.length) event.finish(); if(!list.length) event.finish();
else player.chooseButton(['选择获得一种锦囊牌',[list.map((i)=>['锦囊','',i]),'vcard']],true); else player.chooseButton(['选择获得一种锦囊牌',[list.map((i)=>['锦囊','',i]),'vcard']],true).set('ai',function(button){
var card={name:button.link[2]};
if(!_status.event.list.contains(card.name)) return 0;
return _status.event.player.getUseValue(card);
}).set('list',Array.from(ui.cardPile.childNodes).filter(function(card){
return get.type2(card,false)=='trick';
}).map(function(card){
return card.name;
}).reduce(function(list,name){
if(!list.contains(name)) list.add(name);
return list;
},[]));
'step 2' 'step 2'
var card=get.cardPile(function(i){ var card=get.cardPile(function(i){
return i.name==result.links[0][2]&&!event.cards.contains(i); return i.name==result.links[0][2]&&!event.cards.contains(i);

View File

@ -4091,7 +4091,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'step 0' 'step 0'
var list=lib.inpile.filter(function(i){ var list=lib.inpile.filter(function(i){
if(player.storage.shouxi.contains(i)) return false; if(player.storage.shouxi.contains(i)) return false;
var type=get.type(i); var type=get.type2(i);
if(type=='basic'||type=='trick') return true; if(type=='basic'||type=='trick') return true;
return false; return false;
}); });
@ -4108,6 +4108,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
event.vcard=result.links; event.vcard=result.links;
event.cardname=name; event.cardname=name;
player.storage.shouxi.add(name); player.storage.shouxi.add(name);
player.popup(name);
game.log(player,'声明了','#y'+get.translation(name));
} }
else{ else{
event.finish(); event.finish();

View File

@ -47655,10 +47655,10 @@
for(var i of game.connectPlayers){ for(var i of game.connectPlayers){
if(!i.nickname&&!i.classList.contains('unselectable2')) num++; if(!i.nickname&&!i.classList.contains('unselectable2')) num++;
} }
// if(num>=lib.configOL.number-1){ if(num>=lib.configOL.number-1){
// alert('至少要有两名玩家才能开始游戏!'); alert('至少要有两名玩家才能开始游戏!');
// return; return;
// } }
game.resume(); game.resume();
} }
button.delete(); button.delete();
@ -53293,17 +53293,23 @@
threaten=info.ai.threaten(player,player); threaten=info.ai.threaten(player,player);
} }
} }
if(type=='in'){ if(type.indexOf('in')!=-1){
if(info.enable=='phaseUse') num+=0.5; if(info.enable=='phaseUse') num+=0.5;
if(info.trigger&&info.trigger.player){ if(info.trigger&&info.trigger.player){
var list=Array.isArray(info.trigger.player)?info.trigger.player:[info.trigger.player]; var list=Array.isArray(info.trigger.player)?info.trigger.player:[info.trigger.player];
var add=false; var add=false;
for(var i of list){ for(var i of list){
for(var j of lib.phaseName){ if(i.indexOf('phase')==0){
if(i.indexOf[j]==0){ num+=0.5;
num+=0.5; add=true;
add=true; }
break; else{
for(var j of lib.phaseName){
if(i.indexOf[j]==0){
num+=0.5;
add=true;
break;
}
} }
} }
if(add) break; if(add) break;
@ -53316,12 +53322,22 @@
num+=Math.sqrt(threaten)-1; num+=Math.sqrt(threaten)-1;
} }
} }
else if(type=='out'){ if(type.indexOf('out')!=-1){
if(threaten<1){ if(threaten<1){
num=1/Math.sqrt(threaten); num*=1/Math.sqrt(threaten);
}
if(info.trigger){
if(info.trigger.global){
var list=Array.isArray(info.trigger.global)?info.trigger.global:[info.trigger.global];
num+=Math.min(3,list.length)/10;
for(var i of list){
if(i.indexOf('lose')==0||i.indexOf('use')==0) num+=0.3;
if(i.indexOf('cardsDiscard')==0) num+=0.4;
}
}
if(info.trigger.target||(typeof info.trigger.player=='string'&&
(info.trigger.player.indexOf('damage')==0||info.trigger.player.indexOf('lose')==0))) num+=0.1;
} }
if(info.trigger&&(info.trigger.global||info.trigger.target||(typeof info.trigger.player=='string'&&
(info.trigger.player.indexOf('damage')==0||info.trigger.player.indexOf('lose')==0)))) num+=0.1;
if(info.ai){ if(info.ai){
if(info.ai.maixie||info.ai.maixie_hp||info.ai.maixie_defend){ if(info.ai.maixie||info.ai.maixie_hp||info.ai.maixie_defend){
num+=0.5; num+=0.5;

View File

@ -362,6 +362,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
return Math.random(); return Math.random();
}).set('dialog',event.videoId); }).set('dialog',event.videoId);
"step 5" "step 5"
game.broadcastAll('closeDialog',event.videoId);
game.me.next.init(result.links[0]); game.me.next.init(result.links[0]);
_status.characterlist.remove(result.links[0]); _status.characterlist.remove(result.links[0]);
game.addRecentCharacter(result.links[0]); game.addRecentCharacter(result.links[0]);