From 0a948d23d351a15330c4ae43de58ebbcc87a4c9d Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 11 Jun 2025 22:38:45 +0200 Subject: [PATCH] feat: Make it possible to subtract ability cost from pool points --- index.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/index.html b/index.html index 4f628de..dc0fa32 100644 --- a/index.html +++ b/index.html @@ -412,6 +412,7 @@ const btnCreateCharacter = document.getElementById("btn-create-character"); const btnNoCharCreateCharacter = document.getElementById("btn-no-char-create-character"); const btnSaveCharacter = document.getElementById("btn-save-character"); + const btnAbilityDo = document.getElementById("btn-ability-do"); const inpCharacterRoster = document.getElementById("inp-character-roster"); const inpCampaignName = document.getElementById("inp-campaign-name"); @@ -714,6 +715,26 @@ updateAbilityCostDisplay(); }; + const subtractPoolPoints = () => { + var currentPool = getSelectedPool(); + var abilityCost = calculateAbilityCost(); + var poolValue = Number(inpPoolValue[currentPool].value); + + if (abilityCost === null) return; + + updateAbilityCostDisplay(); + + if (poolValue < abilityCost) { + alert("You cannot affort to use this ability now."); + + return; + } + + inpPoolValue[currentPool].value = poolValue - abilityCost; + + updateAbilityCostDisplay(); + }; + document.addEventListener( "DOMContentLoaded", () => { @@ -751,6 +772,7 @@ loadCharacter(selectedID); }); + btnAbilityDo.addEventListener("click", subtractPoolPoints); clearSheet(); loadCharacterRoster(true);