feat: Create the updateAbilityCostDisplay() helper
This commit is contained in:
22
index.html
22
index.html
@@ -437,6 +437,7 @@
|
|||||||
const inpAbilityEffort = document.getElementById("inp-ability-effort");
|
const inpAbilityEffort = document.getElementById("inp-ability-effort");
|
||||||
|
|
||||||
const dspAbilityPool = document.getElementById("dsp-ability-pool");
|
const dspAbilityPool = document.getElementById("dsp-ability-pool");
|
||||||
|
const dspAbilityCost = document.getElementById("dsp-ability-cost");
|
||||||
|
|
||||||
var characterRoster = {};
|
var characterRoster = {};
|
||||||
var currentCharacter = null;
|
var currentCharacter = null;
|
||||||
@@ -494,6 +495,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentCharacter = characterID;
|
currentCharacter = characterID;
|
||||||
|
updateAbilityCostDisplay();
|
||||||
};
|
};
|
||||||
|
|
||||||
const createCharacter = () => {
|
const createCharacter = () => {
|
||||||
@@ -679,6 +681,25 @@
|
|||||||
return Math.max(0, cost + effortCost - poolEdge);
|
return Math.max(0, cost + effortCost - poolEdge);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateAbilityCostDisplay = () => {
|
||||||
|
var currentPool = getSelectedPool();
|
||||||
|
var cost = calculateAbilityCost();
|
||||||
|
|
||||||
|
clearContainer(dspAbilityCost);
|
||||||
|
|
||||||
|
if ((currentPool === null) || (cost === null)) return;
|
||||||
|
|
||||||
|
var currentPoolValue = Number(inpPoolValue[currentPool].value);
|
||||||
|
|
||||||
|
if (cost > currentPoolValue) {
|
||||||
|
dspAbilityCost.classList.add("warn");
|
||||||
|
} else {
|
||||||
|
dspAbilityCost.classList.remove("warn");
|
||||||
|
}
|
||||||
|
|
||||||
|
dspAbilityCost.appendChild(document.createTextNode(cost));
|
||||||
|
};
|
||||||
|
|
||||||
document.addEventListener(
|
document.addEventListener(
|
||||||
"DOMContentLoaded",
|
"DOMContentLoaded",
|
||||||
() => {
|
() => {
|
||||||
@@ -711,6 +732,7 @@
|
|||||||
clearSheet();
|
clearSheet();
|
||||||
loadCharacterRoster(true);
|
loadCharacterRoster(true);
|
||||||
poolSelectionChanged();
|
poolSelectionChanged();
|
||||||
|
updateAbilityCostDisplay();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user