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);