code:
App.Events.PUndergroundRailroad = class PUndergroundRailroad extends App.Events.BaseEvent {
	execute(node) {
		V.nextButton = "Continue";
		let r = [];

		V.nextButton = " "; // hide button until user makes a selection

		V.collaboration = 0;
		V.traitor = 0;
		V.hackerSupport = 0;

		const traitor = getTraitor();
		const {
			He,
			he, him, himself, his
		} = getPronouns(traitor);
		const {
			HeA, HisA,
			heA, hisA, himA
		} = getPronouns(assistant.pronouns().main).appendSuffix("A");
		const {say, title: Master} = getEnunciation(traitor);
		V.fcnn.push("...you believe a slave has been contacted by the Daughters of Liberty, please call...");

		if (traitor.devotion + traitor.trust >= 175) {
			V.traitorType = "agent";
		} else if (traitor.trust <= -75) {
			V.traitorType = "horror";
		} else if (traitor.devotion <= -20 && traitor.trust >= 20) {
			V.traitorType = "defiant";
		} else {
			V.traitorType = "standard";
		}

		r.push(`One fine day, as normal as any day surrounded by your slaves can be, you're sitting at your desk when`);
		if (V.traitorType === "agent") {
			// TODO: canMove canWalk variants.
			r.push(`${traitor.slaveName} comes bursting into your office. ${He} crashes into your desk and`);
			if (canTalk(traitor)) {
				if (traitor.lips > 70) {
					r.push(`lisps through ${his} huge lips`);
				} else if (traitor.piercing.lips.weight + traitor.piercing.tongue.weight > 2) {
					r.push(`lisps through ${his} piercings`);
				} else {
					r.push(`shouts`);
				}
			} else {
				r.push(`gestures`);
			}
			r.push(`that several nondescript citizens ${he} sees occasionally at work have passed messages to ${him} this morning. Apparently, they simply asked whether ${he} wished to be free and the absurdity of it spurred ${him} to alert you. Even more unusual is the unannounced message waiting in your inbox — a message ${V.assistant.name} totally failed to inform you of. When asked,`);
		} else {
			r.push(`a message comes in. ${capFirstChar(V.assistant.name)} totally fails to announce it, which is unusual; when you ask ${himA} why not,`);
		}
		r.push(`${heA} replies`);
		if (V.assistant.personality > 0) {
			r.push(`flirtatiously, "What message, ${properTitle()}?"`);
			switch (V.assistant.appearance) {
				case "monstergirl":
					r.push(`${HisA} avatar's tentacle hair wiggles with incomprehension.`);
					break;
				case "shemale":
					r.push(`${HisA} avatar looks frustrated, ${hisA} hard-on wilting.`);
					break;
				case "amazon":
					r.push(`${HisA} avatar gives a little shriek of frustration.`);
					break;
				case "businesswoman":
					r.push(`${HisA} avatar wears an unaccustomed look of frustration.`);
					break;
				case "fairy":
				case "pregnant fairy":
					r.push(`${HisA} avatar crosses ${hisA} arms and ponders while hovering in the air.`);
					break;
				case "goddess":
					r.push(`${HisA} avatar looks concerned without ${hisA} usual sultry overtone.`);
					break;
				case "hypergoddess":
					r.push(`${HisA} avatar looks concerned without ${hisA} usual sultry overtone.`);
					break;
				case "loli":
					r.push(`${HisA} avatar seems eager to be out of your sight.`);
					break;
				case "preggololi":
					r.push(`${HisA} avatar rubs ${hisA} belly while looking extremely concerned.`);
					break;
				case "angel":
					r.push(`${HisA} avatar's wings droop as a worried look crosses ${hisA} face.`);
					break;
				case "cherub":
					r.push(`A concerned look forms on ${hisA} face as ${heA} hovers nearby.`);
					break;
				case "incubus":
					r.push(`${HisA} avatar looks frustrated, ${hisA} hard-on wilting.`);
					break;
				case "succubus":
					r.push(`${HeA} stops teasing you, a concerned look forming on ${hisA} pretty face.`);
					break;
				case "imp":
					r.push(`A concerned look forms on ${hisA} face as ${heA} hovers nearby.`);
					break;
				case "witch":
					r.push(`A look of worry spreads across ${hisA} face; a lingering dread that ${heA} did something bad.`);
					break;
				case "ERROR_1606_APPEARANCE_FILE_CORRUPT":
					r.push(`${HisA} avatar twitches slightly before sprouting multiple eyes facing all directions.`);
					break;
				case "schoolgirl":
					r.push(`${HisA} avatar puts on such a hard look of concentration that ${hisA} eyes cross.`);
					break;
				default:
					r.push(`${HisA} symbol avatar spins with frustration.`);
			}
		} else {
			r.push(`"You have received no messages in the past thirty seconds, ${properTitle()}."`);
		}
		r.push(`This is disturbing, to say the least. After close investigation, it appears someone has managed to plant a simple text message in your mail system without ${V.assistant.name} or any of your other security systems taking any notice. Worse, your mysterious correspondent seems willing to show off this ability in this petty display rather than simply sending a message anonymously.`);

		App.Events.addParagraph(node, r);
		r = [];

		r.push(
			`"You will free`,
			App.UI.DOM.slaveDescriptionDialog(traitor),
			`immediately," it reads. "This is the price of your continued survival. Agree and you buy yourself a few more moments at the top of your heap of shit. Refuse, and you shall fall that much sooner." The message is signed "The Daughters of Liberty."`
		);

		App.Events.addParagraph(node, r);
		r = [];

		if (V.traitorType === "agent") {
			r.push(`${traitor.slaveName} is left aghast at the contents of the message, but quickly composes ${himself} and`);
			if (canTalk(traitor)) {
				r.push(
					`${say}s,`,
					Spoken(traitor, `"I think I have an idea, ${Master}. They'll likely take me in if you were to 'free' me and, from there, maybe I could feed you information, ${Master}. I could help expose them to you and they'd be none the wiser of the mistake they've made."`)
				);
			} else {
				r.push(`gestures there may be an opportunity here; they'd likely take ${him} in if ${he} were freed and ${he} could serve you from within the group as a double agent.`);
			}

			App.Events.addParagraph(node, r);
			r = [];

			App.Events.addResponses(node, [
				new App.Events.Result(`Let ${him} go`, agentRelease),
				new App.Events.Result(`Tell ${him} to ignore the Daughters in the future`, agentIgnore)
			]);
		} else {
			r.push(`You call ${traitor.slaveName} in and politely inquire as to whether ${he} knows anything about the matter.`);
			if (V.traitorType === "horror") {
				r.push(`${He} breaks down in tears at the mention of it and barely manages to tell you that several nondescript citizens ${he} sees occasionally at work have passed a few messages to ${him}. Apparently, they simply asked whether ${he} wished to be free. Asked whether ${he} does in fact wish to be free,`);
				if (canTalk(traitor)) {
					r.push(`${he} sobs a yes.`);
				} else {
					r.push(`${he} weeps and nods.`);
				}
			} else if (V.traitorType === "defiant") {
				r.push(`${He} stands ${his} ground and`);
				if (canTalk(traitor)) {
					if (traitor.lips > 70) {
						r.push(`lisps through ${his} huge lips,`);
					} else if (traitor.piercing.lips.weight + traitor.piercing.tongue.weight > 2) {
						r.push(`lisps through ${his} piercings,`);
					} else {
						r.push(`shouts,`);
					}
					r.push(Spoken(traitor, `"I'm going to ${canWalk(traitor) ? "walk" : "get"} out of this shithole or you're going to die a slow, deserved death. That enough for you?"`));
				} else {
					r.push(`gestures you'll free ${him} if you know what's good for you.`);
				}
			} else {
				r.push(`${He} ${canMove(traitor) ? "nearly flees" : "quivers"} in terror, but gathers ${his} courage and`);
				if (canTalk(traitor)) {
					if (traitor.lips > 70) {
						r.push(`lisps meekly through ${his} huge lips`);
					} else if (traitor.piercing.lips.weight + traitor.piercing.tongue.weight > 2) {
						r.push(`lisps meekly through ${his} piercings`);
					} else {
						r.push(`mumbles meekly`);
					}
				} else {
					r.push(`gestures meekly`);
				}
				r.push(`that several nondescript citizens ${he} sees occasionally at work have passed a few messages to ${him}. Apparently, they simply asked whether ${he} wished to be free. Asked whether ${he} does in fact wish to be free, ${he}`);
				if (canTalk(traitor)) {
					if (SlaveStatsChecker.checkForLisp(traitor)) {
						r.push(`lisps faintly,`);
					} else {
						r.push(`mutters faintly,`);
					}
					r.push(Spoken(traitor, `"I'm sorry, ${Master}. Yes."`));
				} else {
					r.push(`shakily gestures an apology, and admits that ${he} does.`);
				}
				App.Events.addParagraph(node, r);
			}

			const responses = [
				new App.Events.Result(`Free ${him}`, free),
				new App.Events.Result(`Tell ${him} to ignore the Daughters in the future`, ignore),
				new App.Events.Result(`Publicly flog ${him} for treasonous conversation`, flog),
			];

			if (V.seeExtreme === 1) {
				responses.push(new App.Events.Result(`Chemically lobotomize ${him} to extirpate any record of the incident`, lobotomy));
				if (V.arcologies[0].FSPaternalist === "unset") {
					responses.push(new App.Events.Result(`Publicly execute ${him}`, execute));
				}
			}

			App.Events.addResponses(node, responses);
		}

		/**
		 * What's traitors, precious
		 * @returns {App.Entity.SlaveState}
		 */
		function getTraitor() {
			// The order of qualities does not matter.
			const qualities = [
				(s) => s.fuckdoll === 0,
				(s) => s.fetish !== "mindbroken",
				(s) => canWalk(s),
				(s) => canTalk(s),
				(s) => canSee(s),
				(s) => s.indenture === -1,
				(s) => [Job.CLUB, Job.PUBLIC, Job.WHORE, Job.BROTHEL].includes(s.assignment),
				(s) => s.devotion < 75,
				(s) => s.trust < 75,
			];
			let rankedSlaves = [];
			for (const slave of V.slaves) {
				let value = 0;
				for (const quality of qualities) {
					if (quality(slave)) {
						value++;
					}
				}
				rankedSlaves.push({value: value, slave: slave});
			}

			// Find the highest bar we reached
			const highScore = Math.max(...rankedSlaves.map(s => s.value));

			// Find anyone that ties for first
			rankedSlaves = rankedSlaves.filter(s => s.value === highScore);

			return rankedSlaves.random().slave;
		}

		function sendTraitor() {
			if (traitor.relationship > 0) {
				const rel = getSlave(traitor.relationshipTarget);
				traitor.relationshipTarget = 0;
				traitor.relationship = 0;
				if (rel) {
					traitor.relationshipTarget = 0;
					traitor.relationship = 0;
				} else {
					r.push(`<span class="red">Error, relationshipTarget not found.</span>`);
				}
			}
			V.traitorWeeks = 1;
			V.traitor = clone(traitor);
			V.traitor.assignment = "rest";
			V.traitor.pregControl = "none";
			deflate(V.traitor);
			V.traitorStats = {
				PCpregSource: 0,
				PCmother: 0,
				PCfather: 0,
				traitorMother: [],
				traitorFather: [],
				traitorPregSources: [],
				traitorMotherTank: [],
				traitorFatherTank: [],
				traitorBody: 0
			};
			if (V.traitor.ID === V.PC.pregSource) {
				V.traitorStats.PCpregSource = V.traitor.ID;
			}
			if (V.PC.mother === V.traitor.ID) {
				V.traitorStats.PCmother = V.traitor.ID;
			}
			if (V.PC.father === V.traitor.ID) {
				V.traitorStats.PCfather = V.traitor.ID;
			}
			for (const slave of V.slaves) {
				if (slave.ID !== V.traitor.ID) {
					if (slave.mother === V.traitor.ID) {
						V.traitorStats.traitorMother.push(slave.ID);
					}
					if (slave.father === V.traitor.ID) {
						V.traitorStats.traitorFather.push(slave.ID);
					}
					if (V.traitor.ID === slave.pregSource) {
						V.traitorStats.traitorPregSources.push(slave.ID);
					}
				}
			}
			if (V.incubator.capacity > 0) {
				for (const child of V.incubator.tanks) {
					if (V.traitor.ID === child.mother) {
						V.traitorStats.traitorMotherTank.push(child.ID);
					}
					if (V.traitor.ID === child.father) {
						V.traitorStats.traitorFatherTank.push(child.ID);
					}
				}
			}
			if (V.nursery > 0) {
				for (const child of V.cribs) {
					if (V.traitor.ID === child.mother) {
						V.traitorStats.traitorMotherTank.push(child.ID);
					}
					if (V.traitor.ID === child.father) {
						V.traitorStats.traitorFatherTank.push(child.ID);
					}
				}
			}
			V.traitor.sisters = 0;
			V.traitor.daughters = 0;
			if (V.traitor.bodySwap > 0) {
				const myBody = V.slaves.findIndex(function(s) { return s.origBodyOwnerID === V.traitor.ID; });
				if (myBody !== -1) {
					V.traitorStats.traitorBody = V.slaves[myBody].ID;
				}
			}
			removeSlave(traitor);
		}

		function agentRelease() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			r.push(`You inform ${him} that ${he} may act as a double agent for you. ${He} nods and hurries out of the penthouse. ${He} wanders down through the arcology, attracting little notice. One moment the monitors have ${him} struggling through a dense-packed crowd, and the next, they don't.`);
			if (traitor.intelligence + traitor.intelligenceImplant < 10) {
				r.push(`${He} isn't the brightest slave, but ${he} means well. Hopefully this will not come back to bite you.`);
			} else {
				r.push(`${He} is smart enough to likely do some damage to the group shadowing you, at the very least.`);
			}
			sendTraitor();
			App.Events.addParagraph(frag, r);
			return frag;
		}

		function agentIgnore() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			r.push(`${traitor.slaveName} nods ${his} head in acceptance. There is too much at stake to take such a risk. All attempts to use your monitoring systems to find the citizens who contacted ${him} fail; it seems their ability to corrupt your systems is considerable. ${He} keeps ${his} lips shut tight in an effort to prevent rumors from spreading, but whispers of freedom still manage to run through your chattel.`);
			V.slaves.forEach(function(s) { s.devotion -= 5; });
			App.Events.addParagraph(frag, r);
			return frag;
		}

		function free() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			r.push(`You calmly inform ${him} that ${he}'s free to go.`);
			if (V.traitorType === "defiant") {
				r.push(`${He} lets out a single harsh laugh and hurries out of the penthouse.`);
			} else {
				r.push(`${He} almost collapses with shock, but turns and hurries out of the penthouse, tears streaming from ${his} eyes.`);
			}
			r.push(`${He} wanders down through the arcology, attracting little notice. One moment the monitors have ${him} struggling through a dense-packed crowd, and the next, they don't.`);
			sendTraitor();
			App.Events.addParagraph(frag, r);
			return frag;
		}

		function ignore() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			if (V.traitorType === "defiant") {
				r.push(`${traitor.slaveName} merely <span class="devotion dec">smirks</span> when it becomes apparent you aren't going to punish ${him} for ${his} transgressions.`);
			} else {
				r.push(`${traitor.slaveName} almost <span class="devotion dec">faints with relief</span> when it becomes apparent you aren't going to punish ${him} for speaking of freedom.`);
			}
			r.push(`All attempts to use your monitoring systems to find the citizens who contacted ${him} fail; it seems their ability to corrupt your systems is considerable. Whispers of freedom run like wildfire amongst your slaves.`);
			V.slaves.forEach(function(s) { s.devotion -= 10; });
			traitor.devotion -= 15;
			App.Events.addParagraph(frag, r);
			return frag;
		}

		function flog() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			r.push(`You announce that a treasonous slave will be publicly flogged. Treason is understood in the Free Cities to be activity that tends to undermine slavery, and public interest is considerable when ${traitor.slaveName} is dragged out into a public atrium and secured to a post. You do your duty; the one that passes the sentence should swing the lash. The ordeal is long and bloody. The populace understand the necessity of the punishment, though they are disturbed that such a thing could happen in your penthouse of all places. The effect on ${traitor.slaveName}'s health is serious, and ${he} is terrified of failing you again.`);
			traitor.trust -= 15;
			repX(-500, "event", traitor);
			healthDamage(traitor, 30);
			App.Events.addParagraph(frag, r);
			return frag;
		}

		function lobotomy() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			r.push(`You inform ${traitor.slaveName} that ${he} is to return to ${his} duties, which ${he} does, mystified. Later in the day ${he} finds ${himself} scheduled for surgery, and meekly goes. As ${he} feels the cool touch of the injector, loaded with powerful chemical lobotomizing agents, ${he} looks up at the camera above the autosurgery with a hint of`);
			if (V.traitorType === "defiant") {
				r.push(`regret`);
			} else {
				r.push(`resigned apology`);
			}
			r.push(`in ${his} eyes. When ${he} is released from the surgery's care a few hours later, the hint is gone. <span class="red">As is everything.</span>`);
			applyMindbroken(traitor);
			App.Events.addParagraph(frag, r);
			return frag;
		}

		function execute() {
			const frag = new DocumentFragment();
			let r = [];
			unlock();
			r.push(`You announce that a treasonous slave will be publicly executed. Treason is understood in the Free Cities to be activity that tends to undermine slavery, and public interest is considerable when ${traitor.slaveName} is dragged out into a public atrium and`);
			if (V.arcologies[0].FSAztecRevivalist !== "unset") {
				r.push(`has ${his} heart cut out of ${his} living body.`);
			} else if (V.arcologies[0].FSEdoRevivalist !== "unset") {
				r.push(`is boiled alive.`);
			} else if (V.arcologies[0].FSRomanRevivalist !== "unset") {
				r.push(`is crucified and left hanging until ${he} perishes.`);
			} else {
				r.push(`is summarily hanged.`);
			}
			r.push(`The populace understands the necessity of the punishment, though they are disturbed that such a thing could happen in your penthouse of all places. The surviving slaves are terrified at the display, but at least you can be sure they will remember the price of failing you.`);
			repX(-500, "event", traitor);
			V.slaves.forEach(function(s) {
				s.trust -= 10 + random(10);
			});
			removeSlave(traitor);
			App.Events.addParagraph(frag, r);
			return frag;
		}

		/** unlock Continue button */
		function unlock() {
			V.nextButton = "Continue";
			App.Utils.updateUserButton();
		}
	}
};


