diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index 3dce8a687ba26bd8a2e56ba3e11e8eb6ee02f0ce..c7b8fcecd6c9b07225cc6f82f6c88fb44437d47a 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -133,6 +133,22 @@ 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"){ + // 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; + } else { + 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 e15c6a715ac53d2f771220ad2ab74efe9f767efd..f8be8f231578f211f997ed8367f7098b7256f946 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);