From fbd71d48dcedd9b1061469c918c0796c7c0f2d02 Mon Sep 17 00:00:00 2001
From: ezsh <ezsh.junk@gmail.com>
Date: Tue, 5 May 2020 22:18:34 +0200
Subject: [PATCH] Refactor resetJobIDArray() to cover all assignments.

---
 src/js/assignJS.js | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/src/js/assignJS.js b/src/js/assignJS.js
index 1f793525faa..7beb1a286ea 100644
--- a/src/js/assignJS.js
+++ b/src/js/assignJS.js
@@ -726,28 +726,19 @@ globalThis.assignmentVisible = function(slave) {
 	return true;
 };
 
+/**
+ * @returns {Object.<string, number[]>} dictionary assignment -> slave IDs
+ */
 globalThis.resetJobIDArray = function() {
-	/* todo: expand to all assignments */
-
-	const slaves = V.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": []
-	};
+	/** @type {Object.<string, number[]>} */
+	const JobIDArray = {};
+	for (const jn of Object.values(Job)) {
+		JobIDArray[jn] = [];
+	}
 
-	slaves.forEach(function(slave) {
-		if (JobIDArray.hasOwnProperty(slave.assignment)) {
-			JobIDArray[slave.assignment].push(slave.ID);
-		}
-	});
+	for (const slave of V.slaves) {
+		JobIDArray[slave.assignment].push(slave.ID);
+	}
 
 	return JobIDArray;
 };
-- 
GitLab