diff --git a/DeusVault/DeusVault.html b/DeusVault/DeusVault.html index dd163c21aa..84bfad85c0 100644 --- a/DeusVault/DeusVault.html +++ b/DeusVault/DeusVault.html @@ -213,9 +213,9 @@ name="attr_mastery" type="text" title="@{mastery}" - value="[[(floor((@{link1}+@{link2})*2.5))]]" + value="@{mastery}%" disabled - />% + /> @@ -260,9 +260,9 @@ name="attr_mastery" type="text" title="@{mastery}" - value="(floor((@{link1}+@{link2})/2)+@{mastery_bonus})" - disabled="true" - />% + value="@{mastery}%" + disabled + /> @@ -357,6 +357,12 @@
+ @@ -364,6 +370,13 @@ /1000
+
@@ -405,6 +418,12 @@
+ @@ -412,6 +431,13 @@ /1000
+
@@ -453,6 +479,12 @@
+ @@ -460,6 +492,13 @@ /1000
+
@@ -501,6 +540,12 @@
+ @@ -508,6 +553,13 @@ /1000
+
@@ -549,6 +601,12 @@
+ @@ -556,6 +614,13 @@ /1000
+
@@ -597,6 +662,12 @@
+ @@ -604,6 +675,13 @@ /1000
+
@@ -645,6 +723,12 @@
+ @@ -652,6 +736,13 @@ /1000
+
@@ -693,6 +784,12 @@
+ @@ -700,6 +797,13 @@ /1000
+
@@ -741,6 +845,12 @@
+ @@ -748,6 +858,13 @@ /1000
+
@@ -1111,7 +1228,7 @@ } on("clicked:repeating_skills:roll clicked:repeating_masteries:roll", async (eventInfo) => { - skillClicked(eventInfo.sourceAttribute, "roll", "skillname", "mastery_value"); + skillClicked(eventInfo.sourceAttribute, "roll", "skillname", "mastery"); }); on("clicked:repeating_attacks:roll", async (eventInfo) => { @@ -1128,7 +1245,10 @@ }); on( - "clicked:repeating_talent-handicraft:roll clicked:repeating_talent-secret:roll clicked:repeating_talent-stealth:roll clicked:repeating_talent-dressage:roll clicked:repeating_talent-larceny:roll clicked:repeating_talent-language:roll clicked:repeating_talent-maneuver:roll clicked:repeating_talent-psychology:roll clicked:repeating_talent-survival:roll", + skills + .filter((s) => s["repeating_section_name"]) + .map((s) => `change:repeating_talent-${s["repeating_section_name"]}:roll`) + .join(" "), async function (eventInfo) { const pathBase = eventInfo.sourceAttribute.substring(0, eventInfo.sourceAttribute.length - 4); getAttrs([`${pathBase}talent_name`, `${pathBase}skillname`, `${pathBase}skill_mastered`], (values) => { @@ -1157,7 +1277,7 @@ function calculate_repeating_skills(repSection) { getAttrs([`${repSection}_link1`, `${repSection}_link2`, ...characteristicNames], (values) => { const output = {}; - output[`${repSection}_mastery_value`] = Math.floor( + output[`${repSection}_mastery`] = Math.floor( (parseInt(values[getLinkAttr(values[`${repSection}_link1`])]) + parseInt(values[getLinkAttr(values[`${repSection}_link2`])])) * 2.5 @@ -1167,27 +1287,138 @@ } on("change:repeating_skills", async (eventInfo) => { + if (eventInfo.triggerName.indexOf("_-") === -1) { + return; + } calculate_repeating_skills(eventInfo.triggerName); }); - function calculate_repeating_masteries(repSection) { + function calculate_repeating_masteries(repSections) { getAttrs( - [`${repSection}_link1`, `${repSection}_link2`, `${repSection}_mastery_bonus`, ...characteristicNames], + repSections.reduce( + (acc, repSection) => [ + ...acc, + `${repSection}_link1`, + `${repSection}_link2`, + `${repSection}_mastery_bonus`, + ...characteristicNames, + ], + [] + ), (values) => { const output = {}; - output[`${repSection}_mastery_value`] = Math.floor( - (parseInt(values[getLinkAttr(values[`${repSection}_link1`])]) + - parseInt(values[getLinkAttr(values[`${repSection}_link2`])])) / - 2 + - parseInt(values[`${repSection}_mastery_bonus`]) - ); + repSections.forEach((repSection) => { + output[`${repSection}_mastery`] = Math.floor( + (parseInt(values[getLinkAttr(values[`${repSection}_link1`])]) + + parseInt(values[getLinkAttr(values[`${repSection}_link2`])])) / + 2 + + parseInt(values[`${repSection}_mastery_bonus`]) + ); + }); setAttrs(output); } ); } on("change:repeating_masteries", async (eventInfo) => { - calculate_repeating_masteries(eventInfo.triggerName); + if (eventInfo.triggerName.indexOf("_-") === -1) { + return; + } + calculate_repeating_masteries([eventInfo.triggerName]); + }); + + function calculate_repeating_talent(basePaths) { + getAttrs( + basePaths.reduce( + (acc, pathBase) => [ + ...acc, + `${pathBase}talent_name`, + `${pathBase}skillname`, + `${pathBase}link1`, + `${pathBase}link2`, + `${pathBase}skill_mastered`, + ], + [] + ), + (values) => { + const talentNames = basePaths.map((pathBase) => values[`${pathBase}talent_name`]); + getAttrs( + talentNames.reduce( + (acc, talentName) => [ + ...acc, + `talent_${talentName}_link1`, + `talent_${talentName}_link2`, + ...characteristicNames, + ], + [] + ), + (talentValues) => { + const output = {}; + basePaths.forEach((pathBase) => { + const talentName = values[`${pathBase}talent_name`]; + const mastery = Math.floor( + (values[`${pathBase}skill_mastered`] === "on" ? 10 : 0) + + (parseInt(talentValues[talentValues[`talent_${talentName}_link1`]]) + + parseInt(talentValues[talentValues[`talent_${talentName}_link2`]])) * + 2.5 + ); + output[`${pathBase}mastery`] = mastery; + }); + setAttrs(output); + } + ); + } + ); + } + + on( + skills + .filter((s) => s["repeating_section_name"]) + .map((s) => `change:repeating_talent-${s["repeating_section_name"]}`) + .join(" "), + async (eventInfo) => { + const rowIdIdx = eventInfo.triggerName.indexOf("_-"); + if (rowIdIdx === -1) { + const sectionName = eventInfo.triggerName.substring(0, eventInfo.triggerName.lastIndexOf("_")); + getSectionIDs(sectionName, (ids) => { + calculate_repeating_talent(ids.map((id) => `${sectionName}_${id}_`)); + }); + } else { + calculate_repeating_talent([`${eventInfo.triggerName}_`]); + } + } + ); + + on(characteristicNames.map((c) => `change:${c}`).join(" "), async (eventInfo) => { + getSectionIDs("repeating_masteries", (ids) => { + calculate_repeating_masteries(ids.map((i) => `repeating_masteries_${i}`)); + }); + + const repTalents = skills.filter((s) => s["repeating_section_name"]); + getAttrs( + repTalents.reduce( + (acc, t) => [ + ...acc, + `talent_${t["repeating_section_name"]}_link1`, + `talent_${t["repeating_section_name"]}_link2`, + ], + [] + ), + (talentLinks) => { + const talentsToUpdate = repTalents.filter( + (t) => + talentLinks[`talent_${t["repeating_section_name"]}_link1`] === eventInfo.sourceAttribute || + talentLinks[`talent_${t["repeating_section_name"]}_link2`] === eventInfo.sourceAttribute + ); + + talentsToUpdate.forEach((talentToUpdate) => { + const sectionName = `repeating_talent-${talentToUpdate["repeating_section_name"]}`; + getSectionIDs(sectionName, (ids) => { + calculate_repeating_talent(ids.map((id) => `${sectionName}_${id}_`)); + }); + }); + } + ); }); })();