code:
App.Events.eliteTakeOver = class eliteTakeOver extends App.Events.BaseEvent {
	eventPrerequisites() {
		return [
			() => V.arcologies[0].FSRestart !== "unset",
			() => V.failedElite > 300,
			() => V.eugenicsFullControl !== 1
		];
	}

	execute(node) {
		const container = App.UI.DOM.appendNewElement("div", node);
		let r = [];
		/* Elites */
		let eliteTotal = 12;
		let eliteDead = 0;
		let eliteVegetable = 0;
		let mercenariesMessageSent = 0;
		let specialForcesMessageSent = 0;
		V.nextButton = " ";
		const {
			He,
			he, his
		} = getPronouns(S.Bodyguard ? S.Bodyguard : {pronoun: App.Data.Pronouns.Kind.neutral});

		let pregSurrender = 0; // preg/lobotomization check
		r.push(`You knew this day would come. Surrounding yourself with powerful people has its boons, but also poses a distinct threat. You've heard them murmuring when you enter the room, you've seen them excuse themselves from your presence, and lately they've been overtly hostile. The Societal Elite${(V.arcologies[0].FSNeoImperialistLaw2 === 1) ? ", likely with the support of your ever-plotting Barons," : ""} have turned on you.`);
		App.Events.addNode(container, r, "div");
		r = [];
		r.push(`You look up from your desk as the locked door to your office unseals, and a dozen individuals brazenly walk into your view.`);
		if (S.Bodyguard) {
			r.push(`${S.Bodyguard.slaveName} stands between you and them. A single glare from the leader of the bunch and ${he} backs off, eyes to the ground.`);
		}
		App.Events.addNode(container, r, "div");
		r = [];
		if (V.PC.pregSource === -1 || V.PC.pregSource === -6) {
			if (V.PC.refreshmentType === 0) {
				r.push(`Taking a drag from a fresh ${V.PC.refreshment},`);
			} else if (V.PC.refreshmentType === 1) {
				r.push(`Taking a drink of a fresh glass of ${V.PC.refreshment},`);
			} else if (V.PC.refreshmentType === 2) {
				r.push(`Taking a bite of a fresh ${V.PC.refreshment},`);
			} else if (V.PC.refreshmentType === 3) {
				r.push(`Doing a line of ${V.PC.refreshment},`);
			} else if (V.PC.refreshmentType === 4) {
				r.push(`Injecting a hit of ${V.PC.refreshment} into your arm,`);
			} else if (V.PC.refreshmentType === 5) {
				r.push(`Swallowing a ${V.PC.refreshment},`);
			} else if (V.PC.refreshmentType === 6) {
				r.push(`Placing a tab of ${V.PC.refreshment} under your tongue,`);
			}
			r.push(`you greet your rather unwelcome guests.`);
			App.Events.addParagraph(container, r);
			r = [];
			r.push(`"You are no longer worthy of being a part of our society. But you carry within you one of our heirs. A conundrum for some, but we have already solved that problem."`);
			App.Events.addNode(container, r, "div");
			r = [];
			r.push(`What was that last thing he said? It's getting hard to think right. The ${V.PC.refreshment}... Drugged... You collapse onto your desk, unconscious.`);
			App.Events.addNode(container, r, "div");
			r = [];
			if (S.Bodyguard) {
				r.push(`A sharp pain and a rush of adrenaline drags you back to your senses. Sneaking a peak, you witness ${S.Bodyguard.slaveName} valiantly trying to protect you, despite`);
				if (hasAnyProstheticLimbs(S.Bodyguard)) {
					r.push(`${his} cybernetics being locked down.`);
				} else {
					r.push(`the overwhelming odds.`);
				}
				r.push(`As ${he} and their leader struggle closer to your desk, his revolver and a syringe are dislodged onto your desk. It seems drugging you wasn't their first thought. With ${S.Bodyguard.slaveName}'s risky gamble, your fate has fallen back into your hands.`);
			} else {
				r.push(`You'll spend the rest of your life a breeder to the Societal Elite; blinded and muted. More than a slave, but still less than your master. Life isn't so bad, your two most devoted slaves were taken along to keep you happy, and you are treated quite well, possibilities considered. Though once your eggs dry up, odds are your little remaining usefulness will be at an end. Best not to think too much into it.`);
				pregSurrender = 1;
				V.ui = "start";
				App.Events.addParagraph(container, r);
				r = [];
				App.UI.DOM.appendNewElement("p", container, "GAME OVER", "bold");
			}
		} else {
			r.push(`The leader reaches into his jacket and extracts a syringe, you recognize it as a powerful drug used in lobotomies, and places it to your left. From his hip he pulls a revolver, six-chambered, and loads five bullets, spins the chamber, and places it to your right.`);
			App.Events.addNode(container, r, "div");
			r = [];
			r.push(`"You are no longer worthy of being a part of our society. You know you can't be allowed to spread any information. But we are not merciless; one of our members has taken an interest in having you as her pet. You may choose to lose your mind, and service her until she tires of you, or gamble for your life and serve her anyway. Now decide."`);
		}
		App.Events.addParagraph(container, r);

		if (pregSurrender === 0) {
			App.UI.DOM.appendNewElement("div", container, "You decide to");

			const choices = [];
			if (S.Bodyguard) {
				if (V.PC.pregSource === -1 || V.PC.pregSource === -6) {
					choices.push(new App.Events.Result(null, null, `${S.Bodyguard.slaveName} is already doing everything in ${his} power to save you.`));
				} else {
					choices.push(new App.Events.Result(`Attempt to signal ${S.Bodyguard.slaveName}, your bodyguard`, BG));
				}
			}
			if (V.mercenaries >= 1) {
				choices.push(new App.Events.Result(`Send a message to the leader of the ${V.mercenariesTitle}`, mercenaries));
			}
			if (V.SF.Toggle && V.SF.Active >= 1) {
				choices.push(new App.Events.Result(`Send a message to ${App.SF.SFC()}`, SF));
			}
			if (V.PC.pregSource !== -1 && V.PC.pregSource !== -6) {
				choices.push(new App.Events.Result(`Try and enrage them.`, enrage));
			}
			choices.push(new App.Events.Result(`Make a final stand`, finalStand));
			choices.push(new App.Events.Result(`Give in`, giveIn));
			App.Events.addResponses(container, choices);
		}
		function BG() {
			$(container).empty().append(eliteTakeOverFight("bodyguard"));
			return [];
		}
		function mercenaries() {
			$(container).empty().append(eliteTakeOverFight("mercenaries"));
			return [];
		}
		function SF() {
			$(container).empty().append(eliteTakeOverFight("SF"));
			return [];
		}
		function enrage() {
			$(container).empty().append(eliteTakeOverFight("enrage"));
			return [];
		}
		function finalStand() {
			$(container).empty().append(eliteTakeOverFight("final stand"));
			return [];
		}
		function giveIn() {
			$(container).empty().append(eliteTakeOverFight("give in"));
			return [];
		}
		function eliteTakeOverFight(finalChoice) {
			const node = new DocumentFragment();
			let r = [];
			let bgSignaled;
			let eliteEnraged;

			switch (finalChoice) {
				case "bodyguard": {
					const roll = random(0, 100);
					if (V.PC.career === "mercenary") {
						r.push(`As a result of your prior experience as a mercenary you were able to successfully signal ${S.Bodyguard.slaveName} without the Elites noticing.`);
						bgSignaled = 1;
					} else if (V.PC.skill.warfare >= 100 && roll > 20) {
						r.push(`As a result of your mastery of warfare you were able to successfully signal ${S.Bodyguard.slaveName} without the Elites noticing.`);
						bgSignaled = 1;
					} else if (V.PC.skill.warfare >= 60 && roll > 30) {
						r.push(`As a result of your expertness of warfare you were able to successfully signal ${S.Bodyguard.slaveName} without the Elites noticing.`);
						bgSignaled = 1;
					} else if (V.PC.skill.warfare >= 30 && roll > 40) {
						r.push(`As a result of having some skill in warfare you were able to successfully signal ${S.Bodyguard.slaveName} without the elites noticing.`);
						bgSignaled = 1;
					} else if (V.PC.skill.warfare >= 10 && roll > 50) {
						r.push(`As a result of having a small amount of skill in warfare you were able to successfully signal ${S.Bodyguard.slaveName} without the Elites noticing.`);
						bgSignaled = 1;
					} else if (V.PC.skill.warfare < 10 && roll > 60) {
						r.push(`By blind luck and what little you remember of your lessons in warfare are were able to successfully signal ${S.Bodyguard.slaveName} without the Elites noticing.`);
						bgSignaled = 1;
					} else {
						r.push(`One of the Elites shouts "What the fuck are you trying to do?" Well, there goes that option.`);
						bgSignaled = 0;
					}
					App.Events.addNode(node, r, "div");
					r = [];
					r.push(`You then pick up the revolver and quickly take aim.`);
					break;
				}
				case "mercenaries":
					r.push(`You send a quick message to the leader of your ${V.mercenariesTitle}, about your situation, then you pick up the revolver and quickly take aim.`);
					mercenariesMessageSent = 1;
					break;
				case "SF":
					r.push(`You send a quick message to`);
					App.SF.SFC();
					r.push(`about your situation, then you pick up the revolver and quickly take aim.`);
					specialForcesMessageSent = 1;
					break;
				case "enrage":
					if (["arcology owner", "BlackHat", "capitalist", "celebrity", "child prostitute", "escort", "gang", "hacker", "hoodlum", "medical assistant", "medicine", "prostitute", "rich kid", "rising star", "trust fund", "wealth"].includes(V.PC.career)) {
						r.push(`You know exactly what to say in order to enrage them.`);
						eliteEnraged = 1;
					} else if (random(0, 100) > 50) {
						r.push(`You manage to select the right words to enrage them.`);
						eliteEnraged = 1;
					} else {
						r.push(`You try to enrage them, but your words have had no effect.`);
						eliteEnraged = 0;
					}
					App.Events.addNode(node, r, "div");
					r = [];
					r.push(`You then pick up the revolver and quickly take aim.`);
					break;
				case "final stand":
					r.push(`You pick up the revolver and quickly take aim.`);
					break;
				case "give in":
					r.push(`You pick up the revolver and hold the barrel to your temple.`);
					break;
			}

			if (finalChoice === "give in") {
				if (V.PC.pregSource === -1 || V.PC.pregSource === -6) {
					r.push(`Screw their plans, you're out of here.`);
				}
				r.push(`With a "Bang!" you drop dead.`);
				V.ui = "start";
				App.Events.addParagraph(node, r);
				App.UI.DOM.appendNewElement("p", node, "GAME OVER", "bold");
			} else {
				/* PC shooting */
				/* higher skill means a higher chance to hit due to lower requirements and if the elites are enraged they very slightly become easier targets. */
				/* 5/6 = 83% rounded down is the chance that it was loaded chamber (simplified version based off the Wikipedia article) */

				/* variables: */
				/* Revolver */
				let revolverChambers = 6;
				let revolverBullets = 5;

				/* To Hit chance */
				let toHit;
				if (V.PC.pregSource === -1 || V.PC.pregSource === -6) { /* still woozy */
					toHit = 56;
				} else if (V.PC.career === "mercenary" || V.PC.skill.warfare >= 100) {
					toHit = 83;
				} else if (V.PC.skill.warfare >= 60) {
					toHit = 76;
				} else if (V.PC.skill.warfare >= 30) {
					toHit = 67;
				} else if (V.PC.skill.warfare >= 10) {
					toHit = 60;
				} else {
					toHit = 56;
				}
				if (eliteEnraged === 1) {
					toHit += 5;
				}

				/* shooting */
				/* in the end I removed the messages from the cycle. I don't think having 6 lines of "you shot" is pretty looking. Feel free to re add them in however */
				for (let i = revolverChambers; i > 0; i--) {
					if (random(0, 100) <= toHit && revolverBullets > 0) {
						eliteDead += 1;
						revolverBullets -= 1;
					} else if (revolverBullets > 0) {
						revolverBullets -= 1;
					}
				}
				App.Events.addNode(node, r, "div");
				r = [];
				if (eliteDead >= 1) {
					r.push(`You managed to kill several Elites in rapid succession, leaving the rest in shock and fear.`);
				} else if (eliteDead === 1) {
					r.push(`You managed to kill one Elite, leaving the rest in shock and fear.`);
				} else {
					r.push(`Unfortunately you fail to kill a single Elite.`);
				}
				App.Events.addNode(node, r, "div");
				r = [];

				/* syringe shot */
				eliteVegetable = 0;
				let druggedThrow = 0;

				if (eliteDead > 0) {
					r.push(`With ${eliteDead} Elites dead, you pick up the syringe from the desk and aim for the forehead of another.`);
				} else {
					r.push(`Having failed to kill them with the revolver, in a desperate move you pick up the syringe from the desk and aim for the forehead of one of the elite.`);
				}
				if (V.PC.pregSource === -1 || V.PC.pregSource === -6) {
					r.push(`But there's two of them... Shaking your head, you realize it's the drugs messing with you. You just need to focus.`);
				}
				const hitRoll = (random(0, 100) - druggedThrow);
				let syringeHeadShot;
				if (V.PC.career === "mercenary" && hitRoll > 0) {
					r.push(`With your prior history as a mercenary, making the throw is child's play.`);
					syringeHeadShot = 1;
				} else if (V.PC.skill.warfare >= 100) {
					if (hitRoll > 50) {
						r.push(`As a result of your mastery of warfare you successfully made the throw.`);
						syringeHeadShot = 1;
					} else {
						r.push(`Unfortunately you miss the shot.`);
						syringeHeadShot = 0;
					}
				} else if (V.PC.skill.warfare >= 60) {
					if (hitRoll > 60) {
						r.push(`As a result of your combat expertise you successfully made the throw.`);
						syringeHeadShot = 1;
					} else {
						r.push(`Unfortunately you miss the shot.`);
						syringeHeadShot = 0;
					}
				} else if (V.PC.skill.warfare >= 30) {
					if (hitRoll > 70) {
						r.push(`As you have some skill, you successfully made the throw.`);
						syringeHeadShot = 1;
					} else {
						r.push(`Unfortunately you miss the shot.`);
						syringeHeadShot = 0;
					}
				} else if (V.PC.skill.warfare >= 10) {
					if (hitRoll > 80) {
						r.push(`Your small amount of skill assisted you in making the throw.`);
						syringeHeadShot = 1;
					} else {
						r.push(`Unfortunately you miss the shot.`);
						syringeHeadShot = 0;
					}
				} else if (V.PC.skill.warfare < 10) {
					if (hitRoll > 90) {
						r.push(`By blind luck you successfully made the throw.`);
						syringeHeadShot = 1;
					} else {
						r.push(`Unfortunately you miss the shot.`);
						syringeHeadShot = 0;
					}
				}
				App.Events.addNode(node, r, "div");
				r = [];
				let spentRevolverHitSyringePlunger;
				if (syringeHeadShot === 1) {
					r.push(`Picking up the spent revolver, you aim for the syringe's plunger.`);
					if (V.PC.career === "mercenary") {
						r.push(`With your prior history as a mercenary, making the throw is child's play.`);
						spentRevolverHitSyringePlunger = 1;
					} else if (V.PC.skill.warfare >= 100 && random(0, 100) > 50) {
						r.push(`As a result of your mastery of warfare you successfully made the throw.`);
						spentRevolverHitSyringePlunger = 1;
					} else if (V.PC.skill.warfare >= 60 && random(0, 100) > 60) {
						r.push(`As a result of your expertness of warfare you successfully made the throw.`);
						spentRevolverHitSyringePlunger = 1;
					} else if (V.PC.skill.warfare >= 30 && random(0, 100) > 70) {
						r.push(`As you have some skill you successfully made the throw.`);
						spentRevolverHitSyringePlunger = 1;
					} else if (V.PC.skill.warfare >= 10 && random(0, 100) > 80) {
						r.push(`Your small amount of skill assisted you in making the throw.`);
						spentRevolverHitSyringePlunger = 1;
					} else if (V.PC.skill.warfare < 10 && random(0, 100) > 90) {
						r.push(`By blind luck you successfully made the throw.`);
						spentRevolverHitSyringePlunger = 1;
					} else {
						r.push(`Unfortunately you miss the shot.`);
						spentRevolverHitSyringePlunger = 0;
					}
				}
				App.Events.addNode(node, r, "div");
				r = [];
				if (spentRevolverHitSyringePlunger === 1) {
					if (random(0, 100) > 50) {
						r.push(`The target dies of nervous system overload brought about by the drug.`);
						eliteDead += 1;
					} else {
						r.push(`The target is still alive but is nothing more than a vegetable.`);
						eliteVegetable = 1;
					}
				}
			}

			let eliteLeft = eliteTotal - eliteDead - eliteVegetable;

			/* if the player has managed to make enough damage to the Elite and the rep is high enough the citizens will come to save the PC */
			/* this is to give reason to exist for the "enrage" and "last stand" option */
			/* result							*/
			/* fate:							*/
			/*		killed = 0					*/
			/*		enslaved = 1				*/
			/*		had fun (and enslaved) = 2	*/

			if (bgSignaled === 1) {
				const {title: Master} = getEnunciation(S.Bodyguard);
				r.push(`${S.Bodyguard.slaveName} asks, "${Master}, what should I do with the`);
				if (eliteLeft < eliteTotal) {
					r.push(`remaining`);
				}
				r.push(`'Elite' left?"`);
				App.Events.addNode(node, r, "div");
				node.append(resultLinks());
			} else if (mercenariesMessageSent === 1) {
				r.push(`It is now that a squad of ${V.mercenariesTitle} makes their entrance, pointing their guns at the`);
				if (eliteLeft < eliteTotal) {
					r.push(`remaining`);
				}
				r.push(`Elite. The officer asks, "Your orders, ${properTitle()}?"`);

				App.Events.addNode(node, r, "div");
				node.append(resultLinks());
			} else if (specialForcesMessageSent) {
				r.push(`It is now that a squad of ${V.SF.Lower} makes their entrance, pointing their guns at the`);
				if (eliteLeft < eliteTotal) {
					r.push(`remaining`);
				}
				r.push(`Elite. The officer asks, "Your orders, ${properTitle()}?"`);

				node.append(resultLinks());
			} else if (V.BodyguardID !== 0) {
				const {title: Master} = getEnunciation(S.Bodyguard);
				r.push(`It is now that ${S.Bodyguard.slaveName} makes ${his} entrance, pointing ${his} guns at the`);
				if (eliteLeft < eliteTotal) {
					r.push(`remaining`);
				}
				r.push(`Elite. ${He} then asks "${Master}, what should I do with the`);
				if (eliteLeft < eliteTotal) {
					r.push(`remaining`);
				}
				r.push(`'Elite' left?"`);
				node.append(resultLinks());
			} else if (eliteLeft <= 9 && V.rep >= 10000) {
				r.push(`Some of the citizens waiting outside your penthouse to see you hear the ruckus and rush inside, worried. Time seems to freeze for a few seconds, while the remaining Elite recover from their terror and the citizens digest the gory scene in front of them.`);
				r.push(`The newcomers are quick to take your side. In little time the Elites, outgunned and outnumbered, are neutralized.`);
				App.Events.addNode(node, r, "div");
				r = [];
				r.push(`One of the more courageous citizens approaches you and asks "${properTitle()}, what should we do with them?"`);
				App.Events.addNode(node, r, "div");
				node.append(resultLinks());
			} else if (finalChoice !== "give in") {
				r.push(`With nothing else left, you remain powerless to stop the`);
				if (eliteLeft < eliteTotal) {
					r.push(`remaining`);
				}
				r.push(`Elite, who quickly capture and enslave you. Your personal story may continue, but the part of it worthy of retelling has now ended.`);
				V.ui = "start";
				App.Events.addParagraph(node, r);
				App.UI.DOM.appendNewElement("p", node, "GAME OVER", "bold");
			}
			return node;

			function resultLinks() {
				const div = document.createElement("div");
				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(
					"Open fire",
					() => {
						$(container).empty().append(eliteTakeOverResult(0));
					}
				));
				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(
					"Enslave them",
					() => {
						$(container).empty().append(eliteTakeOverResult(1));
					}
				));
				App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(
					"Have fun with them",
					() => {
						$(container).empty().append(eliteTakeOverResult(2));
					}
				));
				return div;
			}

			/**
			 *
			 * @param {0|1|2} fate
			 * @returns {DocumentFragment}
			 */
			function eliteTakeOverResult(fate) {
				const node = new DocumentFragment();
				let r = [];

				V.nextButton = "Continue";
				App.Utils.updateUserButton(); /* unlock Continue button */

				const {
					himU, hisU
				} = getNonlocalPronouns(V.seeDicks).appendSuffix("U");
				let sfHappyEverAfter;

				switch (fate) {
					case 0:
						if (mercenariesMessageSent === 1) {
							r.push(`The mercenaries open fire as ordered. Shortly after, the conspiring Elite are dead.`);
						} else if (specialForcesMessageSent === 1) {
							r.push(`The soldiers open fire as ordered. Shortly after, the conspiring Elite are dead.`);
						} else if (eliteLeft <= 9 && V.rep >= 10000) {
							r.push(`Your citizens freeze for a second, then obey your orders. Shortly after, the conspiring Elite are dead.`);
						} else {
							r.push(`Your bodyguard opens fire as ordered. Shortly after, the conspiring Elite are dead.`);
						}
						break;
					case 1:
						if (random(0, 100) > 50) {
							r.push(`An Elite bites down on a cyanide pill hidden in a false tooth and`);
							if (random(0, 100) > 75) {
								r.push(`takes the coward's way out (how predictable), frothing at the mouth.`);
								eliteDead += 1;
							} else {
								r.push(`experiences great pain but unfortunately (for them at least) survives.`);
							}
						}
						App.Events.addNode(node, r, "div");
						r = [];
						if (mercenariesMessageSent === 1) {
							r.push(`The`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly captured and enslaved by your mercenaries.`);
						} else if (specialForcesMessageSent === 1) {
							r.push(`The`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly captured and enslaved by your soldiers.`);
						} else if (eliteLeft <= 9 && V.rep >= 10000) {
							r.push(`The`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly captured and enslaved by your loyal citizens.`);
						} else {
							r.push(`The`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly captured and enslaved by your bodyguard.`);
						}
						break;
					case 2:
						if (random(0, 100) > 50) {
							r.push(`An Elite bites down on a cyanide pill hidden in a false tooth and`);
							if (random(0, 100) > 75) {
								r.push(`takes the coward's way out (how predictable), frothing at the mouth.`);
								eliteDead += 1;
							} else {
								r.push(`experiences great pain but unfortunately (for them at least) survives.`);
							}
						}
						App.Events.addNode(node, r, "div");
						r = [];
						if (mercenariesMessageSent === 1) {
							r.push(`The`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly captured, abused and enslaved. The officer is thankful for giving the troops a chance to let off some stream. Two soldiers decide to double team an Elite; one ass fucks while the other facefucks. Another soldier takes a particular interest in an Elite and politely asks you "${properTitle()}, can I keep ${himU}?"`);
							App.Events.addNode(node, r, "div");

							App.Events.addResponses(node, [
								new App.Events.Result(`No`, no),
								new App.Events.Result(`Yes`, yes)
							]);

							function no() {
								return `Your rejection upsets some of them, but their professionalism ensures it isn't visible.`;
							}
							function yes() {
								eliteLeft -= 1;
								repX(2500, "event");
								return `For a second your acceptance shocks them. Once they recover they are very grateful. "Thank you ${properTitle()}, I'll make sure to look after ${himU}." Soon the story spreads of the kind arcology owner, enhancing your reputation.`;
							}
						} else if (specialForcesMessageSent) {
							r.push(`The`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly captured, abused and enslaved.`);
							if (V.SF.Depravity <= 0.3) {
								r.push(`Two soldiers decide to double team an Elite; one gropes ${hisU} ass while the other gropes ${hisU} tits.`);
							} else if (V.SF.Depravity <= 1.2) {
								r.push(`Two soldiers decide to double team an Elite; one assfucks while the other facefucks.`);
							} else {
								r.push(`Two soldiers decide to double team an Elite; one breaks out their knife and begins to make little breaks in the Elite's skin while the other soldier facefucks them.`);
							}
							r.push(`Another soldier takes a particular interest in an Elite and politely asks you "${properTitle()}, can I keep ${himU}?"`);
							App.Events.addParagraph(node, r);
							r = [];

							App.Events.addResponses(node, [
								new App.Events.Result(`No`, no),
								new App.Events.Result(`Yes`, yes)
							]);

							function no() {
								sfHappyEverAfter = 0;
								return `Your rejection upsets some of them, but their professionalism ensures it isn't visible.`;
							}
							function yes() {
								eliteLeft -= 1;
								sfHappyEverAfter = 1;
								repX(2500, "event");
								return `For a second your acceptance shocks them. Once they recover they are very grateful. "Thank you ${properTitle()}, I'll make sure to look after ${himU}." Soon the story spreads of the kind arcology owner, enhancing your reputation.`;
							}
							if (V.SF.MercCon.CanAttend === -2) {
								switch (V.SF.Colonel.Core) {
									case "kind":
										r.push(`The Colonel is shocked that you would allow her troops to do this but understands that it comes with the territory.`);
										if (sfHappyEverAfter === 1) { // TODO: this never worked in tw since this is set by a link that doesn't refresh this content.
											r.push(`"Thanks for being kind to one of my soldiers."`);
										}
										break;
									case "brazen":
									case "cruel":
									case "jaded":
										r.push(`The Colonel is grateful that you let her troops let off some steam.`);
										if (sfHappyEverAfter === 1) {
											r.push(`"Thanks for being kind to one of my soldiers."`);
										}
								}
							}
							V.SF.Depravity += 0.05;
						} else if (eliteLeft <= 9 && V.rep >= 10000) {
							if (V.arcologies[0].FSDegradationist !== "unset") {
								r.push(`An evil smile appears on the faces of your loyal citizens, while the surviving Elite freeze in terror. The impromptu festivity will go on for hours, getting more and more depraved.`);
							} else {
								r.push(`While some citizens respectfully step out, some join you in the fun. The impromptu festivities will go on for hours, getting more and more depraved.`);
							}
						} else {
							if (S.Bodyguard.fetish === "sadist") {
								r.push(`${S.Bodyguard.slaveName} gets out ${his} melee weapon and starts to give them many small cuts, the look of pleasure on ${his} face is evident.`);
							} else {
								r.push(`${S.Bodyguard.slaveName} ties them and then gets out ${his} melee weapon and starts to abuse them; ${his} face is blank.`);
							}
							App.Events.addNode(node, r, "div");
							r = [];
							r.push(`Shortly after, the terrified`);
							if (eliteLeft < eliteTotal) {
								r.push(`remaining`);
							}
							r.push(`Elite are quickly brought away to be officially enslaved.`);
						}
				}
				App.Events.addParagraph(node, r);

				if (fate >= 1) {
					if (eliteVegetable === 1) {
						eliteLeft--;
						let slave;
						const gender = (V.seeDicks === 100 || (random(1, 100) > 50)) ? "XY" : "XX"; /* 50% chance of getting girl or boy */

						slave = GenerateNewSlave(
							gender,
							{
								minAge: 25, maxAge: V.retirementAge - 2, disableDisability: 1, race: "nonslave"
							});
						slave.origin = "$He was a member of the Societal Elite, captured in their failed attempt at expressing their displeasure.";
						slave.career = "a well connected individual";
						slave.prestige = either(2, 2, 3); /* 33% chance of getting level 3 prestige */
						slave.prestigeDesc = "$He was once considered influential in society, but now $he's the one getting fucked.";
						slave.face = random(70, 100);
						if (slave.boobShape === "saggy" || slave.boobShape === "downward-facing") {
							slave.boobShape = either("perky", "torpedo-shaped", "wide-set");
						}
						applyMindbroken(slave, random(70, 100));
						slave.pubicHStyle = "waxed";
						slave.underArmHStyle = "waxed";
						slave.anus = 0;
						slave.weight = random(10, 75);
						setHealth(slave, jsRandom(60, 75), 0, 0, 0, jsRandom(0, 20));
						slave.canRecruit = 0;
						newSlave(slave); /* skip New Slave Intro */
					}
					for (let i = eliteLeft; i > 0; i--) {
						const gender = (V.seeDicks === 100 || (random(1, 100) > 50)) ? "XY" : "XX"; /* 50% chance of getting girl or boy */
						const slave = GenerateNewSlave(gender, {minAge: 25, maxAge: V.retirementAge - 2, race: "nonslave"});
						slave.origin = "$He was a member of the Societal Elite, captured in their failed attempt at expressing their displeasure.";
						slave.career = "a well connected individual";
						slave.prestige = either(2, 2, 3);
						slave.prestigeDesc = "$He was once considered influential in society, but now $he's the one getting fucked.";
						slave.face = random(70, 100);
						slave.devotion = random(-10, -20);
						slave.trust = random(-20, -30);
						if (slave.boobShape === "saggy" || slave.boobShape === "downward-facing") {
							slave.boobShape = either("perky", "torpedo-shaped", "wide-set");
						}
						slave.pubicHStyle = "waxed";
						slave.underArmHStyle = "waxed";
						slave.anus = 0;
						slave.weight = random(-30, 75);
						slave.intelligence = random(0, 60);
						slave.intelligenceImplant = 30;
						slave.skill.entertainment = 0;
						slave.skill.whoring = 0;
						setHealth(slave, jsRandom(60, 75), 0, 0, 0, jsRandom(0, 20));
						slave.canRecruit = 0;
						slave.behavioralFlaw = either("arrogant", "bitchy");
						if (fate === 2 && random(1, 100) >= 75) { /* 25% chance of getting mindbroken elites if they were abused */
							applyMindbroken(slave);
						}
						newSlave(slave); /* skip New Slave Intro */
					}
				}

				/* clean up */
				V.failedElite = 0;
				V.eugenicsFullControl = 1;
				return node;
			}
		}
	}
};

