[DeusVault] fix auto-update of some fields
This commit is contained in:
+248
-17
@@ -213,9 +213,9 @@
|
||||
name="attr_mastery"
|
||||
type="text"
|
||||
title="@{mastery}"
|
||||
value="[[(floor((@{link1}+@{link2})*2.5))]]"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>%
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -260,9 +260,9 @@
|
||||
name="attr_mastery"
|
||||
type="text"
|
||||
title="@{mastery}"
|
||||
value="(floor((@{link1}+@{link2})/2)+@{mastery_bonus})"
|
||||
disabled="true"
|
||||
/>%
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -357,6 +357,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-handicraft">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_handicraft_link1}+@{talent_handicraft_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="handicraft" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -364,6 +370,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -405,6 +418,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-secret">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_secret_link1}+@{talent_secret_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="secret" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -412,6 +431,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -453,6 +479,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-stealth">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_stealth_link1}+@{talent_stealth_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="stealth" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -460,6 +492,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -501,6 +540,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-dressage">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_dressage_link1}+@{talent_dressage_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="dressage" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -508,6 +553,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -549,6 +601,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-larceny">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_larceny_link1}+@{talent_larceny_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="larceny" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -556,6 +614,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -597,6 +662,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-language">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_language_link1}+@{talent_language_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="language" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -604,6 +675,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -645,6 +723,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-maneuver">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_maneuver_link1}+@{talent_maneuver_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="maneuver" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -652,6 +736,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -693,6 +784,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-psychology">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_psychology_link1}+@{talent_psychology_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="psychology" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -700,6 +797,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -741,6 +845,12 @@
|
||||
<div class="sheet-talent-list">
|
||||
<fieldset class="repeating_talent-survival">
|
||||
<div class="sheet-skill-section">
|
||||
<input
|
||||
type="hidden"
|
||||
name="attr_talent_links"
|
||||
value="@{talent_survival_link1}+@{talent_survival_link2}"
|
||||
disabled
|
||||
/>
|
||||
<input type="text" name="attr_talent_name" value="survival" hidden />
|
||||
<button class="sheet-button-roll" name="act_roll" type="action"></button>
|
||||
<input type="text" name="attr_skillname" value="" />
|
||||
@@ -748,6 +858,13 @@
|
||||
<input type="text" name="attr_skill_xp" value="0" />/1000
|
||||
</div>
|
||||
<input type="checkbox" name="attr_skill_mastered" title="@{skill_mastered}" />
|
||||
<input
|
||||
class="sheet-mastery-value"
|
||||
type="text"
|
||||
name="attr_mastery"
|
||||
value="@{mastery}%"
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -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}_`));
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user