From 39ec07cefc96eae28ca5f2baf61a7815e4b565b7 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Sat, 10 Jul 2021 19:51:00 -0400
Subject: [PATCH] romeo

---
 src/events/nonRandom/mercs/pMercenaryRomeo.js | 212 +++++++++---------
 1 file changed, 110 insertions(+), 102 deletions(-)

diff --git a/src/events/nonRandom/mercs/pMercenaryRomeo.js b/src/events/nonRandom/mercs/pMercenaryRomeo.js
index e546ae4b40e..0d08afcb97d 100644
--- a/src/events/nonRandom/mercs/pMercenaryRomeo.js
+++ b/src/events/nonRandom/mercs/pMercenaryRomeo.js
@@ -7,36 +7,45 @@ App.Events.PMercenaryRomeo = class PMercenaryRomeo extends App.Events.BaseEvent
 		];
 	}
 
-	actorPrerequisites() {
-		return [[
-			(s) => ([Job.PUBLIC, Job.CLUB, Job.WHORE, Job.BROTHEL].includes(s.assignment) || s.counter.publicUse >= 50),
-			(s) => s.fetish !== "mindbroken",
-			(s) => s.fuckdoll === 0
-		]]
-	}
-
 	execute(node) {
 		let r = [];
 		V.nextButton = "Continue";
 		V.nextLink = "Random Nonindividual Event";
-		let _name = 0;
+		/** @type {FC.Zeroable<string>} */
+		let name = 0;
+		let _slaveCost;
+		let juliet;
 
-		const _juliet = getSlave(this.actors[0]);
+		let _romeoSlaves = V.slaves.filter(function(s) { return s.fetish !== "mindbroken" && s.fuckdoll === 0 && ["serve in the club", "serve the public", "whore", "work in the brothel"].includes(s.assignment); });
+		if (_romeoSlaves.length === 0) {
+			_romeoSlaves = V.slaves.filter(function(s) { return (s.counter.publicUse > 0) && (s.newGamePlus === 0) && (s.relationship > -3) && !["be your Concubine", "serve in the master suite"].includes(s.assignment); });
+			if (_romeoSlaves.length === 0) {
+				name = setup.whiteAmericanSlaveNames.random();
+			} else {
+				juliet = _romeoSlaves.random();
+			}
+		} else {
+			juliet = _romeoSlaves.random();
+		}
+		if (juliet === undefined) {
+			name = setup.whiteAmericanSlaveNames.random();
+		}
 
-		let _slaveCost = slaveCost(_juliet);
-		_slaveCost = (random(60, 70) * Math.trunc(_slaveCost / 100));
-		_slaveCost = 100 * Math.trunc(_slaveCost / 100);
+		if (name === 0) {
+			_slaveCost = slaveCost(juliet);
+			_slaveCost = (random(60, 70) * Math.trunc(_slaveCost / 100));
+			_slaveCost = 100 * Math.trunc(_slaveCost / 100);
+		}
 		const {
-
-		} = getPronouns(_juliet);
+			He, His,
+			he, his, him, girl
+		} = getPronouns(juliet ? juliet : {pronoun: App.Data.Pronouns.Kind.neutral});
 		const {
+			heU, hisU, himU, girlU
+		} = getNonlocalPronouns(V.seeDicks).appendSuffix("U");
 