repo_name: Pecanus/fc

license: mit


code:
App.Events.pFoodCrisisLowerClass = class pFoodCrisisLowerClass extends App.Events.BaseEvent {
	actorPrerequisites() {
		return [];
	}

	eventPrerequisites() {
		return [
			() => App.Events.effectiveWeek() >= 48,
			() => !!V.mods.food.enabled,
			() => !V.eventResults.foodCrisis,
		];
	}

	execute(node) {
		const discount = V.PC.skill.trading >= 50 && ["capitalist", "entrepreneur", "business kid"].includes(V.PC.career) || V.PC.skill.trading >= 100;
		const price = discount ? 7500 : 10000;

		App.Events.addParagraph(node, [`The region supplying much of the Free City's food had been battling a famine for quite some time now — between the deteriorating weather and the war raging on — but it had always seemed the situation was improving, and your arcology's citizens never really had to worry about going to bed hungry. Unfortunately, that all changed this week. A firefight had broken out near one of the region's largest farms, and one of the main reserves of food was caught in the crossfire.`]);
		App.Events.addParagraph(node, [`Supplies steadily began to dwindle, and it wasn't long before the prices of food began to rise as a result. ${V.arcologyUpgrade.hydro ? `Even the hydroponics system you had installed earlier could barely put a dent in the needs of your citizens.` : ``} Now, the poorest in your arcology are facing starvation. Seeing no other choice, they turned to you to provide them with sustenance. This is a unique opportunity. It's unlikely your citizens would ask for your help again, should you choose not to help them.`]);

		App.Events.addResponses(node, [
			new App.Events.Result(`Provide them with ample rations`, ample, `This will cost ${cashFormat(price * 2.5)} and ${discount ? `some upkeep, reduced by your knowledge of trading` : `will incur significant upkeep costs`}.`),
			new App.Events.Result(`Give them enough to survive on`, enough, `This will cost ${cashFormat(price * 1.5)} and ${discount ? `some upkeep, reduced by your knowledge of trading` : `will incur significant upkeep costs`}.`),
			new App.Events.Result(`They can figure their problem out on their own`, refuse)
		]);

		V.eventResults.foodCrisis = 1;	// don't repeat this event

		function ample() {
			V.mods.food.rations = 2;
			cashX(forceNeg(price * 2.5), "farmyard");
			repX(3500, "event");

			App.Events.queueEvent(2, new App.Events.pFoodCrisisMiddleClass());
			return `You have enough to go around, so you decide to help the desperate citizens. You have a number of rationing stations set up throughout ${V.arcologies[0].name} and announce that each citizen is entitled to four full meals a day, more than enough to sate the hunger of even the most famished of men. Your citizens are thrilled to hear that their leader is looking out for them.`;
		}

		function enough() {
			V.mods.food.rations = 1;
			cashX(forceNeg(price * 1.5), "farmyard");
			repX(2000, "event");

			App.Events.queueEvent(2, new App.Events.pFoodCrisisMiddleClass());
			return `You have your own problems to deal with, but that doesn't mean you don't look out for your own. You have a number of rationing stations set up throughout ${V.arcologies[0].name} and announce that each citizen is entitled to two full meals a day, just enough for your citizens not to starve. Your citizens are happy to hear that their leader is looking out for them.`;
		}

		function refuse() {
			V.mods.food.rations = 0;
			repX(-1500, "event");
			return `You have your own problems to deal with, and you simply can't afford to drop everything and solve theirs at the moment. That you can't take care of your arcology's citizen reflects poorly on you.`;
		}
	}
};


