From d0dfd53bc0b6e7ef0e155fc8b049af434a50fa22 Mon Sep 17 00:00:00 2001 From: kopareigns <kopareigns@gmail.com> Date: Fri, 22 Mar 2019 20:22:35 -0400 Subject: [PATCH] JobIDArray and datatypeCleanup work --- src/js/assignJS.js | 25 +++++++++++++++++++++ src/js/datatypeCleanupJS.js | 5 +++-- src/uncategorized/BackwardsCompatibility.tw | 3 +++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/js/assignJS.js b/src/js/assignJS.js index af4e705db55..03285aff851 100644 --- a/src/js/assignJS.js +++ b/src/js/assignJS.js @@ -319,6 +319,7 @@ window.assignJob = function assignJob(slave, job) { r += `${slave.slaveName} no longer has your personal attention.`; } } + V.JobIDArray = resetJobIDArray(); if (idx >= 0) V.slaves[idx] = slave; @@ -514,8 +515,32 @@ window.removeJob = function removeJob(slave, assignment) { slave.choosesOwnAssignment = 0; slave.sentence = 0; } + V.JobIDArray = resetJobIDArray(); if (idx >= 0) V.slaves[idx] = slave; return r; }; + +window.resetJobIDArray = function resetJobIDArray() { /* todo: expand to all assignments */ + const slaves = State.variables.slaves; + const JobIDArray = { + "rest": [], + "please you": [], + "work a glory hole": [], + "take classes": [], + "be a servant": [], + "whore": [], + "serve the public": [], + "get milked": [], + "stay confined": [], + "be a subordinate slave": [] + }; + + slaves.forEach(function (slave) { + if (JobIDArray.hasOwnProperty(slave.assignment)) + JobIDArray[slave.assignment].push(slave.ID); + }); + + return JobIDArray; +}; diff --git a/src/js/datatypeCleanupJS.js b/src/js/datatypeCleanupJS.js index 2608876e7c9..93b6a172a0a 100644 --- a/src/js/datatypeCleanupJS.js +++ b/src/js/datatypeCleanupJS.js @@ -49,9 +49,10 @@ window.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() { return SlaveDatatypeCleanup; /** @param {App.Entity.SlaveState} slave */ - function SlaveDatatypeCleanup(slave) { + function SlaveDatatypeCleanup(slave, isIncubatorSlave) { V = State.variables; - slaveAgeDatatypeCleanup(slave); + if (isIncubatorSlave !== true) + slaveAgeDatatypeCleanup(slave); slavePhysicalDatatypeCleanup(slave); slaveFaceDatatypeCleanup(slave); slaveHairDatatypeCleanup(slave); diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw index b34c0135803..78a049d3f9c 100644 --- a/src/uncategorized/BackwardsCompatibility.tw +++ b/src/uncategorized/BackwardsCompatibility.tw @@ -3356,6 +3356,7 @@ Done<br> Checking and fixing records for incubator tanks... <<for _Slave range $tanks>> <<run App.Entity.Utils.SlaveDataSchemeCleanup(_Slave)>> + <<run SlaveDatatypeCleanup(_Slave, true)>> /* pass second argument as true so that slaveAgeDatatypeCleanup is not run */ <</for>> Done<br> <</if>> @@ -3611,5 +3612,7 @@ Done! <<set $upgradeMultiplierMedicine = upgradeMultiplierMedicine()>> <<set $upgradeMultiplierTrade = upgradeMultiplierTrade()>> +<<set $JobIDArray = resetJobIDArray()>> + /* reset NaNArray after BC is run */ <<set $NaNArray = findNaN()>> -- GitLab