From 74c129c498050c509a964074f38ac61e959fdebc Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@mailbox.org> Date: Tue, 17 May 2022 23:10:36 +0200 Subject: [PATCH] Remove global V.slaveAfterRA and use a local function instead --- devTools/types/FC/gameState.d.ts | 3 +- .../backwardsCompatibility.js | 3 +- src/endWeek/reports/penthouseReport.js | 28 ++++++++++++------- src/js/rulesAssistant.js | 11 -------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/devTools/types/FC/gameState.d.ts b/devTools/types/FC/gameState.d.ts index 748bce5e5d8..7226eeb1442 100644 --- a/devTools/types/FC/gameState.d.ts +++ b/devTools/types/FC/gameState.d.ts @@ -34,7 +34,7 @@ declare namespace FC { ID?: number; FS: { name: string; - race?: FC.Race; + race?: FC.Race; adopted?: number; } /** @@ -103,7 +103,6 @@ declare namespace FC { interface TemporaryVariablesInTheGameState { gameover?: string; sortQuickList?: string; - slaveAfterRA?: SlaveState; /** @deprecated */ returnTo: string; diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index c104e5d782e..166bd2ffb9b 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -141,7 +141,7 @@ App.Update.globalVariables = function(node) { if (V.hostageAnnounced && !V.slaves.find(s => s.origin.includes("You were acquainted with $him before you were an arcology owner") && s.newGamePlus === 0)) { V.rival.hostageState = 1; } - V.rival.hostageState = V.rival.hostageState || 0; + V.rival.hostageState = V.rival.hostageState || 0; V.rival.state = V.rival.state || 0; V.rival.prosperity = V.rival.prosperity || 0; @@ -1462,7 +1462,6 @@ App.Update.slaveIndices = function(node) { App.Update.slaveRecords = function(node) { const detachedSlaves = [ V.hostage, - V.slaveAfterRA, V.boomerangSlave, V.traitor, V.shelterSlave diff --git a/src/endWeek/reports/penthouseReport.js b/src/endWeek/reports/penthouseReport.js index f2dc91c5624..33a654b7649 100644 --- a/src/endWeek/reports/penthouseReport.js +++ b/src/endWeek/reports/penthouseReport.js @@ -518,6 +518,19 @@ App.EndWeek.penthouseReport = function() { App.Events.addNode(el, r, "div", "indent"); return el; + /** + * Gives a back a clone with RA applied to it. The original is not modified. + * Call and then check potential change against it to see if the RA would revert it. + * + * @param {FC.SlaveState} slave + * @returns {FC.SlaveState} + */ + function slaveAfterRA(slave) { + const after = clone(slave); + DefaultRules(after); + return after; + } + function piercingCheck() { let piercingForbidden = 0; if (slave.piercing.ear.weight === 0 && slave.earShape !== "none") { @@ -526,8 +539,7 @@ App.EndWeek.penthouseReport = function() { } else { slave.piercing.ear.weight = 1; } - RulesDeconfliction(slave); - if (slave.piercing.ear.weight !== V.slaveAfterRA.piercing.ear.weight) { + if (slave.piercing.ear.weight !== slaveAfterRA(slave).piercing.ear.weight) { piercingForbidden = 1; slave.piercing.ear.weight = 0; } else { @@ -546,8 +558,7 @@ App.EndWeek.penthouseReport = function() { } else { slave.piercing.nose.weight = 1; } - RulesDeconfliction(slave); - if (slave.piercing.nose.weight !== V.slaveAfterRA.piercing.nose.weight) { + if (slave.piercing.nose.weight !== slaveAfterRA(slave).piercing.nose.weight) { piercingForbidden = 1; slave.piercing.nose.weight = 0; } else { @@ -566,8 +577,7 @@ App.EndWeek.penthouseReport = function() { } else { slave.piercing.eyebrow.weight = 1; } - RulesDeconfliction(slave); - if (slave.piercing.eyebrow.weight !== V.slaveAfterRA.piercing.eyebrow.weight) { + if (slave.piercing.eyebrow.weight !== slaveAfterRA(slave).piercing.eyebrow.weight) { piercingForbidden = 1; slave.piercing.eyebrow.weight = 0; } else { @@ -586,8 +596,7 @@ App.EndWeek.penthouseReport = function() { } else { slave.piercing.lips.weight = 1; } - RulesDeconfliction(slave); - if (slave.piercing.lips.weight !== V.slaveAfterRA.piercing.lips.weight) { + if (slave.piercing.lips.weight !== slaveAfterRA(slave).piercing.lips.weight) { piercingForbidden = 1; slave.piercing.lips.weight = 0; } else { @@ -606,8 +615,7 @@ App.EndWeek.penthouseReport = function() { } else { slave.piercing.navel.weight = 1; } - RulesDeconfliction(slave); - if (slave.piercing.navel.weight !== V.slaveAfterRA.piercing.navel.weight) { + if (slave.piercing.navel.weight !== slaveAfterRA(slave).piercing.navel.weight) { piercingForbidden = 1; slave.piercing.navel.weight = 0; } else { diff --git a/src/js/rulesAssistant.js b/src/js/rulesAssistant.js index 4c47a46bac4..5c27802b112 100644 --- a/src/js/rulesAssistant.js +++ b/src/js/rulesAssistant.js @@ -357,17 +357,6 @@ App.RA.newRule = function() { */ globalThis.emptyDefaultRule = App.RA.newRule.rule; -/** - * Saves the slave, silently fires the RA, saves the slave's after-RA state, and then reverts the slave. - * Call and then check potential change against V.slaveAfterRA to see if the RA would revert it. - * @param {App.Entity.SlaveState} slave - */ -globalThis.RulesDeconfliction = function(slave) { - const before = clone(slave); - DefaultRules(slave); - V.slaveAfterRA = clone(slave); - slave = before; -}; /** * Creates RA target object used in rules for body properties -- GitLab