Optimize game.finishSkill.

(cherry picked from commit 3c9cdfc3e560f4e87b69a5508290e024e90ffafb)
This commit is contained in:
Tipx-L 2023-08-24 21:04:59 -07:00
parent a862eb36b2
commit f090e56961
1 changed files with 71 additions and 139 deletions

View File

@ -37475,182 +37475,114 @@
game.asyncDraw.apply(this,arguments); game.asyncDraw.apply(this,arguments);
} }
}, },
finishSkill:function(i,sub){ finishSkill:(i,sub)=>{
var j; const mode=get.mode(),info=lib.skill[i],iInfo=`${i}_info`;
var mode=get.mode();
var info=lib.skill[i];
if(info.alter){ if(info.alter){
lib.translate[i+'_info_origin']=lib.translate[i+'_info']; lib.translate[`${iInfo}_origin`]=lib.translate[iInfo];
if(!lib.config.vintageSkills.contains(i)){ if(!lib.config.vintageSkills.contains(i)) lib.translate[iInfo]=lib.translate[`${iInfo}_alter`];
lib.translate[i+'_info']=lib.translate[i+'_info_alter'];
}
}
else if(lib.translate[i+'_info_'+mode]){
lib.translate[i+'_info']=lib.translate[i+'_info_'+mode];
}
else if(lib.translate[i+'_info_zhu']&&(mode=='identity'||(mode=='guozhan'&&_status.mode=='four'))){
lib.translate[i+'_info']=lib.translate[i+'_info_zhu'];
}
else if(lib.translate[i+'_info_combat']&&get.is.versus()){
lib.translate[i+'_info']=lib.translate[i+'_info_combat'];
} }
else if(lib.translate[`${iInfo}_${mode}`]) lib.translate[iInfo]=lib.translate[`${iInfo}_${mode}`];
else if(lib.translate[`${iInfo}_zhu`]&&(mode=='identity'||mode=='guozhan'&&_status.mode=='four')) lib.translate[iInfo]=lib.translate[`${iInfo}_zhu`];
else if(lib.translate[`${iInfo}_combat`]&&get.is.versus()) lib.translate[iInfo]=lib.translate[`${iInfo}_combat`];
if(info.forbid&&info.forbid.contains(mode)){ if(info.forbid&&info.forbid.contains(mode)){
lib.skill[i]={}; lib.skill[i]={};
if(lib.translate[i+'_info']){ if(lib.translate[iInfo]) lib.translate[iInfo]='此模式下不可用';
lib.translate[i+'_info']='此模式下不可用';
}
return; return;
} }
if(info.mode&&info.mode.contains(mode)==false){ if(info.mode&&info.mode.contains(mode)==false){
lib.skill[i]={}; lib.skill[i]={};
if(lib.translate[i+'_info']){ if(lib.translate[iInfo]) lib.translate[iInfo]='此模式下不可用';
lib.translate[i+'_info']='此模式下不可用';
}
return; return;
} }
if(info.available&&info.available(mode)==false){ if(info.available&&info.available(mode)==false){
lib.skill[i]={}; lib.skill[i]={};
if(lib.translate[i+'_info']){ if(lib.translate[iInfo]) lib.translate[iInfo]='此模式下不可用';
lib.translate[i+'_info']='此模式下不可用';
}
return; return;
} }
if(info.viewAs&&typeof info.viewAs!='function'){ if(info.viewAs&&typeof info.viewAs!='function'){
if(typeof info.viewAs=='string'){ if(typeof info.viewAs=='string') info.viewAs={
info.viewAs={name:info.viewAs}; name:info.viewAs
} };
if(!lib.card[info.viewAs.name]){ if(!lib.card[info.viewAs.name]){
lib.skill[i]={}; lib.skill[i]={};
lib.translate[i+'_info']='技能不可用'; lib.translate[iInfo]='技能不可用';
return; return;
} }
if(info.ai==undefined) info.ai={}; if(info.ai==undefined) info.ai={};
var skill=info.ai; const skill=info.ai,card=lib.card[info.viewAs.name].ai;
var card=lib.card[info.viewAs.name].ai; Object.keys(card).forEach(value=>{
for(j in card){ if(skill[value]==undefined) skill[value]=card[value];
if(skill[j]==undefined) skill[j]=card[j]; else if(typeof skill[value]=='object') Object.keys(card[value]).forEach(element=>{
else if(typeof skill[j]=='object'){ if(skill[value][element]==undefined) skill[value][element]=card[value][element];
for(var k in card[j]){ });
if(skill[j][k]==undefined) skill[j][k]=card[j][k]; });
}
}
}
} }
if(info.inherit){ if(info.inherit){
var skill=lib.skill[info.inherit]; const skill=lib.skill[info.inherit];
for(j in skill){ Object.keys(skill).forEach(value=>{
if(info[j]==undefined){ if(info[value]!=undefined) return;
if(j=='audio'&&(typeof info[j]=='number'||typeof info[j]=='boolean')){ if(value=='audio'&&(typeof info[value]=='number'||typeof info[value]=='boolean')) info[value]=info.inherit;
info[j]=info.inherit; else info[value]=skill[value];
} });
else{ if(lib.translate[i]==undefined) lib.translate[i]=lib.translate[info.inherit];
info[j]=skill[j]; if(lib.translate[iInfo]==undefined) lib.translate[iInfo]=lib.translate[`${info.inherit}_info`];
}
}
}
if(lib.translate[i]==undefined){
lib.translate[i]=lib.translate[info.inherit];
}
if(lib.translate[i+'_info']==undefined){
lib.translate[i+'_info']=lib.translate[info.inherit+'_info'];
}
} }
if(info.limited){ if(info.limited){
if(info.mark===undefined) info.mark=true; if(info.mark===undefined) info.mark=true;
if(!info.intro) info.intro={}; if(!info.intro) info.intro={};
if(info.intro.content===undefined) info.intro.content='limited'; if(info.intro.content===undefined) info.intro.content='limited';
if(info.skillAnimation===undefined) info.skillAnimation=true; if(info.skillAnimation===undefined) info.skillAnimation=true;
if(info.init===undefined) info.init=function(player,skill){ if(info.init===undefined) info.init=(player,skill)=>player.storage[skill]=false;
player.storage[skill]=false;
}
}
if(info.subSkill&&!sub){
for(var j in info.subSkill){
lib.skill[i+'_'+j]=info.subSkill[j];
lib.skill[i+'_'+j].sub=true;
if(info.subSkill[j].name){
lib.translate[i+'_'+j]=info.subSkill[j].name;
}
else{
lib.translate[i+'_'+j]=lib.translate[i+'_'+j]||lib.translate[i];
}
if(info.subSkill[j].description){
lib.translate[i+'_'+j+'_info']=info.subSkill[j].description;
}
if(info.subSkill[j].marktext){
lib.translate[i+'_'+j+'_bg']=info.subSkill[j].marktext;
}
game.finishSkill(i+'_'+j,true);
}
} }
if(info.subSkill&&!sub) Object.keys(info.subSkill).forEach(value=>{
const iValue=`${i}_${value}`;
lib.skill[iValue]=info.subSkill[value];
lib.skill[iValue].sub=true;
if(info.subSkill[value].name) lib.translate[iValue]=info.subSkill[value].name;
else lib.translate[iValue]=lib.translate[iValue]||lib.translate[i];
if(info.subSkill[value].description) lib.translate[`${iValue}_info`]=info.subSkill[value].description;
if(info.subSkill[value].marktext) lib.translate[`${iValue}_bg`]=info.subSkill[value].marktext;
game.finishSkill(iValue,true);
});
if(info.round){ if(info.round){
var k=i+'_roundcount'; const k=`${i}_roundcount`;
if(typeof info.group=='string'){ if(typeof info.group=='string') info.group=[info.group,k];
info.group=[info.group,k]; else if(Array.isArray(info.group)) info.group.add(k);
} else info.group=[k];
else if(Array.isArray(info.group)){ lib.skill[k]=((round,name)=>({
info.group.add(k); init:player=>{
} if(typeof player.storage[name]!=='number') player.storage[name]=1-round;
else{ },
info.group=[k]; intro:{
} content:(storage,player)=>{
lib.skill[k]=(function(round,name){ let str='';
return { const info=get.info(name.slice(0,name.indexOf('_roundcount')));
init:function(player){ if(info&&info.addintro) str+=info.addintro(storage,player);
if(typeof player.storage[name]!=='number') player.storage[name]=1-round; const num=round-(game.roundNumber-storage);
if(num>0) str+=`${get.cnNumber(num)}轮后${info.roundtext||'技能重置'}`;
else str+='技能可发动';
return str;
}, },
intro:{ markcount:(storage,player)=>Math.max(round-(game.roundNumber-storage),0)
content:function(storage,player){ },
var str=''; trigger:{global:'roundStart'},
var info=get.info(name.slice(0,name.indexOf('_roundcount'))); forced:true,
if(info&&info.addintro){ popup:false,
str+=info.addintro(storage,player); silent:true,
} content:()=>{
var num=round-(game.roundNumber-storage); if(lib.skill[event.name.slice(0,event.name.indexOf('_roundcount'))].round-(game.roundNumber-player.storage[event.name])>0) player.updateMarks();
if(num>0){ else player.unmarkSkill(event.name);
str+=get.cnNumber(num)+'轮后'+(info.roundtext||'技能重置'); }
} }))(info.round,k);
else{
str+='技能可发动';
}
return str;
},
markcount:function(storage,player){
var num=round-(game.roundNumber-storage);
if(num>0){
return num;
}
return 0;
}
},
trigger:{global:'roundStart'},
forced:true,
popup:false,
silent:true,
content:function(){
var skill=event.name.slice(0,event.name.indexOf('_roundcount'));
if(lib.skill[skill].round-(game.roundNumber-player.storage[event.name])>0){
player.updateMarks();
}
else{
player.unmarkSkill(event.name);
}
}
};
}(info.round,k));
lib.translate[k]=lib.translate[i]||''; lib.translate[k]=lib.translate[i]||'';
lib.translate[k+'_bg']=lib.translate[i+'_bg']||lib.translate[k][0]; lib.translate[`${k}_bg`]=lib.translate[`${i}_bg`]||lib.translate[k][0];
}
if(info.marktext){
lib.translate[i+'_bg']=info.marktext;
} }
if(info.marktext) lib.translate[`${i}_bg`]=info.marktext;
if(info.silent){ if(info.silent){
if(!info.hasOwnProperty('forced')) info.forced=true; if(!info.hasOwnProperty('forced')) info.forced=true;
if(!info.hasOwnProperty('popup')) info.popup=false; if(!info.hasOwnProperty('popup')) info.popup=false;
} }
if(i[0]=='_'){ if(i[0]=='_') game.addGlobalSkill(i);
game.addGlobalSkill(i);
}
}, },
finishCards:()=>{ finishCards:()=>{
_status.cardsFinished=true; _status.cardsFinished=true;