code:
App.Events.pFoodCrisisMiddleClass = class pFoodCrisisMiddleClass extends App.Events.BaseEvent {
	actorPrerequisites() {
		return [];
	}

	eventPrerequisites() {
		return [];
	}

	execute(node) {
		const discount = V.PC.skill.trading >= 50 && ["capitalist", "entrepreneur", "business kid"].includes(V.PC.career) || V.PC.skill.trading >= 100;
		const price = discount ? 7500 : 10000;

		App.Events.addParagraph(node, [`It's been a few weeks since your citizens had approached you asking for aid, and since then, the situation hasn't improved. In fact, it had gotten worse, and food prices have reached a record high. The tension in ${V.arcologies[0].name} is palpable, and small riots have broken out more than once over disputes about food. You are not surprised, then, when you receive a visit from some more of your citizens – not the poor, but not wealthy either. They state that they noticed that you have been giving out rations to the poorer citizens, and, now that the situation has become dire, were wondering if you would be willing to do the same for them.`]);

		App.Events.addResponses(node, [
			new App.Events.Result(`Give them generous rations as well`, ample, `This will cost ${cashFormat(price * 2)} and ${discount ? `some upkeep, reduced by your knowledge of trading` : `will incur significant upkeep costs`}.`),
			new App.Events.Result(`Give them enough to survive on`, enough, `This will cost ${cashFormat(price)} and ${discount ? `some upkeep, reduced by your knowledge of trading` : `will incur significant upkeep costs`}.`),
			new App.Events.Result(`Change your mind about giving out any rations at all`, refuse)
		]);

		function ample() {
			V.mods.food.rations = 4;
			cashX(forceNeg(price * 2), "farmyard");
			repX(3000, "event");

			App.Events.queueEvent(2, new App.Events.pFoodCrisisUpperClass());
			return `You still have more than enough to go around, so you inform the leaders that you have decided you will give them large rations, enough to feed even the hungriest citizen. The leaders are very pleased to hear that you are taking care of them as well.`;
		}

		function enough() {
			V.mods.food.rations = 3;
			cashX(forceNeg(price), "farmyard");
			repX(1500, "event");

			App.Events.queueEvent(2, new App.Events.pFoodCrisisUpperClass());
			return `As much as you'd like to provide them with all of the food in the world, it simply is not feasible in your current situation. Therefore, you announce to the leaders that you will provide them only enough rations to live off of. The leaders understand, and are pleased to hear that you would provide for them at all.`;
		}

		function refuse() {
			V.mods.food.rations = 0;
			repX(-1500, "event");
			return `Having given the people rations at all was a mistake, you think to yourself. You have a great number of your own problems to deal with, and providing rations to everyone that can't afford food is putting an unnecessary strain on your own situation. With this is mind, you tell the leaders that you simply can't help them at this time, and have decided that you can't help anyone with food at all. The citizens are understandably angry that you would go back on your word.`;
		}
	}
};


