diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt index 5c1848870bad1628597d5aba957910ea2ed9b459..65831888e7235dae8158fdc1d867b42933920385 100644 --- a/devNotes/Useful JS Function Documentation.txt +++ b/devNotes/Useful JS Function Documentation.txt @@ -22,6 +22,8 @@ PiercingScore(slave) - Returns int representing degree of piercings. Higher mean TatScore(slave) - Returns int representing degree of tattooing. Higher means more tattoos. +canImproveIntelligence(slave) - Returns if slave intelligence can be improved with Psychostimulants + sameAssignmentP(slave, slave) - Returns if slaves are on the same assignment. haveRelationP(slave1, slave2) - Returns if slave1 is related to second slave2. (NOT extended family mode compliant). diff --git a/src/js/assayJS.js b/src/js/assayJS.js index 514f84e69ca5ebe9a600ddae2d7aa9d9f35e9381..c4835e1eba9eca7def98e3c5f48e950c2d060917 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -7,6 +7,16 @@ window.sameAssignmentP = function sameAssignmentP(A, B) { return A.assignment === B.assignment; }; +/** + * @param {App.Entity.SlaveState} slave + * @returns {boolean} + */ +window.canImproveIntelligence = function canImproveIntelligence(slave) { + let origIntel = V.genePool.find(function(s) { return s.ID == slave.ID; }).intelligence + return (slave.intelligence < origIntel+15) && (slave.intelligence < 100) +}; + + /** * @param {App.Entity.SlaveState} slave * @param {App.Entity.SlaveState} target diff --git a/src/uncategorized/saDrugs.tw b/src/uncategorized/saDrugs.tw index fa8a1bac291e6ff32f2ed9fc9ad16ddf182bffbc..cc4ee86fb15d96969a79ff3ec9a7c67524dcb5df 100644 --- a/src/uncategorized/saDrugs.tw +++ b/src/uncategorized/saDrugs.tw @@ -1519,8 +1519,7 @@ <<set $slaves[$i].drugs = "no drugs">> <</if>> <<case "psychostimulants">> - <<set _origIntel = $genePool.find(function(s) { return s.ID == $slaves[$i].ID; }).intelligence>> - <<if ($slaves[$i].intelligence >= _origIntel+15) || ($slaves[$i].intelligence >= 100)>> + <<if !canImproveIntelligence($activeSlave)>> $His intelligence has been improved as much as a drink possibly can. @@.yellow;$His drug regimen has been ended.@@ <<set $slaves[$i].drugs = "no drugs">> <</if>> diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index 912fffb0399344a98f984ade8919101243d99129..f5276ac54f716a65541bf1ecf2daa1f59f56a568 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -1044,8 +1044,7 @@ | Psychosuppressants <</if>> <<if $arcologies[0].FSSlaveProfessionalismResearch == 1>> - <<set _origIntel = $genePool.find(function(s) { return s.ID == $activeSlave.ID; }).intelligence>> - <<if ($activeSlave.intelligence < _origIntel+15) && ($activeSlave.intelligence < 100)>> + <<if canImproveIntelligence($activeSlave)>> | <<link "Psychostimulants">><<set $activeSlave.drugs = "psychostimulants">><<SlaveInteractDrugs>><</link>> <<else>> | Psychostimulants diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw index adee9b46db763f178a76202a738cf40be33dcafd..bc92127207face99afe4770c1761f813156e90e8 100644 --- a/src/utility/miscWidgets.tw +++ b/src/utility/miscWidgets.tw @@ -145,8 +145,7 @@ Call as <<SlaveInteractDrugs>> | Psychosuppressants <</if>> <<if $arcologies[0].FSSlaveProfessionalismResearch == 1>> - <<set _origIntel = $genePool.find(function(s) { return s.ID == $activeSlave.ID; }).intelligence>> - <<if ($activeSlave.intelligence < _origIntel+15) && ($activeSlave.intelligence < 100)>> + <<if canImproveIntelligence($activeSlave)>> | <<link "Psychostimulants">><<set $activeSlave.drugs = "psychostimulants">><<SlaveInteractDrugs>><</link>> <<else>> | Psychostimulants