diff --git a/src/js/health.js b/src/js/health.js index 824a1a3376aab8d9b4c8d17c84319d9dafe83abc..5bdaef114218dee478c9b127dee7c7fb371cc58a 100644 --- a/src/js/health.js +++ b/src/js/health.js @@ -28,6 +28,9 @@ globalThis.healthPenalty = function(slave) { * @returns {void} */ globalThis.healthDamage = function(slave, damage) { + if (!_.isFinite(damage)) { + throw "Health damage must be a finite number."; + } const H = slave.health; damage = Math.max(Math.trunc(damage), 0); H.shortDamage += damage; @@ -43,6 +46,9 @@ globalThis.healthDamage = function(slave, damage) { * @returns {void} */ globalThis.healthCure = function(slave, cure) { + if (!_.isFinite(cure)) { + throw "Health cure must be a finite number."; + } const H = slave.health; cure = Math.max(Math.trunc(cure), 0); if (cure > H.shortDamage) { @@ -71,6 +77,9 @@ globalThis.surgeryDamage = function(slave, damage) { * @returns {void} */ globalThis.improveCondition = function(slave, condition) { + if (!_.isFinite(condition)) { + throw "Health condition change must be a finite number."; + } const H = slave.health; H.condition += Math.max(Math.trunc(condition), 0); updateHealth(slave);