From 87d96625ba2368b9f4dbe8ec6bc754e3bbd9085a Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 11 Jun 2025 22:01:16 +0200 Subject: [PATCH] feat: Update ability cost when certain values change on the character sheet --- index.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/index.html b/index.html index 3c5683e..4f628de 100644 --- a/index.html +++ b/index.html @@ -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);