-		} = getNonlocalPronouns(V.seeDicks).appendSuffix("U")
-
-		r.push(`One of your mercenaries requests an interview.He's a worn, grey-haired tank of a man, made bulkier still by heavy ceramic plate armor and lots of ammunition and gear. The murderous submachine gun favored for city fighting looks like a toy in his hands. But as he sits at your invitation and accepts a`);
-		if (V.PC.refreshmentType === 0) {
-			r.push(`${V.PC.refreshment}`);
-		} else if (V.PC.refreshmentType === 1) {
+		r.push(`One of your mercenaries requests an interview. He's a worn, grey-haired tank of a man, made bulkier still by heavy ceramic plate armor and lots of ammunition and gear. The murderous submachine gun favored for city fighting looks like a toy in his hands. But as he sits at your invitation and accepts a`);
+		if (V.PC.refreshmentType === 1) {
 			r.push(`glass of ${V.PC.refreshment}`);
 		} else if (V.PC.refreshmentType === 2) {
 			r.push(`a plate of ${V.PC.refreshment}`);
@@ -48,135 +57,134 @@ App.Events.PMercenaryRomeo = class PMercenaryRomeo extends App.Events.BaseEvent
 			r.push(`pill of ${V.PC.refreshment}`);
 		} else if (V.PC.refreshmentType === 6) {
 			r.push(`tab of ${V.PC.refreshment}`);
+		} else {
+			r.push(V.PC.refreshment);
 		}
-		r.push(`proffered by an attentive slave _girlU, he seems almost bashful.`);
+		r.push(`proffered by an attentive slave ${girlU}, he seems almost bashful.`);
 
 		App.Events.addParagraph(node, r);
 		r = [];
 
 
 		r.push(`"${properTitle()}, I'll say this straight. I'd like to buy one of your slaves.`);
-		if (_name !== 0) {
-			r.push(`I've been seeing ${_name} a lot, and ${_heU} makes the years sit a little lighter on me. I've scraped together what I can, and I can pay ${cashFormat(50000)}." It's a huge sum for a mercenary; it's probably his entire savings, but there is a slight problem; the slave he is looking for isn't one of yours. "Well then," he says in embarrassment, "Have to say this is a little awkward." He gives a fake cough, "You wouldn't happen to, you know, know who _hisU owner is?" You shake your head. A run in with a _girlU named _name isn't much to go by and it really isn't your problem. "Ah well, I'm sure I'll see _himU around again. Anyway, that was a fine victory the other day, properTitle(); come down to the bar and join the boys and I. We'll buy you a drink. Devil knows, thanks to you we can afford to. Hell, maybe you'll even get to meet _name too, get to see just how much of a looker _heU is."`);
-
+		if (name !== 0) {
+			r.push(`I've been seeing ${name} a lot, and ${heU} makes the years sit a little lighter on me. I've scraped together what I can, and I can pay ${cashFormat(50000)}." It's a huge sum for a mercenary; it's probably his entire savings, but there is a slight problem; the slave he is looking for isn't one of yours. "Well then," he says in embarrassment, "Have to say this is a little awkward." He gives a fake cough, "You wouldn't happen to, you know, know who ${hisU} owner is?" You shake your head. A run in with a ${girlU} named ${name} isn't much to go by and it really isn't your problem. "Ah well, I'm sure I'll see ${himU} around again. Anyway, that was a fine victory the other day, ${properTitle()}; come down to the bar and join the boys and I. We'll buy you a drink. Devil knows, thanks to you we can afford to. Hell, maybe you'll even get to meet ${name} too, get to see just how much of a looker ${heU} is."`);
 		} else {
-			if (["serve in the club", "serve the public", "whore", "work in the brothel"].includes(_juliet.assignment)) {
-				r.push(`I've been seeing`);
-				App.UI.slaveDescriptionDialog(_juliet)
-				r.push(`a lot, and ${he} makes the years sit a little lighter on me.`);
+			if (["serve in the club", "serve the public", "whore", "work in the brothel"].includes(juliet.assignment)) {
+				r.push(
+					`I've been seeing`,
+					App.UI.DOM.slaveDescriptionDialog(juliet),
+					`a lot, and ${he} makes the years sit a little lighter on me.`
+				);
 			} else {
-				r.push(`I've seen`);
-				App.UI.slaveDescriptionDialog(_juliet)
-				r.push(`here and there and I can't stop thinking about ${him}. I feel ${he}'d make the years sit a little lighter on me.`);
+				r.push(
+					`I've seen`,
+					App.UI.DOM.slaveDescriptionDialog(juliet),
+					`here and there and I can't stop thinking about ${him}. I feel ${he}'d make the years sit a little lighter on me.`
+				);
 			}
-			r.push(`I've scraped together what I can, and I can pay`);
-			V.cashFormat(_slaveCost)
-			r.push(`." It's a decent price, probably a little less than you could get at auction. It's a huge sum for a mercenary; it's probably his entire savings. You ask what he would do with ${him}. "Well," he says, actually blushing, "I'd free ${him}. And marry ${him}, if ${he}'d have me."`);
+			r.push(`I've scraped together what I can, and I can pay ${cashFormat(_slaveCost)}." It's a decent price, probably a little less than you could get at auction. It's a huge sum for a mercenary; it's probably his entire savings. You ask what he would do with ${him}. "Well," he says, actually blushing, "I'd free ${him}. And marry ${him}, if ${he}'d have me."`);
 
-			//<br><br>
+			App.Events.addParagraph(node, r);
+			const choices = [];
+			choices.push(new App.Events.Result(`Decline, and tell ${him} not to see him`, declineAndForbid));
+			choices.push(new App.Events.Result(`Politely decline`, declinePolitely));
+			choices.push(new App.Events.Result(`Accept`, accept));
+			choices.push(new App.Events.Result(`Give ${him} to him as a gift`, gift));
 
-			//<span id="result">
-			//<<link "Decline, and tell ${him} not to see him">>
-			//<<replace "#result">>
-			_juliet.slaveName obeys your orders not to see the old mercenary.Though neither he or _juliet.slaveName says a word about it, his squadmates are not so closemouthed.Soon the tragic story of The Mercenary and the Slave ${ Girl } is being told in bars and brothels across the Free City, with you naturally playing < span class="red" > the role of the villain.</span >
-				repX(-1000, "event");
-			//<</replace>>
-			//<</link>>
-			//<br>
-			//<<link "Politely decline">>
-			//<<replace "#result">>
-			"Ah well," he says, "didn't think you would, but I had to ask. If you'd be so kind as to keep ${him} assigned so's I can see ${him}, I would be grateful. That was a fine victory,
-			V.properTitle(); come down to the bar and join the boys and I.We'll buy you a drink. Devil knows, thanks to you we can afford to."
-			if (_juliet.relationship === -3 && _juliet.fetish !== "mindbroken" && _juliet.devotion + _juliet.trust > 190) {
-				_juliet.slaveName politely thanks you for not letting him take ${ him } away.
+			App.Events.addResponses(node, choices);
+
+			App.UI.DOM.appendNewElement("h3", node, `${His} records...`);
+			App.UI.DOM.appendNewElement("div", node, `${His} current task is to ${juliet.assignment}${(V.assignmentRecords[juliet.ID]) ? `, and before that to ${V.assignmentRecords[juliet.ID]}` : ""}.`, "indent");
+			node.append(slaveImpactLongTerm(juliet));
+		}
+		function declineAndForbid() {
+			const frag = new DocumentFragment();
+			let r = [];
+			r.push(`${juliet.slaveName} obeys your orders not to see the old mercenary.Though neither he or ${juliet.slaveName} says a word about it, his squadmates are not so closemouthed. Soon the tragic story of The Mercenary and the slave${girl} is being told in bars and brothels across the Free City, with you naturally playing <span class="reputation dec"> the role of the villain.</span>`);
+			repX(-1000, "event");
+			App.Events.addParagraph(frag, r);
+			return frag;
+		}
+		function declinePolitely() {
+			const frag = new DocumentFragment();
+			let r = [];
+			r.push(`"Ah well," he says, "didn't think you would, but I had to ask. If you'd be so kind as to keep ${him} assigned so's I can see ${him}, I would be grateful. That was a fine victory, ${properTitle()}; come down to the bar and join the boys and I. We'll buy you a drink. Devil knows, thanks to you we can afford to."`);
+			if (juliet.relationship === -3 && juliet.fetish !== "mindbroken" && juliet.devotion + juliet.trust > 190) {
+				r.push(`${juliet.slaveName} politely thanks you for not letting him take ${him} away.`);
+			}
+			App.Events.addParagraph(frag, r);
+			return frag;
 		}
-			//<</replace>>
-			//<</link>>
-			//<br>
-			//<<link "Accept">>
-			//<<replace "#result">>
-			r.push(`The mercenary leaves to collect his purchase. On the video feeds, you see that${_juliet.slaveName} can hardly believe what's`);
-			if (_juliet.relationship === -3 && _juliet.fetish !== "mindbroken" && _juliet.devotion + _juliet.trust > 190) {
+
+		function accept() {
+			const frag = new DocumentFragment();
+			let r = [];
+			r.push(`The mercenary leaves to collect his purchase. On the video feeds, you see that${juliet.slaveName} can hardly believe what's`);
+			if (juliet.relationship === -3 && juliet.fetish !== "mindbroken" && juliet.devotion + juliet.trust > 190) {
 				r.push(`happening. You can't hear what he says as he takes out a ring, but ${his} reaction speaks clearly. ${He} says "No."`);
-				if (canWalk(_juliet) && hasAnyArms(_juliet)) {
+				if (canWalk(juliet) && hasAnyArms(juliet)) {
 					r.push(`${He} points back into your penthouse and returns to ${his} home.`);
 				} else {
 					r.push(`${He} gestures towards the nearest camera and he helps ${him} back into your penthouse.`);
 				}
-				r.push(`The only thing ${he} wants after being freed is to return to your side.`);
-				"I thought I was giving ${him} a better life... But ${he} already had everything ${he} wanted. I'm sorry for putting you in such a position." You can hear the sadness in his voice. "Thank you for your time. I'm sorry to have bothered you."
-				r.push(`Since ${he} returned to slavery, it's only fair to return the credits he paid for ${him}. He thanks you hollowly before heading on his way.`);
+				r.push(`The only thing ${he} wants after being freed is to return to your side. "I thought I was giving ${him} a better life... But ${he} already had everything ${he} wanted. I'm sorry for putting you in such a position." You can hear the sadness in his voice. "Thank you for your time. I'm sorry to have bothered you." Since ${he} returned to slavery, it's only fair to return the credits he paid for ${him}. He thanks you hollowly before heading on his way.`);
 			} else {
 				r.push(`happened.`);
-				if (hasAnyArms(_juliet) && hasBothLegs(_juliet)) {
+				if (hasAnyArms(juliet) && hasBothLegs(juliet)) {
 					r.push(`${He} hugs him, sobbing into his shoulder. As they walk hand in hand down towards his quarters,`);
 				} else {
 					r.push(`As he`);
-					if (!isAmputee(_juliet)) {
+					if (!isAmputee(juliet)) {
 						r.push(`gives`);
 					} else {
 						r.push(`picks up ${his} limbless form to give`);
 					}
 					r.push(`${him} a hug,`);
 				}
-				r.push(`${he} gives the nearest camera a little nod and silently mouths the words "Thank you,`);
-				V.getWrittenTitle(_juliet)
-				r.push(`." Soon the romantic story of The Mercenary and the Slave ${Girl} is being told in bars and brothels across the Free City, with you naturally playing <span class="green">a supporting role.</span>`);
+				r.push(`${he} gives the nearest camera a little nod and silently mouths the words "Thank you, ${getWrittenTitle(juliet)}." Soon the romantic story of The Mercenary and the slave${girl} is being told in bars and brothels across the Free City, with you naturally playing <span class="reputation inc">a supporting role.</span>`);
+				// TODO: uh, actually increase rep?
 				cashX(_slaveCost, "slaveTransfer");
-				removeSlave(_juliet);
+				removeSlave(juliet);
 			}
-			//<</replace>>
-			//<</link>>
-			//<br>
-			//<<link "Give ${him} to him as a gift">>
-			//<<replace "#result">>
-			r.push(`The mercenary cannot believe his ears. After you repeat yourself twice, he leaves to collect your gift, thanking you clumsily. On the video feeds, you see that${_juliet.slaveName} can hardly believe what's`);
-			if (_juliet.relationship === -3 && _juliet.fetish !== "mindbroken" && _juliet.devotion + _juliet.trust > 190) {
+
+			App.Events.addParagraph(frag, r);
+			return frag;
+		}
+
+		function gift() {
+			const frag = new DocumentFragment();
+			let r = [];
+			r.push(`The mercenary cannot believe his ears. After you repeat yourself twice, he leaves to collect your gift, thanking you clumsily. On the video feeds, you see that${juliet.slaveName} can hardly believe what's`);
+			if (juliet.relationship === -3 && juliet.fetish !== "mindbroken" && juliet.devotion + juliet.trust > 190) {
 				r.push(`happening. You can't hear what he says as he takes out a ring, but ${his} reaction speaks clearly. ${He} says "No."`);
-				if (canWalk(_juliet) && hasAnyArms(_juliet)) {
+				if (canWalk(juliet) && hasAnyArms(juliet)) {
 					r.push(`${He} points back into your penthouse and returns to ${his} home.`);
 				} else {
 					r.push(`${He} gestures towards the nearest camera and he helps ${him} back into your penthouse.`);
 				}
-				r.push(`The only thing ${he} wants after being freed is to return to your side.`);
-				"I thought I was giving ${him} a better life... But ${he} already had everything ${he} wanted. I'm sorry for putting you in such a position." You can hear the sadness in his voice. "Thank you for your time. I'm sorry to have bothered you."
+				r.push(`The only thing ${he} wants after being freed is to return to your side. "I thought I was giving ${him} a better life... But ${he} already had everything ${he} wanted. I'm sorry for putting you in such a position." You can hear the sadness in his voice. "Thank you for your time. I'm sorry to have bothered you."`);
 			} else {
 				r.push(`happened.`);
-				if (hasAnyArms(_juliet) && hasAnyLegs(_juliet)) {
+				if (hasAnyArms(juliet) && hasAnyLegs(juliet)) {
 					r.push(`${He} hugs him, sobbing into his shoulder. As they walk hand in hand down towards his quarters,`);
 				} else {
 					r.push(`As he`);
-					if (!isAmputee(_juliet)) {
+					if (!isAmputee(juliet)) {
 						r.push(`gives`);
 					} else {
 						r.push(`picks up ${his} limbless form to give`);
 					}
 					r.push(`${him} a hug,`);
 				}
-				r.push(`${he} gives the nearest camera a little nod and silently mouths the words "Thank you,`);
-				V.getWrittenTitle(_juliet)
-				r.push(`." You smile to yourself; when they get there they'll find flowers and a paid reservation at the arcology's best restaurant. Soon the story is being told in bars and brothels across the Free City, with you naturally playing <span class="green">a starring role.</span> Some days later, you hear a dramatization is being filmed, with an aging action star playing the mercenary, a rising starlet playing _juliet.slaveName, and a noted character actor playing you.`);
+				r.push(`${he} gives the nearest camera a little nod and silently mouths the words "Thank you, ${getWrittenTitle(juliet)}." You smile to yourself; when they get there they'll find flowers and a paid reservation at the arcology's best restaurant. Soon the story is being told in bars and brothels across the Free City, with you naturally playing <span class="reputation inc">a starring role.</span> Some days later, you hear a dramatization is being filmed, with an aging action star playing the mercenary, a rising starlet playing ${juliet.slaveName}, and a noted character actor playing you.`);
 				repX(15000, "event");
-				_poster = "a poster for the movie that was made about the love between one of your mercenaries and " + _juliet.slaveName;
-				V.trinkets.push(_poster);
-				removeSlave(_juliet);
+				V.trinkets.push(`a poster for the movie that was made about the love between one of your mercenaries and ${juliet.slaveName}`);
+				removeSlave(juliet);
 			}
-			//<</replace>>
-			//<</link>>
-			//</span>
-
-			//<h3>${His} records...</h3>
-			//<div class="note">
-			//<div class="indent">
-			r.push(`${His} current task is to`);
-			V._juliet.assignment
-			if (V.assignmentRecords[_juliet.ID]) {
-				r.push(`, and before that to`);
-				V.V.assignmentRecords[_juliet.ID]
-			}
-			r.push(`.`);
-			//</div>
-			//<<includeDOM slaveImpactLongTerm(_juliet)>>
-			//</div>
 
+			App.Events.addParagraph(frag, r);
+			return frag;
 		}
+	}
+};
-- 
GitLab