From e8a57a98c585522c3d7f01c7e5e19bc4aa1785d2 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Mon, 23 Nov 2020 16:34:01 -0500 Subject: [PATCH] more cleanup --- src/endWeek/nextWeek/nextWeek.js | 147 ++++++++---------- .../nextWeek/resetUndocumentedGlobals.js | 32 ++++ 2 files changed, 93 insertions(+), 86 deletions(-) create mode 100644 src/endWeek/nextWeek/resetUndocumentedGlobals.js diff --git a/src/endWeek/nextWeek/nextWeek.js b/src/endWeek/nextWeek/nextWeek.js index 4ffb15e8270..68b4cb1339e 100644 --- a/src/endWeek/nextWeek/nextWeek.js +++ b/src/endWeek/nextWeek/nextWeek.js @@ -5,9 +5,9 @@ App.EndWeek.nextWeek = function() { V.upgradeMultiplierTrade = upgradeMultiplier('trading'); if (V.rivalOwner !== 0) { - const _rival = V.arcologies.find(function(s) { return s.rival === 1; }); - if (_rival) { - V.rivalOwner = _rival.prosperity; + const rival = V.arcologies.find(function(s) { return s.rival === 1; }); + if (rival) { + V.rivalOwner = rival.prosperity; } } @@ -39,47 +39,47 @@ App.EndWeek.nextWeek = function() { // Adding random changes to the economy if (V.difficultySwitch === 1) { - const _globalEconSeed = random(1, 100); - if (_globalEconSeed > 98) { + const globalEconSeed = random(1, 100); + if (globalEconSeed > 98) { V.economy += 2; - } else if (_globalEconSeed > 85) { + } else if (globalEconSeed > 85) { V.economy += 1; - } else if (_globalEconSeed <= 2) { + } else if (globalEconSeed <= 2) { V.economy -= 2; - } else if (_globalEconSeed <= 25 + V.econRate * 10) { + } else if (globalEconSeed <= 25 + V.econRate * 10) { V.economy -= 1; } if (V.economy < 20) { V.economy = 20; } - const _localEconSeed = random(1, 100); + const localEconSeed = random(1, 100); if (V.localEcon <= (V.economy + V.econAdvantage)) { - if (_localEconSeed > 95) { + if (localEconSeed > 95) { V.localEcon += 2; - } else if (_localEconSeed > 50) { + } else if (localEconSeed > 50) { V.localEcon += 1; - } else if (_localEconSeed <= 1) { + } else if (localEconSeed <= 1) { V.localEcon -= 2; - } else if (_localEconSeed <= 10) { + } else if (localEconSeed <= 10) { V.localEcon -= 1; } } else if (V.localEcon <= (V.economy + V.econAdvantage + 5)) { - if (_localEconSeed > 98) { + if (localEconSeed > 98) { V.localEcon += 2; - } else if (_localEconSeed > 66) { + } else if (localEconSeed > 66) { V.localEcon += 1; - } else if (_localEconSeed <= 2) { + } else if (localEconSeed <= 2) { V.localEcon -= 2; - } else if (_localEconSeed <= 33) { + } else if (localEconSeed <= 33) { V.localEcon -= 1; } - } else if (_localEconSeed > 99) { + } else if (localEconSeed > 99) { V.localEcon += 2; - } else if (_localEconSeed > 90) { + } else if (localEconSeed > 90) { V.localEcon += 1; - } else if (_localEconSeed <= 5) { + } else if (localEconSeed <= 5) { V.localEcon -= 2; - } else if (_localEconSeed <= 50) { + } else if (localEconSeed <= 50) { V.localEcon -= 1; } if (V.localEcon < 20) { @@ -106,10 +106,12 @@ App.EndWeek.nextWeek = function() { V.averageTrust = 0; V.averageDevotion = 0; - let _slavesContributing = 0, _OldHG = -1, _NewHG = -1; + let slavesContributing = 0; + let oldHG = -1; + let newHG = -1; if (V.studio === 1) { - for (const _genre of App.Porn.getAllGenres()) { - V.pornStars[_genre.fameVar].p1count = 0; + for (const genre of App.Porn.getAllGenres()) { + V.pornStars[genre.fameVar].p1count = 0; } } for (const slave of V.slaves) { @@ -218,57 +220,59 @@ App.EndWeek.nextWeek = function() { slave.prematureBirth = 0; if (V.HGSuiteEquality === 1 && V.HeadGirlID !== 0 && slave.devotion > 50) { if (slave.assignment === "live with your Head Girl") { - _NewHG = _i; - } else if ((slave.ID === V.HeadGirlID)) { - _OldHG = _i; + newHG = slave.ID; + } else if (slave.ID === V.HeadGirlID) { + oldHG = slave.ID; } } /* AVERAGE VALUES UPDATE */ if (assignmentVisible(slave)) { V.averageTrust += slave.trust; V.averageDevotion += slave.devotion; - _slavesContributing++; - } else if ((slave.assignment !== "be confined in the cellblock") && (slave.assignment !== "be confined in the arcade") && ((slave.assignment !== "work in the dairy") || (V.dairyRestraintsSetting < 2)) && slave.assignment !== "labor in the production line") { + slavesContributing++; + } else if ( + slave.assignment !== "be confined in the cellblock" && + slave.assignment !== "be confined in the arcade" && + (slave.assignment !== "work in the dairy" || V.dairyRestraintsSetting < 2) && + slave.assignment !== "labor in the production line" + ) { V.averageTrust += slave.trust * 0.5; V.averageDevotion += slave.devotion * 0.5; - _slavesContributing += 0.5; + slavesContributing += 0.5; } if (V.studio === 1) { - const _activeGenres = App.Porn.getAllGenres().filter((g) => slave.porn.fame[g.fameVar] > 0); - for (const _genre of _activeGenres) { - V.pornStars[_genre.fameVar].p1count++; + const activeGenres = App.Porn.getAllGenres().filter((g) => slave.porn.fame[g.fameVar] > 0); + for (const genre of activeGenres) { + V.pornStars[genre.fameVar].p1count++; } } if (slave.choosesOwnAssignment > 0) { assignJob(slave, "choose her own job"); } } - if (_slavesContributing !== 0) { - V.averageTrust = V.averageTrust / _slavesContributing; - V.averageDevotion = V.averageDevotion / _slavesContributing; + if (slavesContributing !== 0) { + V.averageTrust = V.averageTrust / slavesContributing; + V.averageDevotion = V.averageDevotion / slavesContributing; } V.enduringTrust = (V.averageTrust + (V.enduringTrust * 3)) / 4; V.enduringDevotion = (V.averageDevotion + (V.enduringDevotion * 3)) / 4; - if (_OldHG !== -1 && _NewHG !== -1) { - const _oldTimeInGrade = V.HGTimeInGrade; - /* preserve time in grade during HG swaps */ - if (V.personalAttention === "HG") { - /* keep removeJob from clearing PC HG supporting. */ - _keepHelpingHG = 1; - } - removeJob(V.slaves[_NewHG], "live with your Head Girl"); - assignJob(V.slaves[_OldHG], "live with your Head Girl"); - assignJob(V.slaves[_NewHG], "be your Head Girl"); - V.slaves[_NewHG].diet = "healthy"; - V.HGTimeInGrade = _oldTimeInGrade; - if (_keepHelpingHG) { + if (oldHG !== -1 && newHG !== -1) { + const oldTimeInGrade = V.HGTimeInGrade; + // preserve time in grade during HG swaps + const keepHelpingHG = (V.personalAttention === "HG"); // keep removeJob from clearing PC HG supporting. + removeJob(getSlave(newHG), "live with your Head Girl"); + assignJob(getSlave(oldHG), "live with your Head Girl"); + assignJob(getSlave(newHG), "be your Head Girl"); + getSlave(newHG).diet = "healthy"; + V.HGTimeInGrade = oldTimeInGrade; + if (keepHelpingHG) { V.personalAttention = "HG"; } } - const _toSearch = V.PC.refreshment.toLowerCase(); - if (_toSearch.indexOf("fertility") !== -1) { + const toSearch = V.PC.refreshment.toLowerCase(); + if (toSearch.indexOf("fertility") !== -1) { V.PC.forcedFertDrugs = 1; } else if (V.PC.forcedFertDrugs > 0) { V.PC.forcedFertDrugs--; @@ -333,38 +337,9 @@ App.EndWeek.nextWeek = function() { V.pit.fought = false; } - /* These are variables that either should be made into _temp vars or should be Zeroed out once done with them instead of here. This can also interfere with debugging or hide NaN's as zeroing things out would clear a NaN. Also could stop from NaN's getting worse? */ - /* Integer and float variables. No real need to zero them out but doesn't hurt to have them in a known state, though this might mask variables NaN'ing out. Takes up the least amount of Memory besides a "" string. */ - V.i = 0; - V.j = 0; - V.averageProsperity = 0; - V.motherSlave = -1; - V.daughterSlave = -1; - V.devMother = -1; - V.devDaughter = -1; - V.alphaTwin = -1; - V.betaTwin = -1; - V.youngerSister = -1; - V.olderSister = -1; - V.boobsID = -1; - V.boobsInterestTargetID = -1; - V.buttslutID = -1; - V.buttslutInterestTargetID = -1; - V.cumslutID = -1; - V.cumslutInterestTargetID = -1; - V.humiliationID = -1; - V.humiliationInterestTargetID = -1; - V.sadistID = -1; - V.sadistInterestTargetID = -1; - V.masochistID = -1; - V.masochistInterestTargetID = -1; - V.domID = -1; - V.dominantInterestTargetID = -1; - V.subID = -1; - V.submissiveInterestTargetID = -1; - V.shelterGirlID = -1; + App.EndWeek.resetUndocumentedGlobals(); - /* Other arrays */ + // Other arrays V.events = []; V.RESSevent = []; V.RESSTRevent = []; @@ -390,7 +365,7 @@ App.EndWeek.nextWeek = function() { V.REInterslaveBeggingIDs = []; V.eligibleSlaves = []; - /* Slave Objects using 0 instead of null. Second most memory eaten up. */ + // Slave Objects using 0 instead of null. Second most memory eaten up. V.activeSlave = 0; V.eventSlave = 0; V.subSlave = 0; @@ -399,16 +374,16 @@ App.EndWeek.nextWeek = function() { V.relative = 0; V.relative2 = 0; - /* Slave Objects that never get zeroed so null them here. Second most memory eaten up. */ + // Slave Objects that never get zeroed so null them here. Second most memory eaten up. V.beforeGingering = null; - /* Strings Memory varies. */ + // Strings Memory varies. V.buyer = ""; V.desc = ""; V.event = ""; V.goto = ""; V.malefactor = ""; - /* Done with zeroing out, what should be for the most part Temps */ + // Done with zeroing out, what should be for the most part Temps if (V.autosave !== 0) { Save.autosave.save("Week Start Autosave"); diff --git a/src/endWeek/nextWeek/resetUndocumentedGlobals.js b/src/endWeek/nextWeek/resetUndocumentedGlobals.js new file mode 100644 index 00000000000..544ae22f3b1 --- /dev/null +++ b/src/endWeek/nextWeek/resetUndocumentedGlobals.js @@ -0,0 +1,32 @@ +App.EndWeek.resetUndocumentedGlobals = function() { + /* These are variables that either should be made into temp vars or should be Zeroed out once done with them instead of here. This can also interfere with debugging or hide NaN's as zeroing things out would clear a NaN. Also could stop from NaN's getting worse? */ + /* Integer and float variables. No real need to zero them out but doesn't hurt to have them in a known state, though this might mask variables NaN'ing out. Takes up the least amount of Memory besides a "" string. */ + V.i = 0; + V.j = 0; + V.averageProsperity = 0; + V.motherSlave = -1; + V.daughterSlave = -1; + V.devMother = -1; + V.devDaughter = -1; + V.alphaTwin = -1; + V.betaTwin = -1; + V.youngerSister = -1; + V.olderSister = -1; + V.boobsID = -1; + V.boobsInterestTargetID = -1; + V.buttslutID = -1; + V.buttslutInterestTargetID = -1; + V.cumslutID = -1; + V.cumslutInterestTargetID = -1; + V.humiliationID = -1; + V.humiliationInterestTargetID = -1; + V.sadistID = -1; + V.sadistInterestTargetID = -1; + V.masochistID = -1; + V.masochistInterestTargetID = -1; + V.domID = -1; + V.dominantInterestTargetID = -1; + V.subID = -1; + V.submissiveInterestTargetID = -1; + V.shelterGirlID = -1; +} \ No newline at end of file -- GitLab