From 0672a932a04d2707e9ee631743f62210ca6c29e4 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 25 Oct 2021 19:10:59 -0700
Subject: [PATCH 1/2] More PA fixes and cleanup. 1. Fix some more cases where
 selecting non-training tasks didn't reset the active slave. 2. Highlight
 paraphilias in yellow instead of red (matching the slave list). 3. Fix some
 cases where the selected slave list being an empty array was handled
 differently than being deleted entirely. 4. A bit of code cleanup.

---
 src/player/personalAttentionSelect.js | 73 +++++++++++++--------------
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git a/src/player/personalAttentionSelect.js b/src/player/personalAttentionSelect.js
index 23a975e6df4..016cbf5aea0 100644
--- a/src/player/personalAttentionSelect.js
+++ b/src/player/personalAttentionSelect.js
@@ -37,7 +37,7 @@ App.UI.Player.personalAttention = function() {
 		text.push(`This week you are`);
 
 		if (V.personalAttention.task === PersonalAttention.TRAINING) {
-			const r =[];
+			const r = [];
 			for (const slave of V.personalAttention.slaves) {
 				slave.objective = slave.objective || getRegimen(getSlave(slave.ID));
 				r.push(`<span class="slave-name">${SlaveFullName(getSlave(slave.ID))}</span> to <span class="bold">${App.personalAttention.getText(slave.objective, getSlave(slave.ID))}</span>`);
@@ -109,14 +109,14 @@ App.UI.Player.personalAttention = function() {
 				link: `Focus on "connecting"`,
 				value: PersonalAttention.WHORING,
 				prereqs: [
-					() => ["escort", "prostitute", "child prostitute"].includes(V.PC.career),
+					() => isPCCareerInCategory("escort"),
 				],
 			},
 			{
 				link: `Maintain your home`,
 				value: PersonalAttention.MAID,
 				prereqs: [
-					() => ["servant", "handmaiden", "child servant"].includes(V.PC.career),
+					() => isPCCareerInCategory("servant"),
 				],
 			},
 			{
@@ -127,7 +127,7 @@ App.UI.Player.personalAttention = function() {
 				link: `Help people "pass" things around`,
 				value: PersonalAttention.SMUGGLING,
 				prereqs: [
-					() => ["gang", "hoodlum", "street urchin"].includes(V.PC.career),
+					() => isPCCareerInCategory("gang"),
 				],
 			},
 			{
@@ -182,7 +182,7 @@ App.UI.Player.personalAttention = function() {
 						]));
 					} else {
 						links.push(App.UI.DOM.link(link.link, () => {
-							V.personalAttention.task = link.value;
+							V.personalAttention = {task: link.value};
 
 							refresh();
 						}));
@@ -393,7 +393,6 @@ App.UI.Player.personalAttention = function() {
 			 */
 			function addSkill(skill, text, link) {
 				const div = document.createElement("div");
-				const an = ['a', 'e', 'i', 'o', 'u'].includes(text[0]) ? `an` : `a`;
 
 				if (V.PC.skill[skill] >= 100) {
 					skillMaster.push(`${text}`);
@@ -401,11 +400,11 @@ App.UI.Player.personalAttention = function() {
 					if (V.PC.skill[skill] > 60) {
 						div.append(`You are an expert ${text}.`);
 					} else if (V.PC.skill.hacking > 30) {
-						div.append(`You have some skill as ${an} ${text}.`);
+						div.append(`You have some skill as ${addA(text)}.`);
 					} else if (V.PC.skill.hacking > 10) {
-						div.append(`You have basic knowledge as ${an} ${text}.`);
+						div.append(`You have basic knowledge as ${addA(text)}.`);
 					} else {
-						div.append(`You have no knowledge as ${an} ${text}.`);
+						div.append(`You have no knowledge as ${addA(text)}.`);
 					}
 
 					addLink(div, {
@@ -427,7 +426,7 @@ App.UI.Player.personalAttention = function() {
 						]), ['margin-left']);
 					} else {
 						App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(skill.link, () => {
-							V.personalAttention.task = skill.value;
+							V.personalAttention = {task: skill.value};
 
 							refresh();
 						}, null, '', `Training will cost ${cashFormat(cost)} per week.`), ['margin-left']);
@@ -459,7 +458,7 @@ App.UI.Player.personalAttention = function() {
 
 		const frag = new DocumentFragment();
 		App.UI.DOM.appendNewElement("h2", frag, `Slaves`);
-		if (!V.personalAttention.slaves) {
+		if (!V.personalAttention.slaves || V.personalAttention.slaves.length === 0) {
 			frag.append(`You have not selected a slave for your personal attention.`);
 		} else {
 			if (V.personalAttention.slaves.length > (V.PC.skill.slaving >= 100 ? 2 : 1)) {	// ensure only the maximum number of slaves are being trained
@@ -478,14 +477,14 @@ App.UI.Player.personalAttention = function() {
 				const {He, him, his} = getPronouns(slave);
 				let text = [];
 				let links = [];
-				V.personalAttention.slaves[i].objective = V.personalAttention.slaves[i].objective || getRegimen(slave, regimen);
+				V.personalAttention.slaves[i].objective = V.personalAttention.slaves[i].objective || getRegimen(slave);
 				text.push(
 					`You will give`,
 					App.UI.DOM.referenceSlaveWithPreview(slave, SlaveFullName(slave)),
 					`your personal attention this week to ${App.personalAttention.getText(V.personalAttention.slaves[i].objective, slave)}.`,
 					App.UI.DOM.link(`Stop`, () => {
 						if (V.personalAttention.slaves.length === 1) {
-							V.personalAttention.task = PersonalAttention.SEX;
+							V.personalAttention = {task: PersonalAttention.SEX};
 						} else {
 							V.personalAttention.slaves.deleteAt(i);
 						}
@@ -636,16 +635,17 @@ App.UI.Player.personalAttention = function() {
 
 				// Sexual Flaws
 				if (slave.sexualFlaw !== "none") {
+					const isParaphilia = App.Data.misc.paraphiliaList.includes(slave.sexualFlaw);
 					App.Events.addNode(div, [
-						`Current sexual flaw: <span class="red">${capFirstChar(slave.sexualFlaw)}.</span>`,
+						`Current sexual flaw: <span class=${isParaphilia ? "yellow" : "red"}>${capFirstChar(slave.sexualFlaw)}.</span>`,
 					]);
-					links.push(attentionLink(i, `Remove ${his} sexual flaw`, "fix sexual flaw"));
+					links.push(attentionLink(i, `Remove ${his} ${isParaphilia ? "paraphilia" : "sexual flaw"}`, "fix sexual flaw"));
 
 					if (slave.devotion < -20) {
 						links.push(App.UI.DOM.disabledLink(`Soften ${his} sexual flaw`, [
 							`${He} must be broken before ${his} flaws can be softened`
 						]));
-					} else if (App.Data.misc.paraphiliaList.includes(slave.sexualFlaw)) {
+					} else if (isParaphilia) {
 						links.push(App.UI.DOM.disabledLink(`Soften ${his} sexual flaw`, [
 							`Paraphilias cannot be softened`
 						]));
@@ -871,6 +871,7 @@ App.UI.Player.personalAttention = function() {
 		} else {
 			const paIndex = V.personalAttention.slaves.findIndex(s => s.ID === id);
 			if (paIndex === -1) { // not already a PA target; add
+				V.personalAttention.task = PersonalAttention.TRAINING; // make sure
 				V.personalAttention.slaves.push({
 					ID: id,
 					objective: getRegimen(getSlave(id)),
@@ -913,32 +914,30 @@ App.UI.Player.personalAttention = function() {
 
 		return frag;
 	}
+
 	/**
 	 * @param {App.Entity.SlaveState} slave
-	 * @param {string} regimen
 	 * @returns {string}
 	 */
-	function getRegimen(slave, regimen = null) {
-		if (!regimen) {
-			if (slave.health.condition < -20) {
-				return `health`;
-			} else if (slave.behavioralFlaw !== "none") {
-				if (slave.devotion < -20) {
-					return `fix behavioral flaw`;
-				} else {
-					return `soften behavioral flaw`;
-				}
-			} else if (slave.sexualFlaw !== "none") {
-				if (slave.devotion < -20 || App.Data.misc.paraphiliaList.includes(slave.sexualFlaw)) {
-					return `fix sexual flaw`;
-				} else {
-					return `soften sexual flaw`;
-				}
-			} else if (!slave.fetishKnown) {
-				return `explore sexuality`;
-			} else if (slave.devotion <= 20 && slave.trust >= -20) {
-				return `break will`;
+	function getRegimen(slave) {
+		if (slave.health.condition < -20) {
+			return `health`;
+		} else if (slave.behavioralFlaw !== "none") {
+			if (slave.devotion < -20) {
+				return `fix behavioral flaw`;
+			} else {
+				return `soften behavioral flaw`;
+			}
+		} else if (slave.sexualFlaw !== "none") {
+			if (slave.devotion < -20 || App.Data.misc.paraphiliaList.includes(slave.sexualFlaw)) {
+				return `fix sexual flaw`;
+			} else {
+				return `soften sexual flaw`;
 			}
+		} else if (!slave.fetishKnown) {
+			return `explore sexuality`;
+		} else if (slave.devotion <= 20 && slave.trust >= -20) {
+			return `break will`;
 		}
 		return `build devotion`;
 	}
-- 
GitLab


From 69b5fcf95e92e0562f80060f0169406b04ebc7df Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Mon, 25 Oct 2021 19:18:48 -0700
Subject: [PATCH 2/2] Print different text for paraphilia removal than sexual
 flaw fixing

---
 src/js/personalAttentionFunctions.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/js/personalAttentionFunctions.js b/src/js/personalAttentionFunctions.js
index 8d21b0ea1b1..a580106dde3 100644
--- a/src/js/personalAttentionFunctions.js
+++ b/src/js/personalAttentionFunctions.js
@@ -54,7 +54,11 @@ App.personalAttention.getText = function(objective, slave) {
 		case "soften sexual flaw":
 			return `soften ${his} sexual flaw`;
 		case "fix sexual flaw":
-			return `fix ${his} sexual flaw`;
+			if (App.Data.misc.paraphiliaList.includes(slave.sexualFlaw)) {
+				return `remove ${his} paraphilia`;
+			} else {
+				return `fix ${his} sexual flaw`;
+			}
 		case "break will":
 			return `break ${his} will`;
 		case "harshly break will":
-- 
GitLab