feat: Make it possible to subtract ability cost from pool points
This commit is contained in:
22
index.html
22
index.html
@@ -412,6 +412,7 @@
|
|||||||
const btnCreateCharacter = document.getElementById("btn-create-character");
|
const btnCreateCharacter = document.getElementById("btn-create-character");
|
||||||
const btnNoCharCreateCharacter = document.getElementById("btn-no-char-create-character");
|
const btnNoCharCreateCharacter = document.getElementById("btn-no-char-create-character");
|
||||||
const btnSaveCharacter = document.getElementById("btn-save-character");
|
const btnSaveCharacter = document.getElementById("btn-save-character");
|
||||||
|
const btnAbilityDo = document.getElementById("btn-ability-do");
|
||||||
|
|
||||||
const inpCharacterRoster = document.getElementById("inp-character-roster");
|
const inpCharacterRoster = document.getElementById("inp-character-roster");
|
||||||
const inpCampaignName = document.getElementById("inp-campaign-name");
|
const inpCampaignName = document.getElementById("inp-campaign-name");
|
||||||
@@ -714,6 +715,26 @@
|
|||||||
updateAbilityCostDisplay();
|
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(
|
document.addEventListener(
|
||||||
"DOMContentLoaded",
|
"DOMContentLoaded",
|
||||||
() => {
|
() => {
|
||||||
@@ -751,6 +772,7 @@
|
|||||||
|
|
||||||
loadCharacter(selectedID);
|
loadCharacter(selectedID);
|
||||||
});
|
});
|
||||||
|
btnAbilityDo.addEventListener("click", subtractPoolPoints);
|
||||||
|
|
||||||
clearSheet();
|
clearSheet();
|
||||||
loadCharacterRoster(true);
|
loadCharacterRoster(true);
|
||||||
|
Reference in New Issue
Block a user