From 21f66e784b9a34ac6fbc715a13e2e8f4772d561e Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Mon, 2 Oct 2023 16:40:02 +0800 Subject: [PATCH] =?UTF-8?q?inherit,group,subSkill=E5=A5=97=E5=A8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 267 ++++++++++++++++++++++++++------------------------- 1 file changed, 138 insertions(+), 129 deletions(-) diff --git a/game/game.js b/game/game.js index fbc8037d0..00e5c2816 100644 --- a/game/game.js +++ b/game/game.js @@ -26153,72 +26153,60 @@ return list; }, addSkillTrigger:function(skill,hidden,triggeronly){ - var info=lib.skill[skill]; - if(!info) return; - if(typeof info.group=='string'){ - this.addSkillTrigger(info.group,hidden); - } - else if(Array.isArray(info.group)){ - for(var i=0;i{ + finishSkill:(i,history)=>{ const mode=get.mode(),info=lib.skill[i],iInfo=`${i}_info`; if(info.alter){ lib.translate[`${iInfo}_origin`]=lib.translate[iInfo]; @@ -40237,14 +40215,25 @@ }); } if(info.inherit){ - const skill=lib.skill[info.inherit]; - if(skill) Object.keys(skill).forEach(value=>{ - if(info[value]!=undefined) return; - if(value=='audio'&&(typeof info[value]=='number'||typeof info[value]=='boolean')) info[value]=info.inherit; - else info[value]=skill[value]; - }); - if(lib.translate[i]==undefined) lib.translate[i]=lib.translate[info.inherit]; - if(lib.translate[iInfo]==undefined) lib.translate[iInfo]=lib.translate[`${info.inherit}_info`]; + var inheritHistory=[]; + while(true){ + if(!info.inherit) break; + if(inheritHistory.includes(info.inherit)){ + console.trace(`Inherit Error: ${info.inherit} in ${i}'s inherit forms a deadlock`); + break; + } + inheritHistory.push(info.inherit); + + const inheritInfo=lib.skill[info.inherit]; + if(inheritInfo) Object.keys(inheritInfo).forEach(value=>{ + if(info[value]!=undefined) return; + if(value=='audio'&&(typeof info[value]=='number'||typeof info[value]=='boolean')) info[value]=info.inherit; + else info[value]=inheritInfo[value]; + }); + 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(!inheritInfo||!inheritInfo.inherit) info.inherit=void 0; + } } if(info.limited){ if(info.mark===undefined) info.mark=true; @@ -40253,16 +40242,26 @@ if(info.skillAnimation===undefined) info.skillAnimation=true; if(info.init===undefined) info.init=(player,skill)=>player.storage[skill]=false; } - 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.subSkill){ + let subSkillHistory=Array.isArray(history)?history:[]; + for(let value in info.subSkill){ + if(subSkillHistory.includes(value)){ + console.trace(`SubSkill Error: ${value} in ${i} forms a deadlock`); + continue; + } + let history=subSkillHistory.slice(0); + history.push(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,history); + } + } if(info.round){ const k=`${i}_roundcount`; if(typeof info.group=='string') info.group=[info.group,k]; @@ -41165,15 +41164,25 @@ if(!player.storage.skill_blocker||!player.storage.skill_blocker.length) return out; return out.filter(value=>exclude&&exclude.includes(value)||!get.is.blocked(value,player)); }, - expandSkills:skills=>skills.addArray(skills.reduce((previousValue,currentValue)=>{ - const info=get.info(currentValue); - if(info){ - if(Array.isArray(info.group)) previousValue.push(...info.group); - else if(info.group) previousValue.push(info.group); + expandSkills:(skill,oldHistory)=>{ + let history=[]; + if(oldHistory) history.addArray(oldHistory); + if(Array.isArray(skill)){ + return skill.reduce((previous,current)=>previous.addArray(game.expandSkills(current,history)),[]); } - else console.log(currentValue); - return previousValue; - },[])), + + let info=get.info(skill); + if(!info){ + console.trace(`Cannot find skill: ${skill}`); + return history; + } + history.add(skill); + if(info.group){ + let group=Array.isArray(info.group)?info.group:[info.group]; + history.addArray(game.expandSkills([].addArray(group.filter(skill=>!history.includes(skill))),history)); + } + return history; + }, css:style=>Object.keys(style).forEach(value=>{ let uiStyle=ui.style[value]; if(!uiStyle){