code:
App.Events.pFoodCrisisUpperClass = class pFoodCrisisUpperClass extends App.Events.BaseEvent {
	actorPrerequisites() {
		return [];
	}

	eventPrerequisites() {
		return [];
	}

	execute(node) {
		const discount = V.PC.skill.trading >= 50 && ["capitalist", "entrepreneur", "business kid"].includes(V.PC.career) || V.PC.skill.trading >= 100;
		const price = discount ? 7500 : 10000;

		App.Events.addParagraph(node, [`Another few weeks has passed since your last meeting with your citizens regarding rationing, and things have only deteriorated further since then. It was only a matter of time before the wealthier citizens of ${V.arcologies[0].name} paid you a visit one afternoon. While being able to afford food wasn't exactly difficult for them as of yet, they could read the writing on the wall, and knew it would only be a matter of time before the prices of food were so high that even they would be forced to beg for handouts.`]);
		App.Events.addParagraph(node, [`Seeing the progress you had made since taking control of the arcology, they decided their best course of action was to come to you with a proposition. They would allow you to take full control of the food supply in ${V.arcologies[0].name}, and in return you would keep them well-fed. This is a unique opportunity. If you turn their offer down, the citizens of your arcology will find another way of surviving.`]);

		App.Events.addResponses(node, [
			new App.Events.Result(`Set up a food market`, foodMarket, `This will cost an initial investment of ${cashFormat(price * 15)}${discount ? `, reduced by your knowledge of trading` : ``}.`),
			new App.Events.Result(`Politely decline their offer, but continue giving them rations`, enough, `This will cost ${cashFormat(price)} and ${discount ? `some upkeep, reduced by your knowledge of trading` : `will incur significant upkeep costs`}.`),
			new App.Events.Result(`Turn down their offer and end rationing completely`, refuse),
		]);

		function foodMarket() {
			V.mods.food.market = true;
			V.mods.food.rations = 0;
			cashX(forceNeg(price * 15), "farmyard");
			repX(5000, "event");
			return `You know that a proposition like this wouldn't have been easy for your citizens to make, and you also know that there is no one better suited to a task like this than you. You announce that you will be setting up a market to buy, sell, and store food in, and that you'll make sure that the citizens will continue to be well-fed. Your citizens are glad to hear that you are looking out for their best interests.`;
		}

		function enough() {
			V.mods.food.rations = 5;
			cashX(forceNeg(price), "farmyard");
			repX(1500, "event");
			return `Things have been going fairly well for you, but not that well — setting up an entirely new place to buy, sell, and store food would no doubt be an expensive undertaking. You tell the citizens that while you can't spare the resources to create a new market at the moment, you will honor your past agreement and continue giving them free rations. The people initially seem a bit disappointed that you don't seem to want to expand ${V.arcologies[0].name}, but are ultimately glad to hear that you'll continue taking care of them.`;
		}

		function refuse() {
			V.mods.food.rations = 0;
			repX(-1500, "event");
			return `While a new place to buy, sell, and store food in ${V.arcologies[0].name} would most likely come in quite handy in the future, you ultimately decide that you simply cannot spare the resources required. In fact, giving rations at all was a costly venture, and after not having seen any sort of return-on-investment, you decide that you are unable to continue giving out rations anymore. Your citizens are angry at the fact that you seem not to care about them at all, but that's their problem.`;
		}
	}
};


