feat: Update ability cost when certain values change on the character sheet

This commit is contained in:
2025-06-11 22:01:16 +02:00
parent 574844d460
commit 87d96625ba

View File

@@ -666,6 +666,8 @@
if (abilityEffort > maxEffort) {
inpAbilityEffort.value = maxEffort;
}
updateAbilityCostDisplay();
};
const calculateAbilityCost = () => {
@@ -700,6 +702,18 @@
dspAbilityCost.appendChild(document.createTextNode(cost));
};
const poolValueChanged = () => {
updateAbilityCostDisplay();
};
const poolEdgeChanged = () => {
updateAbilityCostDisplay();
};
const abilityCostChanged = () => {
updateAbilityCostDisplay();
};
document.addEventListener(
"DOMContentLoaded",
() => {
@@ -716,6 +730,15 @@
.querySelectorAll("input[name=pool-selector]")
.forEach((elem) => {elem.addEventListener("change", poolSelectionChanged)});
for (var poolValueInput of Object.values(inpPoolValue)) {
poolValueInput.addEventListener("input", poolValueChanged);
}
for (var poolEdgeInput of Object.values(inpPoolEdge)) {
poolEdgeInput.addEventListener("input", poolEdgeChanged);
}
inpAbilityCost.addEventListener("input", abilityCostChanged);
inpAbilityEffort.addEventListener("input", abilityEffortChanged);
btnNoCharCreateCharacter.addEventListener("click", createCharacter);