From 11fcc424b848e046f7d1f0917334e1f75523a46c Mon Sep 17 00:00:00 2001 From: AlacoGit <alacofruxo@gmail.com> Date: Fri, 7 Mar 2025 14:53:38 +0100 Subject: [PATCH 1/3] Allow RA to re-assign slaves to previous assignment --- src/js/DefaultRules.js | 13 +++++++++++++ src/js/rulesAssistantOptions.js | 1 + 2 files changed, 14 insertions(+) diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index 3dce8a687ba..2b925d3459a 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -133,6 +133,19 @@ globalThis.DefaultRules = function(slave, options) { delete rule.setAssignment; return rule; } + + // RA uses "@prevAssignment" to indicate that the player wants the slave to return to their previous Assignment + // @ts-ignore - this comparison is intentional + if (rule.setAssignment === "@prevAssignment"){ + // Since assignmentRecord doesn't include which arcology the agent came from we can never auto assign to this job + if ([Job.AGENT, Job.AGENTPARTNER].includes(V.assignmentRecords[slave.ID])){ + delete rule.setAssignment; + return rule; + } + rule.setAssignment = V.assignmentRecords[slave.ID]; + } + + const job = App.Utils.jobForAssignment(rule.setAssignment); if (job === undefined) { r += `<span class="red">No job for assignment '${rule.setAssignment}'.</span>`; diff --git a/src/js/rulesAssistantOptions.js b/src/js/rulesAssistantOptions.js index e15c6a715ac..f8be8f23157 100644 --- a/src/js/rulesAssistantOptions.js +++ b/src/js/rulesAssistantOptions.js @@ -4286,6 +4286,7 @@ App.RA.options = (function() { items.push([f.manager.desc.position, f.manager.desc.assignment]); } } + items.push(["Previous Assignment", "@prevAssignment"]); super("Automatically set assignment", items); this.setValue(current_rule.set.setAssignment); -- GitLab From 09c1fba787c29fd5be3c44c98069b353e6a98ca5 Mon Sep 17 00:00:00 2001 From: AlacoGit <alacofruxo@gmail.com> Date: Fri, 7 Mar 2025 15:09:44 +0100 Subject: [PATCH 2/3] handle case where slaves can't be re-assigned --- src/js/DefaultRules.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index 2b925d3459a..cf0b098335b 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -137,10 +137,12 @@ globalThis.DefaultRules = function(slave, options) { // RA uses "@prevAssignment" to indicate that the player wants the slave to return to their previous Assignment // @ts-ignore - this comparison is intentional if (rule.setAssignment === "@prevAssignment"){ - // Since assignmentRecord doesn't include which arcology the agent came from we can never auto assign to this job - if ([Job.AGENT, Job.AGENTPARTNER].includes(V.assignmentRecords[slave.ID])){ - delete rule.setAssignment; - return rule; + // In these cases we can't auto re-assign the slave, either because we don't know which arcology the slave came from(AGENT jobs) + // or because the slave doesn't have a job to return to. + // We set the slaves assignment to REST since that is probably closer to what the player wanted + // rather than leaving the slave in their current assignment + if ([Job.AGENT, Job.AGENTPARTNER].includes(V.assignmentRecords[slave.ID]) || V.assignmentRecords[slave.ID] === undefined){ + rule.setAssignment = Job.REST; } rule.setAssignment = V.assignmentRecords[slave.ID]; } -- GitLab From dd2ae958119058cca2855a51783cfb9bb235c7d2 Mon Sep 17 00:00:00 2001 From: AlacoGit <alacofruxo@gmail.com> Date: Fri, 7 Mar 2025 15:15:01 +0100 Subject: [PATCH 3/3] fix --- src/js/DefaultRules.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index cf0b098335b..c7b8fcecd6c 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -143,8 +143,9 @@ globalThis.DefaultRules = function(slave, options) { // rather than leaving the slave in their current assignment if ([Job.AGENT, Job.AGENTPARTNER].includes(V.assignmentRecords[slave.ID]) || V.assignmentRecords[slave.ID] === undefined){ rule.setAssignment = Job.REST; + } else { + rule.setAssignment = V.assignmentRecords[slave.ID]; } - rule.setAssignment = V.assignmentRecords[slave.ID]; } -- GitLab