code:
App.Events.PCitizensAndCivilians = class PCitizensAndCivilians extends App.Events.BaseEvent {
	eventPrerequisites() {
		return [
			() => V.mercenaries >= 3,
		];
	}

	execute(node) {
		V.nextButton = " "; // hide button until user makes a selection

		let r = [];
		const mercDiscount = (V.PC.skill.warfare >= 100 || V.PC.career === "arcology owner");
		const cost = mercDiscount ? 10000 : 20000;

		const {
			HeA, heA, hisA, girlA, himselfA
		} = getPronouns(assistant.pronouns().main).appendSuffix("A");

		if (V.assistant.personality > 0) {
			r.push(`While working at your desk, you are accompanied by the luscious sound of ${V.assistant.name} humming to ${himselfA}, which ${heA} does to indicate ${heA}'s working on a difficult task. After this goes on for a while,`);
			switch (V.assistant.appearance) {
				case "monstergirl":
					r.push(`${hisA} monster${girlA} avatar uses ${hisA} tentacle hair to wave for your attention`);
					break;
				case "shemale":
					r.push(`${hisA} avatar helicopters ${hisA} dick until ${heA} has your attention`);
					break;
				case "amazon":
					r.push(`${hisA} avatar jumps up and down for your attention, hooting cheerfully,`);
					break;
				case "hypergoddess":
					r.push(`${hisA} avatar leans onto ${hisA} massive belly, allowing ${hisA} tits to flop onto the ground to get your attention,`);
					break;
				case "loli":
					r.push(`${hisA} avatar eagerly jumps up and down to get your attention`);
					break;
				case "preggololi":
					r.push(`${hisA} avatar eagerly waves ${hisA} hands to get your attention`);
					break;
				case "businesswoman":
					r.push(`${hisA} avatar takes off ${hisA} reading glasses, straightens ${hisA} suit jacket,`);
					break;
				case "cherub":
				case "fairy":
				case "imp":
				case "pregnant fairy":
					r.push(`${hisA} avatar flies up to your face and waves ${hisA} arms`);
					break;
				case "goddess":
					r.push(`${hisA} avatar hefts up ${hisA} gravid body, glowing brighter than usual to get your attention,`);
					break;
				case "schoolgirl":
					r.push(`${hisA} school${girlA} avatar bounces up and down for your attention`);
					break;
				case "angel":
					r.push(`${hisA} avatar flaps ${hisA} wings to grab your attention`);
					break;
				case "incubus":
					r.push(`${hisA} avatar blows a huge load of cum to get your attention`);
					break;
				case "succubus":
					r.push(`${hisA} avatar lets loose a huge moan to get your attention`);
					break;
				case "witch":
					r.push(`${hisA} avatar summons a number of explosions, searing perfectly placed holes on ${hisA} robe, to get your attention`);
					break;
				case "ERROR_1606_APPEARANCE_FILE_CORRUPT":
					r.push(`${hisA} avatar explodes into a twisted being of flesh and blood, reforms into ${hisA} usual shape,`);
					break;
				default:
					r.push(`${hisA} symbol glows to get your attention`);
			}
			r.push(`and says, "${properTitle()}, I have a suggestion. At your request I have been reviewing historical slave societies for parallels with our current situation. I calculate it would be very advantageous to bind your mercenaries more closely to the arcology. It would be expensive, but if they were all given slaves, better weapons, and some sort of title, they would defend this place to the death."`);
		} else {
			r.push(`${capFirstChar(V.assistant.name)} catches your attention as you work at your desk. ${HeA} says, "${properTitle()}, a suggestion. Review of historical slave societies for parallels with your current situation is complete. Analysis indicates it would be advantageous to increase the loyalty of your mercenaries. It would be expensive, but if they were given slaves, better weapons, and an honorary title, they would defend the arcology with increased effectiveness."`);
		}

		App.Events.addParagraph(node, r);
		r = [];
		r.push(
			App.UI.DOM.makeElement("span", "This is a unique and very important opportunity", "bold"),
			"and must not be taken lightly.",
			App.UI.DOM.makeElement("span", "All of these choices have the same gameplay effect, and only differ in theme.", "note"),
		);
		App.Events.addParagraph(node, r);

		function costDesc() {
			if (mercDiscount) {
				return App.UI.DOM.combineNodes(
					`This will cost ${cashFormat(cost)} and some upkeep, `,
					App.UI.DOM.makeElement("span", "reduced by your mercenary contacts", ["skill", "player"])
				);
			} else {
				return `This will cost ${cashFormat(cost)} and incur significant upkeep costs`;
			}
		}

		const choices = [];
		choices.push(new App.Events.Result(`Decline`, decline));
		choices.push(new App.Events.Result(`They shall be my Knights`, generic, costDesc()));

		if (V.arcologies[0].FSRomanRevivalist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Evocati`, FSRomanRevivalist, costDesc()));
		}
		if (V.arcologies[0].FSNeoImperialist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Black Eagles`, FSNeoImperialist, costDesc()));
		}
		if (V.arcologies[0].FSAztecRevivalist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Shorn Ones`, FSAztecRevivalist, costDesc()));
		}
		if (V.arcologies[0].FSChineseRevivalist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Imperial Guards`, FSChineseRevivalist, costDesc()));
		}
		if (V.arcologies[0].FSEgyptianRevivalist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Medjay`, FSEgyptianRevivalist, costDesc()));
		}
		if (V.arcologies[0].FSEdoRevivalist >= 10) {
			choices.push(new App.Events.Result(`Naturally, they shall be the Samurai`, FSEdoRevivalist, costDesc()));
		}
		if (V.arcologies[0].FSArabianRevivalist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Janissaries`, FSArabianRevivalist, costDesc()));
		}
		if (V.arcologies[0].FSChattelReligionist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Knights Templar`, FSChattelReligionist, costDesc()));
		}
		if (V.arcologies[0].FSDegradationist >= 10) {
			choices.push(new App.Events.Result(`They shall be my Immortals`, FSDegradationist, costDesc()));
		}
		if (V.arcologies[0].FSAssetExpansionist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Vast Legions`, FSAssetExpansionist, costDesc()));
		}
		if (V.arcologies[0].FSTransformationFetishist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Surgical Corps`, FSTransformationFetishist, costDesc()));
		}
		if (V.arcologies[0].FSGenderRadicalist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Inglorious Bitches`, FSGenderRadicalist, costDesc()));
		}
		if (V.arcologies[0].FSGenderFundamentalist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Thousand Sons`, FSGenderFundamentalist, costDesc()));
		}
		if (V.arcologies[0].FSRepopulationFocus >= 10) {
			choices.push(new App.Events.Result(`They shall be the Guardians of the Unborn`, FSRepopulationFocus, costDesc()));
		}
		if (V.arcologies[0].FSRestart >= 10) {
			choices.push(new App.Events.Result(`They shall be my Shadowed Hand`, FSRestart, costDesc()));
		}
		if (V.arcologies[0].FSPhysicalIdealist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Asgardians`, FSPhysicalIdealist, costDesc()));
		}
		if (V.arcologies[0].FSHedonisticDecadence >= 10) {
			choices.push(new App.Events.Result(`They shall be the Tasters`, FSHedonisticDecadence, costDesc()));
		}
		if (V.arcologies[0].FSSupremacist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Knights of the Blood`, FSSupremacist, costDesc()));
		}
		if (V.arcologies[0].FSSubjugationist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Knights of the Purge`, FSSubjugationist, costDesc()));
		}
		if (V.arcologies[0].FSPaternalist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Wardens`, FSPaternalist, costDesc()));
		}
		if (V.arcologies[0].FSIntellectualDependency >= 10) {
			choices.push(new App.Events.Result(`They shall be the Shepherds`, FSIntellectualDependency, costDesc()));
		}
		if (V.arcologies[0].FSSlaveProfessionalism >= 10) {
			choices.push(new App.Events.Result(`They shall be the Geniuses`, FSSlaveProfessionalism, costDesc()));
		}
		if (V.arcologies[0].FSBodyPurist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Purifiers`, FSBodyPurist, costDesc()));
		}
		if (V.arcologies[0].FSSlimnessEnthusiast >= 10) {
			choices.push(new App.Events.Result(`They shall be the Abstemious`, FSSlimnessEnthusiast, costDesc()));
		}
		if (V.arcologies[0].FSPetiteAdmiration >= 10) {
			choices.push(new App.Events.Result(`They shall be the Caretakers`, FSPetiteAdmiration, costDesc()));
		}
		if (V.arcologies[0].FSStatuesqueGlorification >= 10) {
			choices.push(new App.Events.Result(`They shall be the Titans`, FSStatuesqueGlorification, costDesc()));
		}
		if (V.arcologies[0].FSPastoralist >= 10) {
			choices.push(new App.Events.Result(`They shall be the Rangers`, FSPastoralist, costDesc()));
		}

		App.Events.addResponses(node, choices);

		function decline() {
			unlock();
			return `The suggestion is absurd; no historical lessons are necessary for a world where drones and supercomputers rule the day. Your mercenaries will doubtless perform well enough as mercenaries.`;
		}

		function setConsequences(title){
			repX(5000, "event");
			cashX(forceNeg(cost), "mercenaries");
			V.mercenaries = 5;
			V.mercenariesTitle = title;
			unlock();
		}
		function generic() {
			setConsequences("Knights");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Knight-Captain reporting for duty, ${properTitle()}." The mercenaries — no, the Knights — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSRomanRevivalist() {
			setConsequences("Evocati");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Centurion reporting for duty, ${properTitle()}." The mercenaries — no, the Evocati — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and bearing a Roman standard. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSNeoImperialist() {
			setConsequences("Black Eagles");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Black Marshal reporting for duty, ${properTitle()}." The mercenaries — no, the Black Eagles — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and bearing a standard with your Imperial crest. Word of the innovation runs through the Free Cities like wildfire.`;
		}

		function FSAztecRevivalist() {
			setConsequences("Shorn Ones");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Centurion reporting for duty, ${properTitle()}." The mercenaries — no, the Shorn Ones — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and bearing an Aztec standard adorned on a spear. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSChineseRevivalist() {
			setConsequences("Imperial Guards");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "General of the Imperial Guard, reporting for duty, ${properTitle()}." The mercenaries — no, the Imperial Guards — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and bearing an Imperial Chinese war banner. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSEgyptianRevivalist() {
			setConsequences("Medjay");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "First Medjay reporting for duty, ${properTitle()}." The mercenaries — no, the Medjay — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and bearing a faux cheetah cloak. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSEdoRevivalist() {
			setConsequences("Samurai");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Your Samurai-Lord reports for duty, ${properTitle()}." The mercenaries — no, the Samurai — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons, exterior plates styled after lacquered Samurai armor, and an enraged mask covering the face. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSArabianRevivalist() {
			setConsequences("Janissaries");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Corbaci reporting for duty, ${properTitle()}." The mercenaries — no, the Janissaries — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and cloaked in an outer garment of fine oriental silks. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSChattelReligionist() {
			setConsequences("Knights Templar");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Inquisitor-General reporting for duty, ${properTitle()}." The mercenaries — no, the Knights Templar — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and bearing a cloak emblazoned with the symbol of God. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSDegradationist() {
			setConsequences("Immortals");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Satrap reporting for duty, ${properTitle()}." The mercenaries — no, the Immortals — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and more than one wicked, curved blade. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSAssetExpansionist() {
			setConsequences("Vast Legions");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "The Vast Legions reporting for duty, ${properTitle()}." The mercenaries — no, the Vast Legions — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of bulky, heavily armored prototype armor. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSTransformationFetishist() {
			setConsequences("Surgical Corps");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Surgeon-General reporting for duty, ${properTitle()}." The mercenaries — no, the Surgical Corps — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest medical equipment. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSGenderRadicalist() {
			setConsequences("Inglorious Bitches");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Guess that makes me a bitch, ${properTitle()}." The mercenaries — no, the Inglorious Bitches — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor slathered in garish neon paint. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSGenderFundamentalist() {
			setConsequences("Thousand Sons");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Allfather reporting for duty, ${properTitle()}." The mercenaries — no, the Thousand Sons — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, a private gym, and a suit of prototype armor that preserves a sample of the wearer's genetic material in the event of death. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSRepopulationFocus() {
			setConsequences("Guardians of the Unborn");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Fetal Guardian reporting for duty, ${properTitle()}." The mercenaries — no, the Guardians of the Unborn — are well looked after. They are each assigned a nice apartment, three fertile slavegirls for the men, assured maternity leave for the ladies, and a suit of prototype armor designed to keep even the most heavily pregnant mercenary's child safe and sound. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSRestart() {
			setConsequences("Shadowed Hand");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Your Right Hand reporting for duty, ${properTitle()}." The mercenaries — no, the Shadowed Hand of the Societal Elite — are well looked after. They are each assigned a glorious apartment, a slave of their choice, what ever luxuries they can think of, and a suit of prototype armor equipped with the latest weapons and defenses. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSPhysicalIdealist() {
			setConsequences("Asgardians");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Foehammer reporting for duty, ${properTitle()}." The mercenaries — no, the Asgardians — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, a private gym, and a suit of prototype armor equipped with the latest weapons. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSHedonisticDecadence() {
			setConsequences("Tasters");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Lead Foodie reporting for duty, ${properTitle()}." The mercenaries — no, the Tasters — are well looked after. They are each assigned a comfy apartment, a freshly enslaved, plush servant, all the food and drink they can want (while off duty), and a suit of self-propelling prototype armor designed for maximum comfort without sacrificing protection. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSSupremacist() {
			setConsequences("Knights of the Blood");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Knights of the Blood reporting for duty, ${properTitle()}." The mercenaries — no, the Knights of the Blood — are well looked after. They are each assigned a nice apartment, three freshly enslaved servants of inferior races, and a suit of prototype armor equipped with the latest weapons. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSSubjugationist() {
			setConsequences("Knights of the Purge");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Knights of the Purge reporting for duty, ${properTitle()}." The mercenaries — no, the Knights of the Purge — are well looked after. They are each assigned a nice apartment, three freshly enslaved servants of the inferior race, and a suit of prototype armor equipped with the latest weapons. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSPaternalist() {
			setConsequences("Wardens");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a redesigned contract between you. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "First Warden reporting for duty, ${properTitle()}." The mercenaries — no, the Wardens — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons and a collapsible riot shield. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSIntellectualDependency() {
			setConsequences("Shepherds");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how needed this was. Just the other day I saw a half dozen bimbos waiting for a broken elevator. When I walked past an hour later, they were still waiting." He rises and gives you a short bow. "Shepherd of the slow reporting for duty, ${properTitle()}." The mercenaries — no, the Shepherds — are well looked after. They are each assigned a nice apartment, a very horny servant to stake their lust, and a suit of prototype armor equipped with the latest of weapons and a bevy of toys to lure wayward slaves with. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSSlaveProfessionalism() {
			setConsequences("Geniuses");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Chief brain reporting for duty, ${properTitle()}." The mercenaries — no, the Geniuses — are well looked after. They are each assigned a nice apartment, a skilled courtesan, and a suit of prototype armor equipped with cutting edge weaponry and combat systems. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSBodyPurist() {
			setConsequences("Purifiers");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Master Purifier reporting for duty, ${properTitle()}." The mercenaries — no, the Purifiers — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with a cleansing flamethrower. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSSlimnessEnthusiast() {
			setConsequences("Abstemious");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Lord-Abstinent reporting for duty, ${properTitle()}." The mercenaries — no, the Abstemious — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of sleek prototype armor equipped with advanced restraining weapons. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSPetiteAdmiration() {
			setConsequences("Caretakers");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "I'm ready to make a path for our little toys, ${properTitle()}." The mercenaries — no, the Caretakers — are well looked after. They are each assigned a nice apartment, a trio of tiny servants, and a suit of prototype armor capable of carrying multiple petite slaves in time of need. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSStatuesqueGlorification() {
			setConsequences("Titans");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Tallest Titan reporting for duty, ${properTitle()}." The mercenaries — no, the Titans — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a towering suit of prototype armor to make their presence known. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		function FSPastoralist() {
			setConsequences("Rangers");
			return `You ask for a meeting with your mercenaries' captain and lay out a proposal for a new contract between you over ${V.PC.refreshment}. As he reviews the terms, he looks skeptical, then surprised, then interested, and finally, he breaks out into laughter. "${properTitle()}," he says, "you have no idea how fun this is going to be." He rises and gives you a short bow. "Lead Ranger reporting for duty, ${properTitle()}." The mercenaries — no, the Rangers — are well looked after. They are each assigned a nice apartment, a freshly enslaved servant, and a suit of prototype armor equipped with the latest weapons — and an improbably massive revolver on the hip. Word of the innovation runs through the Free Cities like wildfire.`;
		}
		/** unlock Continue button */
		function unlock() {
			V.nextButton = "Continue";
			App.Utils.updateUserButton();
		}
	}
};


code:
App.Events.PMercenaries = class PMercenaries extends App.Events.BaseEvent {
	eventPrerequisites() {
		return [
			() => V.mercenaries === 0
		];
	}

	execute(node) {
		V.nextButton = "Continue";
		V.mercenaries = 0;
		V.mercenariesTitle = "mercenaries";

		let price = 5000;
		if (V.PC.skill.warfare >= 100) {
			price = 2500;
		} else if (V.PC.skill.warfare >= 50) {
			price = 3725;
		}

		App.Events.addParagraph(node, [`Another wave of security hysteria is sweeping the Free Cities. And this time, it's not based on rumor and alarmism. On the other side of the globe, a Free City was sacked by an old world army today. The Free City's handful of high-technology defenders and multitude of drones caused heavy casualties among the attackers, but eventually sheer weight of numbers wore them down.`]);

		App.Events.addParagraph(node, [`Your Free City is on good terms with the nations that border it, unlike the unfortunate sacked city, which was next to a nation suffering total collapse and looking for a convenient target. However, there's no telling how long this will last. The situation in the small, troubled country close to the arcology you've been monitoring grows worse by the day${(V.nationHate > 0) ? ", and if rumor of your enslavement of some of their vulnerable citizens got out, its people may have cause to hate you" : ""}.`]);

		App.Events.addParagraph(node, [
			`The budgetary difficulty many old world countries are in has resulted in unemployed soldiers looking for mercenary work. You could easily hire some of them to protect the arcology and fight in the militia if necessary.`,
			App.UI.DOM.makeElement("span", "This is a unique opportunity.", "bold"),
			`Without this security scare, it's unlikely you could convince any of your free-spirited tenants to even stay near a permanent armed presence.`
		]);
		const discount = (V.PC.skill.warfare >= 50 || V.PC.career === "arcology owner");
		const choices = [];
		choices.push(new App.Events.Result(
			`Quarter a squad in the arcology`, quarter,
			App.Events.makeNode([
				`This will cost ${cashFormat(price)} ${discount
					? `and some upkeep, <span class="skill player">reduced by your mercenary contacts.</span>`
					: `and incur significant upkeep costs.`}`
			])
		));
		choices.push(new App.Events.Result(
			`Quarter a platoon in the arcology`, platoon,
			App.Events.makeNode([
				`This will cost ${cashFormat(price * 2)} ${discount
					? `and some upkeep, <span class="skill player">reduced by your mercenary contacts.</span>`
					: `and incur significant upkeep costs.`}`
			])
		));
		choices.push(new App.Events.Result(`Do not quarter troops in your arcology`, plead3rd));
		App.Events.addResponses(node, choices);

		function quarter() {
			repX(-100, "event");
			cashX(forceNeg(price), "mercenaries");
			V.mercenaries = 1;
			if (V.secExpEnabled > 0) {
				V.SecExp.units.mercs.free = 15;
			}
			return `You hire some reputable mercenaries, kit them in excellent gear, and quarter them in ${V.arcologies[0].name}. The sight of armed men on patrol has offended some of the more free-spirited citizens of ${V.arcologies[0].name}.`;
		}

		function platoon() {
			repX(-500, "event");
			cashX(forceNeg(price * 2), "mercenaries");
			V.mercenaries = 3;
			if (V.secExpEnabled > 0) {
				V.SecExp.units.mercs.free = 30;
			}
			return `You hire a full platoon of reputable mercenaries with a veteran officer to command them, kit them in excellent gear, and quarter them in ${V.arcologies[0].name}. The sight of many armed men on patrol has deeply offended some of the more free-spirited citizens of ${V.arcologies[0].name}.`;
		}

		function plead3rd() {
			V.mercenaries = 0;
			return `Having armed men on permanent watch is a step too far. ${V.arcologies[0].name}'s security systems are formidable and will have to serve.`;
		}
	}
};