From 7a09ae57e153af6f24804ebba89203192b6209e3 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 11 Jun 2025 21:07:22 +0200 Subject: [PATCH] feat: Create the calculateAbilityCost() helper --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.html b/index.html index 0457ae5..5148f12 100644 --- a/index.html +++ b/index.html @@ -433,6 +433,7 @@ speed: document.getElementById("inp-pool-edge-speed"), intellect: document.getElementById("inp-pool-edge-intellect"), }; + const inpAbilityCost = document.getElementById("inp-ability-cost"); const inpAbilityEffort = document.getElementById("inp-ability-effort"); const dspAbilityPool = document.getElementById("dsp-ability-pool"); @@ -665,6 +666,19 @@ } }; + const calculateAbilityCost = () => { + var currentPool = getSelectedPool(); + + if (currentPool === null) return null; + + var cost = Number(inpAbilityCost.value); + var effort = Number(inpAbilityEffort.value); + var effortCost = (effort) ? 3 + (effort - 1) * 2 : 0; + var poolEdge = Number(inpPoolEdge[currentPool].value); + + return Math.max(0, cost + effortCost - poolEdge); + }; + document.addEventListener( "DOMContentLoaded", () => {