Merge pull request #1065 from PZ157/PR-Branch

新增freeShan标签,修复闪相关的一些ai
This commit is contained in:
Spmario233 2024-03-11 20:35:30 +08:00 committed by GitHub
commit c838ec7bf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 101 additions and 32 deletions

View File

@ -155,11 +155,13 @@ game.import('card',function(lib,game,ui,get,ai,_status){
next.set('useShan',(()=>{
if(target.hasSkillTag('noShan',null,event)) return false;
if(target.hasSkillTag('useShan',null,event)) return true;
if(event.baseDamage+event.extraDamage<=0 || target.isLinked()&&game.hasNature(event.card)&&get.attitude(target,player._trueMe||player)>0) return false;
if(target.isLinked()&&game.hasNature(event.card)&&get.attitude(target,player._trueMe||player)>0) return false;
if(event.baseDamage+event.extraDamage<=0&&!game.hasNature(event.card,'ice')) return false;
if(target.hasSkillTag('freeShan',false,event,true)) return true;
if(event.shanRequired>1&&target.mayHaveShan(target,'use',null,'count')<event.shanRequired-(event.shanIgnored||0)) return false;
if(event.baseDamage+event.extraDamage>=target.hp+
((player.hasSkillTag('jueqing',false,target)||target.hasSkill('gangzhi'))?target.hujia:0)) return true;
if(!game.hasNature(event.card, 'ice')&&get.damageEffect(target,player,target,get.nature(event.card))>=0) return false;
if(!game.hasNature(event.card,'ice')&&get.damageEffect(target,player,target,get.nature(event.card))>=0) return false;
return true;
})());
//next.autochoose=lib.filter.autoRespondShan;
@ -394,7 +396,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
useful:(card,i)=>{
let player = _status.event.player, basic = [7, 5.1, 2], num = basic[Math.min(2, i)];
if(player.hp>2&&player.hasSkillTag('maixie')) num *= 0.57;
if(player.getEquip('bagua') || player.getEquip('rewrite_bagua') || player.getEquip('renwang') || player.getEquip('rewrite_renwang')) num *= 0.8;
if(player.hasSkillTag('freeShan',false,null,true) || player.getEquip('rewrite_renwang')) num *= 0.8;
return num;
},
value:[7,5.1,2],
@ -2676,6 +2678,18 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},
ai:{
respondShan:true,
freeShan:true,
skillTagFilter(player,tag,arg){
if(tag!=='respondShan'&&tag!=='freeShan') return;
if(player.hasSkillTag('unequip2')) return false;
if(!arg||!arg.player) return true;
if(arg.player.hasSkillTag('unequip',false,{
target:player
})||arg.player.hasSkillTag('unequip_ai',false,{
target:player
})) return false;
return true;
},
effect:{
target:function(card,player,target,effect){
if(target.hasSkillTag('unequip2')) return;

View File

@ -2775,7 +2775,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
order:7,
result:{
target(player,target){
if(player.getEquip('tengjia')||player.getEquip('bagua')) return -1;
if(player.getEquip('tengjia')||player.hasSkillTag('freeShan',false,{
player:target,
card:new lib.element.VCard({name:'sha'})
})) return -1;
if(get.effect(player,{name:'sha'},target,player)>=0) return -1;
if(!player.hasShan()){
if(ui.selected.targets.length) return 0;

View File

@ -2351,7 +2351,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
result:{
target:function(player,target){
if(player.getStorage('dclvecheng_xiongluan').includes(target)) return 0;
if(target.getEquip('bagua')||target.getEquip('rewrite_bagua')) return -0.6;
if(target.hasSkillTag('freeShan',false,{
player:player
},true)) return -0.6;
var hs=player.countCards('h',card=>{
if(!player.canUse(card,target)) return false;
return get.name(card)=='sha'&&get.effect(target,card,player,player)>0;

View File

@ -2295,7 +2295,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
direct:true,
content:function(){
"step 0"
var dis=trigger.target.countCards('h','shan')||trigger.target.getEquip('bagua')||trigger.target.countCards('h')>2;
var dis=trigger.target.countCards('h','shan')||trigger.target.hasSkillTag('freeShan',false,{
player:player,
card:trigger.card
},true)||trigger.target.countCards('h')>2;
var att=get.attitude(player,trigger.target);
var next=player.chooseToDiscard(get.prompt('xiandan'));
next.ai=function(card){

View File

@ -1389,7 +1389,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
order:13,
result:{
target:(player,target)=>{
if(target.getEquip('bagua')||target.getEquip('rewrite_bagua')) return 0;
let hs=player.countCards('h',card=>{
if(!get.tag(card,'damage')||get.effect(target,card,player,player)<=0) return 0;
if(get.name(card,player)==='sha'){
@ -5435,6 +5434,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
ai:{
respondShan:true,
freeShan:true,
skillTagFilter(player,tag,arg){
if(tag!=='respondShan'&&tag!=='freeShan') return;
if(!player.hasEmptySlot(2)||player.hasSkillTag('unequip2')) return false;
if(!arg||!arg.player) return true;
if(arg.player.hasSkillTag('unequip',false,{
target:player
})||arg.player.hasSkillTag('unequip_ai',false,{
target:player
})) return false;
return true;
},
effect:{
target:function(card,player,target){
if(player==target&&get.subtype(card)=='equip2'){

View File

@ -2413,9 +2413,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ai:{
directHit_ai:true,
skillTagFilter:function(player,tag,arg){
if(!arg||!arg.card||!arg.target||(arg.card.name!='sha'&&arg.card.name!='juedou')) return false;
if(tag!=='directHit_ai'||!arg||!arg.card||!arg.target||(arg.card.name!='sha'&&arg.card.name!='juedou')) return false;
if(player.storage.counttrigger&&player.storage.counttrigger.dbquedi&&player.storage.counttrigger.dbquedi>0) return false;
if(arg.target.countCards('h')==1&&(arg.card.name!='sha'||!arg.target.getEquip('bagua')||player.hasSkillTag('unequip',false,{
if(arg.target.countCards('h')==1&&(arg.card.name!='sha'||!arg.target.hasSkillTag('freeShan',false,{
player:player,
card:arg.card
})||player.hasSkillTag('unequip',false,{
name:arg.card?arg.card.name:null,
target:arg.target,
card:arg.card

View File

@ -15738,8 +15738,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(get.attitude(player,event.player)>=0) return false;
var e2=player.getEquip(2);
if(e2){
if(e2.name=='tengjia') return true;
if(e2.name=='bagua') return true;
if(e2.name=='tengjia'||e2.name=='rewrite_tengjia') return true;
if(e2.name=='bagua'||e2.name=='rewrite_bagua') return true;
}
return event.player.countCards('h')>event.player.hp;
},
@ -20019,6 +20019,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
ai:{
respondShan:true,
freeShan:true,
skillTagFilter(player,tag,arg){
if(tag!=='respondShan'&&tag!=='freeShan') return;
if(!player.hasEmptySlot(2)||player.hasSkillTag('unequip2')) return false;
if(!arg||!arg.player) return true;
if(arg.player.hasSkillTag('unequip',false,{
target:player
})||arg.player.hasSkillTag('unequip_ai',false,{
target:player
})) return false;
return true;
},
effect:{
target:function(card,player,target){
if(player==target&&get.subtype(card)=='equip2'){
@ -20477,8 +20489,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(get.attitude(player,event.player)>=0) return false;
var e2=player.getEquip(2);
if(e2){
if(e2.name=='tengjia') return true;
if(e2.name=='bagua') return true;
if(e2.name=='tengjia'||e2.name=='rewrite_tengjia') return true;
if(e2.name=='bagua'||e2.name=='rewrite_bagua') return true;
}
return player.countCards('h','shan')>0;
},

View File

@ -9528,7 +9528,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
direct:true,
content:function(){
"step 0"
var dis=trigger.target.countCards('h','shan')||trigger.target.getEquip('bagua')||trigger.target.countCards('h')>2;
var dis=trigger.target.countCards('h','shan')||trigger.target.hasSkillTag('freeShan',false,{
player:player,
card:trigger.card
},true)||trigger.target.countCards('h')>2;
var next=player.chooseToDiscard(get.prompt('shoulie',trigger.target));
next.ai=function(card){
if(dis) return 7-get.value(card);

View File

@ -10299,9 +10299,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
player.chooseTarget(get.prompt2('juetao'),lib.filter.notMe).set('ai',function(target){
let att=-get.attitude(_status.event.player,target);
if(att<=0) return att;
if(target.hasSkillTag('nodamage')) return 0.01*att;
if(target.getEquip('tengjia')||target.getEquip('renwang')) return 0.2*att;
if(target.getEquip('bagua')) return 0.3*att;
if(target.hasSkillTag('nodamage')||target.getEquip('qimenbagua')) return 0.01*att;
if(target.getEquip('tengjia')||target.getEquip('renwang')) return 0.3*att;
if(target.getEquip('rewrite_tengjia')||target.getEquip('rewrite_renwang')) return 0.2*att;
if(target.hasSkillTag('freeShan',false,{
player:_status.event.player
},true)) return 0.3*att;
if(target.getEquip(2)) return att/2;
return 1.2*att;
});

View File

@ -3692,11 +3692,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ai:{
directHit_ai:true,
skillTagFilter:function(player,tag,arg){
if(player._zhuandui_temp) return false;
if(player._zhuandui_temp||tag!=='directHit_ai') return false;
player._zhuandui_temp=true;
var bool=function(){
if(arg.card.name!='sha'||get.attitude(player,arg.target)>=0||!arg.target.countCards('h')) return false;
if(arg.target.countCards('h')==1&&(!arg.target.getEquip('bagua')||player.hasSkillTag('unequip',false,{
if(arg.target.countCards('h')==1&&(!arg.target.hasSkillTag('freeShan',false,{
player:player,
card:arg.card
},true)||player.hasSkillTag('unequip',false,{
name:arg.card?arg.card.name:null,
target:arg.target,
card:arg.card
@ -7254,7 +7257,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var trigger=_status.event.getTrigger();
if(att>0&&eff>=0) return 1;
if(att>=0&&eff>0) return 1;
if(att>0&&(trigger.player.hp>=3||trigger.player.getEquip('bagua')||trigger.player.countCards('h','shan'))){
if(att>0&&(trigger.player.hp>=3||trigger.player.hasSkillTag('freeShan',false,{
player:_status.event.player,
card:new lib.element.VCard({name:'sha',isCard:true})
})||trigger.player.countCards('h','shan'))){
if(name=='lebu'&&nh>trigger.player.hp) return 1;
if(name=='bingliang'&&nh<trigger.player.hp) return 1;
}
@ -7290,7 +7296,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var trigger=_status.event.getTrigger();
if(att>0&&eff>=0) return 1;
if(att>=0&&eff>0) return 1;
if(att>0&&(trigger.player.hp>=3||trigger.player.getEquip('bagua')||trigger.player.countCards('h','shan'))){
if(att>0&&(trigger.player.hp>=3||trigger.player.hasSkillTag('freeShan',false,{
player:_status.event.player,
card:new lib.element.VCard({name:'sha',isCard:true})
})||trigger.player.countCards('h','shan'))){
if(name=='lebu'&&nh>trigger.player.hp) return 1;
if(name=='bingliang'&&nh<trigger.player.hp) return 1;
}
@ -9895,8 +9904,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ai:{
directHit_ai:true,
skillTagFilter:function(player,tag,arg){
if(!arg.target.hasSkill('qianxi2')) return false;
if(arg.card.name=='sha') return arg.target.storage.qianxi2=='red'&&(!arg.target.getEquip('bagua')||player.hasSkillTag('unequip',false,{
if(tag!=='directHit_ai'||!arg.target.hasSkill('qianxi2')) return false;
if(arg.card.name=='sha') return arg.target.storage.qianxi2=='red'&&(!arg.target.hasSkillTag('freeShan',false,{
player:player,
card:arg.card
},true)||player.hasSkillTag('unequip',false,{
name:arg.card?arg.card.name:null,
target:arg.target,
card:arg.card

View File

@ -1066,7 +1066,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
check:function(event,player){
if(get.attitude(player,event.target)>=0) return false;
if(event.target.getEquip('bagua')) return false;
if(event.target.hasSkillTag('freeShan',false,{
player:player,
card:event.card
},true)) return false;
if(event.target.hasSkillTag('respondShan')&&event.target.countCards('h')>=3) return false;
return true;
},
@ -2186,7 +2189,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(trigger.target.hasSkill('shanguang2')) return 0;
var equip=trigger.target.getEquip(2);
if(equip&&equip.name=='bagua') return 1;
if(equip&&(equip.name=='bagua'||equip.name=='rewrite_bagua')) return 1;
return trigger.target.countCards('h')<2?0:1;
};
"step 1"

View File

@ -2316,11 +2316,11 @@ export class Player extends HTMLDivElement {
}
/**
* 换肤换音想要支持某个武将更换皮肤必须在lib.character.characterSubstitute中存在该武将的id以下以name代指武将idcharacter代指换肤图片名
*
*
* 如果换肤换音引用本体的image/character素材作为更换的皮肤且不需要使用本体audio/die以外的地方的配音则你无需在characterSubstitute中书写关于此皮肤的信息
*
*
* 如果lib.character[character]不存在且想引用其他路径的图片素材或阵亡素材请以[character,[]]的形式写入lib.character.characterSubstitute[name]第二个数组填入形式同lib.character[4]的书写形式
*
*
* @param { string | string }
*/
changeSkin(skill, character) {
@ -7518,7 +7518,7 @@ export class Player extends HTMLDivElement {
this.addSkill(skillsToAdd[i], null, true, true);
this.additionalSkills[skill].push(skillsToAdd[i]);
}
this.checkConflict();
_status.event.clearStepCache();
return this;
@ -8791,10 +8791,10 @@ export class Player extends HTMLDivElement {
if (this.hasSkillTag('respondSha', true, respond ? 'respond' : 'use', true)) return true;
return this.hasUsableCard('sha');
}
hasShan() {
hasShan(respond) {
if (this.countCards('hs', 'shan')) return true;
if (this.countCards('hs', 'hufu')) return true;
if (this.hasSkillTag('respondShan', true, null, true)) return true;
if (this.hasSkillTag('respondShan', true, respond ? 'respond' : 'use', true)) return true;
return this.hasUsableCard('shan');
}
mayHaveSha(viewer, type, ignore, rvt) {
@ -8843,7 +8843,7 @@ export class Player extends HTMLDivElement {
}
mayHaveShan(viewer, type, ignore, rvt) {
/**
* type: skill tag type 'use', 'respond'
* type: skill tag type 'use', 'respond' or object
* ignore: ignore cards, ui.selected.cards added
* rvt: return value type 'count', 'odds', 'bool'(default)
*/