From 8e559fa5766a75e7ce2e6c0dfe1713c7b33c5a2d Mon Sep 17 00:00:00 2001
From: DCoded <dcoded@live.com>
Date: Sat, 3 Oct 2020 12:23:20 -0400
Subject: [PATCH] Fixes, moved killSlave

---
 src/004-base/facility.js                                  | 2 +-
 src/data/backwardsCompatibility/backwardsCompatibility.js | 4 ++--
 src/data/backwardsCompatibility/datatypeCleanup.js        | 2 +-
 src/{facilities/pit => interaction}/killSlave.js          | 2 +-
 src/{pregmod => interaction}/killSlave.tw                 | 0
 src/js/assignJS.js                                        | 4 +++-
 6 files changed, 8 insertions(+), 6 deletions(-)
 rename src/{facilities/pit => interaction}/killSlave.js (99%)
 rename src/{pregmod => interaction}/killSlave.tw (100%)

diff --git a/src/004-base/facility.js b/src/004-base/facility.js
index b633f983d19..09222e7fc6d 100644
--- a/src/004-base/facility.js
+++ b/src/004-base/facility.js
@@ -262,7 +262,7 @@ App.Entity.Facilities.Facility = class {
 	/** Facility display name
 	 * @returns {string} */
 	get name() {
-		const res = V[this.desc.baseName + "Name"];
+		const res = V[this.desc.baseName].name || V[this.desc.baseName + "Name"];
 		return res !== undefined ? res : 'the ' + this.genericName;
 	}
 
diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js
index 8811d180bb4..67d3def729c 100644
--- a/src/data/backwardsCompatibility/backwardsCompatibility.js
+++ b/src/data/backwardsCompatibility/backwardsCompatibility.js
@@ -295,9 +295,9 @@ App.Update.globalVariables = function(node) {
 	}
 
 	// Pit
-	if (V.pit) {
-		V.pit = typeof V.pit === "object" ? V.pit : null;
+	V.pit = typeof V.pit === "object" ? V.pit : null;
 
+	if (V.pit) {
 		V.pit.name = V.pit.name || V.pitName || "the Pit";
 		V.pit.virginities = V.pit.virginities || V.pitVirginities || "neither";
 
diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js
index 1072455e4e0..0be7dfb3aaa 100644
--- a/src/data/backwardsCompatibility/datatypeCleanup.js
+++ b/src/data/backwardsCompatibility/datatypeCleanup.js
@@ -1571,7 +1571,7 @@ globalThis.FacilityDatatypeCleanup = (function() {
 		V.cellblockName = V.cellblockName || "the Cellblock";
 		V.masterSuiteName = V.masterSuiteName || "the Master Suite";
 		V.HGSuiteName = V.HGSuiteName || "the Head Girl Suite";
-		V.pit ? V.pit.name = V.pit.name || "the Pit" : null;
+		V.pit.name = V.pit.name || "the Pit";
 		V.incubatorName = V.incubatorName || "the Incubator";
 		V.farmyardName = V.farmyardName || "the Farmyard";
 	}
diff --git a/src/facilities/pit/killSlave.js b/src/interaction/killSlave.js
similarity index 99%
rename from src/facilities/pit/killSlave.js
rename to src/interaction/killSlave.js
index 2ff8f34be25..5fc1b9abf01 100644
--- a/src/facilities/pit/killSlave.js
+++ b/src/interaction/killSlave.js
@@ -5,7 +5,7 @@
  *
  * @param {App.Entity.SlaveState} slave
  */
-App.Facilities.Pit.killSlave = function(slave) {
+App.UI.SlaveInteract.killSlave = function(slave) {
 	// MARK: Declarations
 
 	const frag = new DocumentFragment;
diff --git a/src/pregmod/killSlave.tw b/src/interaction/killSlave.tw
similarity index 100%
rename from src/pregmod/killSlave.tw
rename to src/interaction/killSlave.tw
diff --git a/src/js/assignJS.js b/src/js/assignJS.js
index 6d179a87215..a5443a2aeaf 100644
--- a/src/js/assignJS.js
+++ b/src/js/assignJS.js
@@ -760,7 +760,9 @@ globalThis.makeJobIdMap = function() {
 	}
 
 	// special cases
-	res[Job.PIT] = V.pit ? new Set(V.pit.fighterIDs) : null;
+	if (V.pit) {
+		res[Job.PIT] = new Set(V.pit.fighterIDs);
+	}
 	res[Job.LURCHER].add(V.LurcherID);
 
 	return res;
-- 
GitLab