diff --git a/src/endWeek/healthFunctions.js b/src/endWeek/healthFunctions.js index 277e9e68a81efb1b0c04e458d4f24c1b743fcd77..83c00bb43fc5e25c7c613c276bceccbd4dda954f 100644 --- a/src/endWeek/healthFunctions.js +++ b/src/endWeek/healthFunctions.js @@ -269,18 +269,6 @@ window.endWeekHealthDamage = function endWeekHealthDamage(slave) { H.shortDamage += Math.trunc(Math.pow(H.illness, 1.52) * 3 + 2); // 5, 10, 17, 26, 36 points of damage per respective level of illness } - // Reducing condition for tired slaves - if (H.tired > 90) { - tiredToCondition += Math.round((H.tired * 0.1) + 5); - } else if (H.condition >= -20) { - if (H.tired > 60) { - tiredToCondition += Math.round((H.tired * 0.1) + 2); - } - } - if (tiredToCondition > 0) { - H.condition -= tiredToCondition; - } - // Long term damage due to age calculated on birthdays only if (slave.birthWeek === 0 && slave.physicalAge > 29) { H.longDamage += Math.trunc((slave.physicalAge - 25 + jsRandom(1, 15)) / 20); @@ -291,15 +279,39 @@ window.endWeekHealthDamage = function endWeekHealthDamage(slave) { // recovering and transferring short term damage to condition and long term if (H.shortDamage > 0) { - shortToCondition += Math.max(Math.trunc(H.shortDamage * 0.25), 1); // 25% of short term damage gets transferred + shortToCondition += Math.max(Math.trunc(H.shortDamage * 0.5), 1); // 50% of short term damage gets transferred H.shortDamage -= shortToCondition; + if (slave.assignment === "get treatment in the clinic") { + H.shortDamage = Math.trunc(H.shortDamage * 0.5); // An aditional 50% of short term damage reduction (75% total) for getting treatment in the clinic + } else if (slave.assignment === "rest" || slave.assignment === "rest in the spa") { + H.shortDamage = Math.trunc(H.shortDamage * 0.75); // An additional 25% of short term damage reduction (62.5% total) for resting + } if (slave.curatives > 0 || slave.ID === -1) { // transferred damage is half if on preventatives/curatives or target is the player shortToCondition = Math.trunc(shortToCondition * 0.5); } - H.condition -= shortToCondition; - shortToLong += Math.trunc(shortToCondition * 0.25); // 25% of transferred damage gets added to long term damage, minimum of 16 short term damage before any long term damage is accumulated + if (slave.assignment === "get treatment in the clinic") { + shortToCondition = Math.trunc(shortToCondition * 0.75); + } + shortToLong += Math.trunc(shortToCondition * 0.1); // 10% of transferred damage gets added to long term damage, minimum of 20 short term damage before any long term damage is accumulated H.longDamage += shortToLong; } + if (V.baseDifficulty === 1) { // Reducing longDamage up to a certain point depending on the difficulty + if (H.longDamage > 0) { + H.longDamage -= Math.min(Math.trunc(H.longDamage * 0.1), 1); + } + } else if (V.baseDifficulty === 2) { + if (H.longDamage > 20) { + H.longDamage -= Math.min(Math.trunc((H.longDamage - 20) * 0.1), 1); + } + } else if (V.baseDifficulty === 3) { + if (H.longDamage > 40) { + H.longDamage -= Math.min(Math.trunc((H.longDamage - 40) * 0.1), 1); + } + } else if (V.baseDifficulty === 4) { + if (H.longDamage > 60) { + H.longDamage -= Math.min(Math.trunc((H.longDamage - 60) * 0.1), 1); + } + } if (V.disableLongDamage) { H.longDamage = 0; } diff --git a/src/facilities/clinic/clinicFramework.js b/src/facilities/clinic/clinicFramework.js index 1fdf84e80a0b340d56dbb159770241afe12f165f..acc9642d966227ae52c7d91e544e17add0a1e749 100644 --- a/src/facilities/clinic/clinicFramework.js +++ b/src/facilities/clinic/clinicFramework.js @@ -41,7 +41,7 @@ App.Entity.Facilities.ClinicPatientJob = class extends App.Entity.Facilities.Fac checkRequirements(slave) { let r = super.checkRequirements(slave); - if ((slave.health.condition >= 20 && slave.health.illness < 2 && slave.health.shortDamage < 10) && + if ((slave.health.illness === 0 && slave.health.shortDamage < 20 && slave.health.condition >= 40) && (V.Nurse === 0 || ((slave.chem <= 15 || this.facility.upgrade("Filters") !== 1) && (V.bellyImplants !== 1 || slave.bellyImplant <= -1) && (slave.pregKnown !== 1 || (this.facility.option("SpeedGestation") <= 0 && slave.pregControl !== "speed up")) && (slave.pregAdaptation * 1000 >= slave.bellyPreg && slave.preg <= slave.pregData.normalBirth / 1.33)))) { diff --git a/src/facilities/spa/spaFramework.js b/src/facilities/spa/spaFramework.js index 2a55012d1803bf1f75ee46866e15b20427057816..65c5565e9bce14a89f5aabde53437d3701f2e33d 100644 --- a/src/facilities/spa/spaFramework.js +++ b/src/facilities/spa/spaFramework.js @@ -46,7 +46,6 @@ App.Entity.Facilities.SpaAssigneeJob = class extends App.Entity.Facilities.Facil ( slave.devotion < -20 || ( - slave.health.condition >= 50 && slave.health.tired < 20 && slave.trust > 60 && slave.devotion > 60 && diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js index a15930d361acf01bf5df9730f2ca2d4e9247a0ed..85f36214f67075c1df84baba574382ebe99873ce 100644 --- a/src/js/datatypeCleanupJS.js +++ b/src/js/datatypeCleanupJS.js @@ -494,12 +494,12 @@ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() { slave.pubertyAgeXY = Math.max(+slave.pubertyAgeXY, 0) || V.potencyAge; slave.ageAdjust = Math.clamp(+slave.ageAdjust, -40, 40) || 0; slave.NCSyouthening = Math.max(+slave.NCSyouthening, 0) || 0; - slave.health.condition = Math.clamp(slave.health.condition, -100, 100) || 0; slave.health.shortDamage = Math.max(+slave.health.shortDamage, 0) || 0; slave.health.longDamage = Math.max(+slave.health.longDamage, 0) || 0; slave.health.illness = Math.max(+slave.health.illness, 0) || 0; slave.health.tired = Math.clamp(+slave.health.tired, 0, 100) || 0; - slave.health.health = Math.clamp(slave.health.condition - slave.health.shortDamage - slave.health.longDamage, -100, 100) || 0; + slave.health.health = Math.clamp(slave.health.health, -100, 200) || 0; + slave.health.condition = Math.clamp(slave.health.condition, -100, 200) || 0; } /** diff --git a/src/js/descriptionWidgets.js b/src/js/descriptionWidgets.js index 4fdfdbf082a2121e033e7e46a37b0a77c5b5599b..8c2280bc82894338e13cd3e95f110ca20f215050 100644 --- a/src/js/descriptionWidgets.js +++ b/src/js/descriptionWidgets.js @@ -337,11 +337,13 @@ App.Desc.ageAndHealth = function(slave) { r += `${He} is in <span class="yellow">fair health.</span>`; } else if (H.health <= 50) { r += `${He} seems to be in <span class="green">good health.</span>`; + } else if (H.health <= 90) { + r += `${He} seems to be in <span class="green">great health.</span>`; } else { r += `${He} almost gleams; ${he}'s in the absolute <span class="green">best of health.</span>`; } - if (H.shortDamage !== 0 || H.longDamage !== 0) { + if (H.shortDamage !== 0 || H.longDamage !== 0 || H.condition < 0) { r += ` Upon closer inspection you note that ${he}`; if (H.shortDamage >= 100) { @@ -351,42 +353,42 @@ App.Desc.ageAndHealth = function(slave) { } else if (H.shortDamage >= 40) { r += ` is <span class="red">seriouly injured</span> with some lasting effects`; } else if (H.shortDamage >= 20) { - r += ` is <span class="red">injured</span>`; + r += ` is <span class="orange">injured</span>`; } else if (H.shortDamage > 0) { r += ` seems to have suffered a <span class="yellow">minor injury</span> recently`; } - if (H.shortDamage !== 0 && H.longDamage !== 0) { + if (H.shortDamage !== 0 && H.longDamage !== 0 && H.condition < 0) { r += `,`; + } else if ((H.shortDamage !== 0 && H.longDamage !== 0) || (H.shortDamage !== 0 && H.condition < 0)) { + r += ` and`; } - if (H.longDamage >= 50) { + if (H.longDamage >= 70) { r += ` is suffering heavily under accumulated <span class="red">permanent health problems</span>`; - } else if (H.longDamage >= 30) { + } else if (H.longDamage >= 40) { r += ` has some clear <span class="red">permanent health issues</span>`; - } else if (H.longDamage >= 10) { - r += ` shows signs of <span class="red">lasting health problems</span>`; + } else if (H.longDamage >= 20) { + r += ` shows signs of <span class="orange">lasting health problems</span>`; } else if (H.longDamage > 0) { r += ` carries some <span class="yellow">minor niggles</span>`; } - if (H.shortDamage !== 0 || H.longDamage !== 0) { + if ((H.shortDamage !== 0 || H.longDamage !== 0) && H.condition < 0) { r += ` and`; } if (H.condition < -80 && H.shortDamage !== 0 && H.longDamage !== 0) { - r += ` has been treated so badly ${he} <span class="red">is close to the brink</span>.`; + r += ` has been treated so badly ${he} <span class="red">is close to the brink</span>`; } else if (H.condition < -50) { - r += ` appears to be in <span class="red">terrible condition.</span>`; + r += ` appears to be in <span class="red">terrible condition</span>`; } else if (H.condition < -20) { - r += ` appears to be in <span class="red">poor condition.</span>`; - } else if (H.condition <= 20) { - r += ` appears to be in <span class="yellow">decent condition.</span>`; - } else if (H.condition <= 50) { - r += ` appears to be in <span class="green">good condition.</span>`; - } else { - r += ` is clearly <span class="green">in tip top condition.</span>`; + r += ` appears to be in <span class="orange">poor condition</span>`; + } else if (H.condition < 0) { + r += ' could be in <span class="yellow">better condition</span>'; } + + r += `.`; } if (H.tired > 30) { diff --git a/src/js/health.js b/src/js/health.js index 5b96b73c3e6da66f8701a1821dd8f76b7942d86a..8da70fc209bbc2fc8962332afa99627e74bc192e 100644 --- a/src/js/health.js +++ b/src/js/health.js @@ -27,8 +27,10 @@ window.healthPenalty = function healthPenalty(slave) { */ window.healthDamage = function healthDamage(slave, damage) { const H = slave.health; - H.shortDamage += Math.max(Math.trunc(damage), 0); - H.health = H.condition - H.longDamage - H.shortDamage; + damage = Math.max(Math.trunc(damage), 0); + H.shortDamage += damage; + H.condition -= damage; + updateHealth(slave); }; /** @@ -40,9 +42,13 @@ window.healthDamage = function healthDamage(slave, damage) { */ window.healthCure = function healthCure(slave, cure) { const H = slave.health; - H.shortDamage -= Math.max(Math.trunc(cure), 0); - H.shortDamage = Math.max(H.shortDamage, 0); - H.health = H.condition - H.longDamage - H.shortDamage; + cure = Math.max(Math.trunc(cure), 0); + if (cure > H.shortDamage) { + cure = H.shortDamage; + } + H.shortDamage -= cure; + H.condition += cure; + updateHealth(slave); }; /** @@ -65,7 +71,25 @@ window.surgeryDamage = function surgeryDamage(slave, damage) { window.improveCondition = function improveCondition(slave, condition) { const H = slave.health; H.condition += Math.max(Math.trunc(condition), 0); - H.health = H.condition - H.longDamage - H.shortDamage; + updateHealth(slave); +}; + +/** + * Updates slave.health.health + * @param {App.Entity.SlaveState} slave + * @returns {void} + */ +window.updateHealth = function updateHealth(slave) { + const H = slave.health; + const condition = H.condition; + + // Converting the other variables to better fit the same scale as .condition + const damage = (40 - H.shortDamage - H.longDamage) * 2.5; // 100 / -inf + const tired = (40 - H.tired) * 2.5; // 100 / -150 + const illness = (5 - Math.pow(H.illness, 2)) * 20; // 100 / -400 + + // Assigning weights to the different components and aggregating + H.health = condition * 0.6 + damage * 0.2 + tired * 0.1 - illness * 0.1; }; /** diff --git a/src/uncategorized/clinicReport.tw b/src/uncategorized/clinicReport.tw index 0f051540f9fc5be93292bdd80d75b8fce0faceb4..b89cfdb5413fffd2254ab573c6d8e62fc2b5969e 100644 --- a/src/uncategorized/clinicReport.tw +++ b/src/uncategorized/clinicReport.tw @@ -292,7 +292,7 @@ <</if>> <</if>> <<if ($slaves[$i].health.illness > 0)>> - <<elseif ($slaves[$i].health.shortDamage >= 10)>> + <<elseif ($slaves[$i].health.shortDamage >= 20)>> /* shortDamage does no real harm, until it gets to 20 */ <<elseif ($slaves[$i].health.condition <= 40)>> <<elseif ($Nurse != 0) && ($slaves[$i].chem > 15) && ($clinicUpgradeFilters == 1)>> <<elseif ($Nurse != 0) && ($slaves[$i].pregKnown == 1) && ($clinicSpeedGestation > 0 || $slaves[$i].pregControl == "speed up")>> @@ -345,6 +345,8 @@ $He stays in the clinic since $he is still sick. <<elseif ($slaves[$i].health.condition <= 40)>> $He stays in the clinic since $his health is still poor. + <<elseif ($slaves[$i].health.shortDamage >= 20)>> + $He stays in the clinic to recover from $his injuries. <<elseif ($Nurse != 0) && ($slaves[$i].chem > 15) && ($clinicUpgradeFilters == 1)>> $He stays in the clinic as unhealthy chemicals are still being flushed from $his system. <<elseif ($Nurse != 0) && ($slaves[$i].pregKnown == 1) && ($clinicSpeedGestation > 0 || $slaves[$i].pregControl == "speed up")>> diff --git a/src/uncategorized/spaReport.tw b/src/uncategorized/spaReport.tw index 40326adbf1d99702c29b91fa16b674eb377f3e2c..432f9efe44b4da5578b69279a39442a00c208297 100644 --- a/src/uncategorized/spaReport.tw +++ b/src/uncategorized/spaReport.tw @@ -287,7 +287,7 @@ <<default>> <<set $slaves[$i].rules.living = "luxurious">> <</switch>> - <<if ($slaves[$i].health.condition >= 50) && ($slaves[$i].health.tired < 20) && ($slaves[$i].trust > 60) && ($slaves[$i].devotion > 60) && ($slaves[$i].fetish != "mindbroken") && ($slaves[$i].sexualFlaw == "none") && ($slaves[$i].behavioralFlaw == "none")>> + <<if ($slaves[$i].health.condition >= 20) && ($slaves[$i].health.tired < 20) && ($slaves[$i].trust > 60) && ($slaves[$i].devotion > 60) && ($slaves[$i].fetish != "mindbroken") && ($slaves[$i].sexualFlaw == "none") && ($slaves[$i].behavioralFlaw == "none")>> <p> <span class="slave-name">$slaves[$i].slaveName</span> is feeling well enough to leave $spaName, <span class="noteworthy"> @@ -337,7 +337,7 @@ <<elseif ($slaves[$i].trust < 60) || ($slaves[$i].devotion < 60)>> $He remains in the Spa, as $he is still learning to accept life as a slave. <<elseif ($slaves[$i].health.condition < 20)>> - $He remains in the Spa, as $his health is still low. + $He remains in the Spa, as $he is benefiting from its healing properties. <</if>> <br> <<= saChoosesOwnClothes($slaves[$i])>>