feat: Create the calculateAbilityCost() helper
This commit is contained in:
14
index.html
14
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",
|
||||
() => {
|
||||
|
Reference in New Issue
Block a user