From 1e53be985b80c15258dabea6e8d74a79fe9b8593 Mon Sep 17 00:00:00 2001 From: Svornost <11434-svornost@users.noreply.gitgud.io> Date: Sat, 16 Dec 2023 01:23:34 -0500 Subject: [PATCH] Don't consider implant height in `maxHeight`; instead, consider both implant height and the global maximum height properly at the call sites. --- src/endWeek/player/prDrugs.js | 2 +- src/endWeek/saDrugs.js | 2 +- src/js/utilsAssessSlave.js | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/endWeek/player/prDrugs.js b/src/endWeek/player/prDrugs.js index 40b706d59a0..4b7be0f3c2a 100644 --- a/src/endWeek/player/prDrugs.js +++ b/src/endWeek/player/prDrugs.js @@ -1727,7 +1727,7 @@ App.EndWeek.Player.drugs = function(PC = V.PC) { case Drug.GROWTHSTIM: if (!canImproveHeight(PC)) { r.push(`Your body has grown far past its natural limits, and with their recent reduced effects, it makes sense that the stimulants have also reached their limit. <span class="noteworthy">You stop using them.</span>`); - PC.height = Math.clamp(PC.height, 0, maxHeight(PC)); + PC.height = Math.clamp(PC.height, 0, Math.min(maxHeight(PC) + PC.heightImplant * 10, 274)); PC.drugs = Drug.NONE; } break; diff --git a/src/endWeek/saDrugs.js b/src/endWeek/saDrugs.js index 01e0c8c7782..45c6ba11630 100644 --- a/src/endWeek/saDrugs.js +++ b/src/endWeek/saDrugs.js @@ -1914,7 +1914,7 @@ App.SlaveAssignment.drugs = function saDrugs(slave) { case Drug.GROWTHSTIM: if (!canImproveHeight(slave)) { r += ` ${His} body has already grown far past ${his} natural limits; further injections of stimulants will have no effect. <span class="yellow">${His} drug regimen has been ended.</span>`; - slave.height = Math.clamp(slave.height, 0, maxHeight(slave)); + slave.height = Math.clamp(slave.height, 0, Math.min(maxHeight(slave) + slave.heightImplant * 10, 274)); slave.drugs = Drug.NONE; } break; diff --git a/src/js/utilsAssessSlave.js b/src/js/utilsAssessSlave.js index 74fb0983988..b0268f33c0f 100644 --- a/src/js/utilsAssessSlave.js +++ b/src/js/utilsAssessSlave.js @@ -111,14 +111,15 @@ globalThis.canImproveIntelligence = function(slave) { }; /** + * This function returns the max *growable* height; remember to consider implants at call sites. * @param {FC.HumanState} slave * @returns {number} */ globalThis.maxHeight = function(slave) { - let max = Math.clamp(((slave.natural.height * 1.25) + slave.heightImplant * 10), 0, 274); /* max achievable height is expected height plus 25% */ + let max = Math.clamp(slave.natural.height * 1.25, 0, 274); /* max achievable height is expected height plus 25% */ if (slave.geneticQuirks.neoteny === 2 && slave.physicalAge > 12) { /* Limit neoteny slaves to 12 year old max height */ - max = Math.clamp(((Height.mean(slave.nationality, slave.race, slave.genes, 12) * 1.25) + slave.heightImplant * 10), 0, 274); + max = Math.clamp(Height.mean(slave.nationality, slave.race, slave.genes, 12) * 1.25, 0, 274); } if (slave.geneticQuirks.dwarfism === 2 && slave.geneticQuirks.gigantism !== 2) { @@ -137,7 +138,7 @@ globalThis.maxHeight = function(slave) { * @returns {boolean} */ globalThis.canImproveHeight = function(slave) { - return slave.height < maxHeight(slave); + return slave.height - slave.heightImplant * 10 < maxHeight(slave); }; /** -- GitLab