From 6ff446d5df70be7c9e17deedbe7a5b99d75ab5cd Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Mon, 1 Mar 2021 01:01:50 +0100 Subject: [PATCH] Dedupe --- src/js/assignJS.js | 17 ++--------------- src/js/removeSlave.js | 8 +------- src/js/utilsPC.js | 9 +++++++++ 3 files changed, 12 insertions(+), 22 deletions(-) create mode 100644 src/js/utilsPC.js diff --git a/src/js/assignJS.js b/src/js/assignJS.js index 06659766ee5..32f86468427 100644 --- a/src/js/assignJS.js +++ b/src/js/assignJS.js @@ -431,13 +431,7 @@ globalThis.assignJob = function(slave, job) { if (!assignmentVisible(slave) && Array.isArray(V.personalAttention)) { if (V.personalAttention.deleteWith(s => s.ID === slave.ID).length > 0) { if (V.personalAttention.length === 0) { - if (V.PC.career === "escort" || V.PC.career === "prostitute" || V.PC.career === "child prostitute") { - V.personalAttention = "whoring"; - } else if (V.PC.career === "servant" || V.PC.career === "handmaiden" || V.PC.career === "child servant") { - V.personalAttention = "upkeep"; - } else { - V.personalAttention = "business"; - } + resetPersonalAttention(); r += `${slave.slaveName} no longer has your personal attention; you plan to focus on ${V.personalAttention}.`; } else { r += `${slave.slaveName} no longer has your personal attention.`; @@ -641,14 +635,7 @@ globalThis.removeJob = function(slave, assignment, saveRecord = false) { } } if (V.personalAttention === "HG" && attentionCheck === 1) { - if (V.PC.career === "escort" || V.PC.career === "prostitute" || V.PC.career === "child prostitute") { - V.personalAttention = "whoring"; - } else if (V.PC.career === "servant" || V.PC.career === "handmaiden" || V.PC.career === "child servant") { - V.personalAttention = "upkeep"; - } else { - V.personalAttention = "business"; - } - + resetPersonalAttention(); r += `You no longer have a slave assigned to be your Head Girl, so you turn your personal attention to focus on ${V.personalAttention}.`; } V.HGTimeInGrade = 0; diff --git a/src/js/removeSlave.js b/src/js/removeSlave.js index 071678f08b8..d879b6ff8f1 100644 --- a/src/js/removeSlave.js +++ b/src/js/removeSlave.js @@ -129,13 +129,7 @@ globalThis.removeSlave = function(slave) { if (Array.isArray(V.personalAttention)) { V.personalAttention.deleteWith(s => s.ID === AS_ID); if (V.personalAttention.length === 0) { - if (V.PC.career === "escort" || V.PC.career === "prostitute" || V.PC.career === "child prostitute") { - V.personalAttention = "whoring"; - } else if (V.PC.career === "servant" || V.PC.career === "handmaiden" || V.PC.career === "child servant") { - V.personalAttention = "upkeep"; - } else { - V.personalAttention = "business"; - } + resetPersonalAttention(); } } diff --git a/src/js/utilsPC.js b/src/js/utilsPC.js new file mode 100644 index 00000000000..4d1e516a74c --- /dev/null +++ b/src/js/utilsPC.js @@ -0,0 +1,9 @@ +globalThis.resetPersonalAttention = function() { + if (V.PC.career === "escort" || V.PC.career === "prostitute" || V.PC.career === "child prostitute") { + V.personalAttention = "whoring"; + } else if (V.PC.career === "servant" || V.PC.career === "handmaiden" || V.PC.career === "child servant") { + V.personalAttention = "upkeep"; + } else { + V.personalAttention = "business"; + } +}; -- GitLab