code:
App.Facilities.Farmyard.farmyard = function() {
	const frag = new DocumentFragment();

	V.nextButton = "Back to Main";
	V.nextLink = "Main";
	V.returnTo = "Farmyard";
	V.encyclopedia = "Farmyard";

	const farmyardNameCaps = capFirstChar(V.farmyardName);

	App.UI.DOM.appendNewElement("div", frag, intro(), "farmyard-intro");
	App.UI.DOM.appendNewElement("div", frag, expand(), "farmyard-expand");
	App.UI.DOM.appendNewElement("div", frag, menials(), "farmyard-menials");
	App.UI.DOM.appendNewElement("div", frag, rules(), "farmyard-rules");
	App.UI.DOM.appendNewElement("div", frag, upgrades(), "farmyard-upgrades");
	App.UI.DOM.appendNewElement("div", frag, animals(), "farmyard-animals");
	App.UI.DOM.appendNewElement("div", frag, App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.farmyard), "farmyard-slaves");
	App.UI.DOM.appendNewElement("div", frag, rename(), "farmyard-rename");

	App.UI.SlaveList.ScrollPosition.restore();

	function intro() {
		const frag = new DocumentFragment();

		const desc = App.UI.DOM.makeElement("div", '', "scene-intro");
		const link = App.UI.DOM.makeElement("div", '', "indent");

		const count = App.Entity.facilities.farmyard.totalEmployeesCount;
		const farmyardNameCaps = capFirstChar(V.farmyardName);

		desc.append(`${farmyardNameCaps} is an oasis of growth in the midst of the jungle of steel and concrete that is ${V.arcologies[0].name}. Animals are kept in pens, tended to by your slaves, while ${V.farmyardUpgrades.hydroponics ? `rows of hydroponics equipment` : `makeshift fields`} grow crops. `);

		switch (V.farmyardDecoration) {
			case "Roman Revivalist":
				desc.append(`Its red tiles and white stone walls are the very picture of a Roman farm villa's construction, as are the marble statues and reliefs. Saturn and Ceres look over the prosperity of the fields${V.seeBestiality ? `. Mercury watches over the health of the animals, and Feronia ensures strong litters in your slaves.` : `, and Mercury watches over the health of the animals.`} The slaves here are all looked after well, as they have one of the most important jobs in ${V.arcologies[0].name}.`);
				break;
			case "Neo Imperialist":
				desc.append(`Its high-tech, sleek black design invocates an embracement of the future, tempered by the hanging banners displaying your family crest as the rightful lord and master of these farms. Serf-like peasants work tirelessly in the fields, both to grow crops and oversee the slaves beneath them. Despite the harsh nature of the fieldwork, the slaves here are all looked after well, as they have one of the most important jobs in ${V.arcologies[0].name}.`);
				break;
			case "Aztec Revivalist":
				desc.append(`It can't completely recreate the floating farms in the ancient Aztec fashion, but it comes as close as it can, shallow pseudo-canals dividing each field into multiple sections. Smooth stone and colorful murals cover the walls, depicting bloody stories of gods and mortals alike.`);
				break;
			case "Egyptian Revivalist":
				desc.append(`It does its best to capture the wide open nature of ancient Egyptian farms, including mimicking the irrigation systems fed by the Nile. The stone walls are decorated with murals detailing its construction and your prowess in general, ${V.seeBestiality ? `with animal-bloated slaves featured prominently.` : `hieroglyphs spelling out a volumes of praise.`}`);
				break;
			case "Edo Revivalist":
				desc.append(`It does its best to mimic the rice patties and thatch roofed buildings of the Edo period despite the wide variety of crops tended by various slaves. Not every crop can thrive in flooded fields, but the ones that can take advantage of your attention to detail.`);
				break;
			case "Arabian Revivalist":
				desc.append(`Large plots of olive trees and date palms line the outer edges of the main crop area, while a combination of wheat, flax, and barley occupies the interior space. Irrigation canals snake through the area, ensuring every inch of cropland is well-watered.`);
				break;
			case "Chinese Revivalist":
				desc.append(`It does its best to capture the terraces that covered the ancient Chinese hills and mountains, turning every floor into ribbons of fields following a slight incline. Slaves wade through crops that can handle flooding and splash through the irrigation of the others when they aren't tending to${V.seeBestiality ? ` or breeding with` : ``} your animals.`);
				break;
			case "Chattel Religionist":
				desc.append(`It runs like a well oiled machine, slaves bent in humble service as they tend crops grown on the Prophet's command, or see to the animals' needs. Their clothing is tucked up and out of the way as they see to their tasks, keeping them clean as they work ${V.seeBestiality ? `around animal-bloated bellies ` : ``}as divine will dictates.`);
				break;
			case "Degradationist":
				desc.append(`It is constructed less as a converted warehouse and more as something to visit, allowing guests to enjoy the spectacle of slaves ${V.seeBestiality ? `being pounded by eager animals` : `elbow deep in scrubbing animal waste`} to their satisfaction.`);
				break;
			case "Repopulation Focus":
				desc.append(`It teems with life, both in the belly of every animal and the belly of every slave, though the latter makes tending the fields difficult. They're ordered to take care, as they carry the future ${V.seeBestiality ? `of this farm` : `of the arcology`} in their bellies.`);
				break;
			case "Eugenics":
				desc.append(`It holds a wide variety of crops and animals, but the best of the best is easy to find. They're set apart from the others, given only the best care and supplies${V.seeBestiality ? ` and bred with only the highest quality slaves` : ``}, while the sub-par stock is neglected off to the side.`);
				break;
			case "Asset Expansionist":
				desc.append(`It is not easy to look after animals and till fields with such enormous body parts, but your slaves are diligent regardless, working hard to provide food and livestock for the arcology.`);
				break;
			case "Transformation Fetishist":
				// desc.append(`TODO:`);
				break;
			case "Gender Radicalist":
				// desc.append(`TODO:`);
				break;
			case "Gender Fundamentalist":
				// desc.append(`TODO:`);
				break;
			case "Physical Idealist":
				desc.append(`Its animals are in exceptional shape, their coats unable to hide how muscular they are, requiring your slaves to be equally toned to control them. There's plenty of space for their exercise as well${V.seeBestiality ? ` and an abundance of curatives for the slaves full of their fierce, kicking offspring` : ``}.`);
				break;
			case "Supremacist":
				desc.append(`It is a clean and orderly operation, stables and cages mucked by a multitude of inferior slaves, along with grooming your animals and harvesting your crops.`);
				break;
			case "Subjugationist":
				desc.append(`It is a clean and orderly operation, stables and cages mucked by a multitude of ${V.arcologies[0].FSSubjugationistRace} slaves, while the others are tasked with grooming your animals and harvesting your crops.`);
				break;
			case "Paternalist":
				desc.append(`It's full of healthy animals, crops, and slaves, the former's every need diligently looked after by the latter. The fields flourish to capacity under such care, and the animals give the distinct impression of happiness${V.seeBestiality ? ` — some more than others if the growing bellies of your slaves are anything to go by, the only indication that such rutting takes place` : ``}.`);
				break;
			case "Pastoralist":
				// desc.append(`TODO:`);
				break;
			case "Maturity Preferentialist":
				// desc.append(`TODO:`);
				break;
			case "Youth Preferentialist":
				// desc.append(`TODO:`);
				break;
			case "Body Purist":
				// desc.append(`TODO:`);
				break;
			case "Slimness Enthusiast":
				desc.append(`It features trim animals and slaves alike, not a pound of excess among them. The feed for both livestock and crops are carefully maintained to ensure optimal growth without waste, letting them flourish without being weighed down.`);
				break;
			case "Hedonistic":
				desc.append(`It features wider gates and stalls, for both the humans visiting or tending the occupants, and the animals starting to mimic their handlers${V.seeBestiality ? ` and company` : ``}, with plenty of seats along the way.`);
				break;
			default:
				desc.append(`It is very much a converted warehouse still, sectioned off in various 'departments'${V.farmyardUpgrades.machinery ? ` with machinery placed where it can be` : V.farmyardUpgrades.hydroponics ? ` and plumbing for the hydroponics system running every which way` : ``}.`);
				break;
		}

		if (count > 2) {
			desc.append(` ${farmyardNameCaps} is bustling with activity. Farmhands are hurrying about, on their way to feed animals and maintain farming equipment.`);
		} else if (count) {
			desc.append(` ${farmyardNameCaps} is working steadily. Farmhands are moving about, looking after the animals and crops.`);
		} else if (S.Farmer) {
			desc.append(` ${S.Farmer.slaveName} is alone in $farmyardName, and has nothing to do but look after the animals and crops.`);
		} else {
			desc.append(` ${farmyardNameCaps} is empty and quiet.`);
		}

		link.append(App.UI.DOM.passageLink(`Decommission ${V.farmyardName}`, "Main", () => {
			if (V.farmMenials) {
				V.menials += V.farmMenials;
				V.farmMenials = 0;
			}

			V.farmyardName = "the Farmyard";
			V.farmyard = 0;
			V.farmyardDecoration = "standard";

			V.farmMenials = 0;
			V.farmMenialsSpace = 0;

			V.farmyardShows = 0;
			V.farmyardBreeding = 0;
			V.farmyardCrops = 0;

			V.farmyardKennels = 0;
			V.farmyardStables = 0;
			V.farmyardCages = 0;

			V.activeCanine = 0;
			V.activeHooved = 0;
			V.activeFeline = 0;

			V.pit.animal = null;

			V.canines = [];
			V.hooved = [];
			V.felines = [];

			V.farmyardUpgrades = {
				pump: 0,
				fertilizer: 0,
				hydroponics: 0,
				machinery: 0,
				seeds: 0
			};

			clearAnimalsBought();
			App.Arcology.cellUpgrade(V.building, App.Arcology.Cell.Manufacturing, "Farmyard", "Manufacturing");
		}));

		desc.append(link);
		frag.append(desc);

		return frag;
	}

	function expand() {
		const frag = new DocumentFragment();

		const desc = document.createElement("div");
		const link = App.UI.DOM.makeElement("div", '', "indent");
		const note = App.UI.DOM.makeElement("span", '', "note");
		const cost = App.UI.DOM.makeElement("span", '', "yellowgreen");

		const upgradeCost = Math.trunc(V.farmyard * 1000 * V.upgradeMultiplierArcology);
		const farmhands = App.Entity.facilities.farmyard.totalEmployeesCount;

		cost.append(cashFormat(upgradeCost));

		desc.append(`It can support ${V.farmyard} farmhands. Currently there ${farmhands === 1 ? `is` : `are`} ${farmhands} ${farmhands === 1 ? `farmhand` : `farmhands`} in ${V.farmyardName}. `);
		note.append(` Costs `, cost, ` and will increase upkeep costs`);

		link.append(App.UI.DOM.passageLink(`Expand ${V.farmyardName}`, "Farmyard", () => {
			cashX(forceNeg(upgradeCost), "capEx");
			V.farmyard += 5;
			V.PC.skill.engineering += .1;
		}));

		link.append(note);
		desc.append(link);
		frag.append(desc);

		if (App.Entity.facilities.farmyard.totalEmployeesCount) {
			App.UI.DOM.appendNewElement("div", frag, removeFacilityWorkers("farmyard"), "indent");
		}

		return frag;
	}

	function menials() {
		const frag = new DocumentFragment();

		frag.append(transferMenials());
		frag.append(buyMenials());
		frag.append(houseMenials());

		return frag;
	}

	function transferMenials() {
		const frag = new DocumentFragment();

		const links = [];
		const linksDiv = App.UI.DOM.makeElement("div", '', "indent");

		const menials = V.menials;
		const farmMenials = V.farmMenials;
		const farmMenialsSpace = V.farmMenialsSpace;

		if (farmMenials) {
			frag.append(`Assigned to ${V.farmyardName} ${farmMenials === 1 ? `is` : `are`} ${farmMenials} menial ${farmMenials === 1 ? `slave` : `slaves`}, working to produce as much food for your arcology as they can. `);
		}

		if (farmMenialsSpace) {
			frag.append(`You ${menials ? `own ${num(menials)}` : `don't own any`} free menial slaves. ${farmyardNameCaps} can house ${farmMenialsSpace} menial slaves total, with ${farmMenialsSpace - farmMenials} free spots. `);
		}

		if (farmMenialsSpace && farmMenials < farmMenialsSpace) {
			if (menials) {
				links.push(App.UI.DOM.passageLink("Transfer in a menial slave", "Farmyard", () => {
					V.menials--;
					V.farmMenials++;
				}));
			}

			if (menials >= 10 && farmMenials <= farmMenialsSpace - 10) {
				links.push(App.UI.DOM.passageLink("Transfer in 10 menial slaves", "Farmyard", () => {
					V.menials -= 10;
					V.farmMenials += 10;
				}));
			}

			if (menials >= 100 && farmMenials <= farmMenialsSpace - 100) {
				links.push(App.UI.DOM.passageLink("Transfer in 100 menial slaves", "Farmyard", () => {
					V.menials -= 100;
					V.farmMenials += 100;
				}));
			}

			if (menials) {
				links.push(App.UI.DOM.passageLink("Transfer in all free menial slaves", "Farmyard", () => {
					if (menials > farmMenialsSpace - farmMenials) {
						V.menials -= farmMenialsSpace - farmMenials;
						V.farmMenials = farmMenialsSpace;
					} else {
						V.farmMenials += menials;
						V.menials = 0;
					}
				}));
			}
		} else if (!farmMenialsSpace) {
			frag.append(`${farmyardNameCaps} cannot currently house any menial slaves. `);
		} else {
			frag.append(`${farmyardNameCaps} has all the menial slaves it can currently house assigned to it. `);
		}

		if (farmMenials) {
			links.push(App.UI.DOM.passageLink("Transfer out all menial slaves", "Farmyard", () => {
				V.menials += farmMenials;
				V.farmMenials = 0;
			}));
		}

		linksDiv.append(App.UI.DOM.generateLinksStrip(links));
		frag.append(linksDiv);

		return frag;
	}

	function buyMenials() {
		const frag = new DocumentFragment();

		const links = [];
		const linksDiv = App.UI.DOM.makeElement("div", '', "indent");

		const menials = V.menials;
		const farmMenials = V.farmMenials;
		const farmMenialsSpace = V.farmMenialsSpace;
		const popCap = menialPopCap();
		const bulkMax = popCap.value - menials - V.fuckdolls - V.menialBioreactors;

		const menialPrice = Math.trunc(menialSlaveCost());
		const maxMenials = Math.trunc(Math.clamp(V.cash / menialPrice, 0, bulkMax));

		if (farmMenialsSpace) {
			if (bulkMax > 0 || V.menials + V.fuckdolls + V.menialBioreactors === 0) {
				links.push(App.UI.DOM.passageLink("Buy ", "Farmyard", () => {
					V.menials++;
					V.menialSupplyFactor--;
					cashX(forceNeg(menialPrice), "farmyard");
				}));

				links.push(App.UI.DOM.passageLink("(x10)", "Farmyard", () => {
					V.menials += 10;
					V.menialSupplyFactor -= 10;
					cashX(forceNeg(menialPrice * 10), "farmyard");
				}));

				links.push(App.UI.DOM.passageLink("(x100)", "Farmyard", () => {
					V.menials += 100;
					V.menialSupplyFactor -= 100;
					cashX(forceNeg(menialPrice * 100), "farmyard");
				}));

				links.push(App.UI.DOM.passageLink("(max)", "Farmyard", () => {
					V.menials += maxMenials;
					V.menialSupplyFactor -= maxMenials;
					cashX(forceNeg(maxMenials * menialPrice), "farmyard");
				}));
			}
		}

		if (farmMenials) {
			linksDiv.append(App.UI.DOM.generateLinksStrip(links));
			frag.append(linksDiv);
		}

		return frag;
	}

	function houseMenials() {
		const frag = new DocumentFragment();

		const desc = document.createElement("div");
		const link = App.UI.DOM.makeElement("div", '', "indent");
		const note = App.UI.DOM.makeElement("span", '', "note");
		const cost = App.UI.DOM.makeElement("span", '', "yellowgreen");

		const unitCost = Math.trunc(1000 * V.upgradeMultiplierArcology);

		cost.append(cashFormat(unitCost));

		if (V.farmMenialsSpace < 500) {
			desc.append(`There is enough room in ${V.farmyardName} to build housing, enough to give ${V.farmMenialsSpace + 100} menial slaves a place to sleep and relax. `);
			note.append(` Costs `, cost, ` and will increase upkeep costs`);

			link.append(App.UI.DOM.passageLink("Build a new housing unit", "Farmyard", () => {
				cashX(forceNeg(unitCost), "farmyard");
				V.farmMenialsSpace += 100;
			}), note);

			desc.append(link);
			frag.append(desc);
		}

		return frag;
	}

	function rules() {
		const frag = new DocumentFragment();

		if (App.Entity.facilities.farmyard.employeesIDs().size > 0) {	// TODO: redo this with V.farmyardShowgirls
			if (V.farmyardShows && (V.canines || V.hooved || V.felines)) {
				const rule = makeRule(
					['Slaves', 'are putting on shows with animals'],
					'are',
					"End shows",
					[],
					["farmyardShows", "farmyardBreeding", "farmyardRestraints"]
				);

				frag.append(rule);

				if (V.seeBestiality) {
					if (V.farmyardBreeding) {
						const rule = makeRule(
							['Slaves', 'are being bred with animals'],
							'are',
							"End breeding",
							["farmyardShows"],
							["farmyardBreeding", "farmyardRestraints"]
						);

						frag.append(rule);

						if (V.farmyardRestraints) {
							const rule = makeRule(
								'are being restrained',
								'All of the slaves',
								"Restrain only disobedient slaves",
								["farmyardShows", "farmyardBreeding"],
								["farmyardRestraints"]
							);

							frag.append(rule);
						} else {
							const rule = makeRule(
								'are being restrained',
								'Only disobedient slaves',
								"Restrain all slaves",
								["farmyardShows", "farmyardBreeding", "farmyardRestraints"],
								[]
							);

							frag.append(rule);
						}
					} else {
						const rule = makeRule(
							['Slaves', 'being bred with animals'],
							'are not',
							"Begin breeding",
							["farmyardShows", "farmyardBreeding"],
							["farmyardRestraints"]
						);

						frag.append(rule);
					}
				}
			} else {
				const rule = makeRule(
					['Slaves', 'putting on shows with animals'],
					'are not',
					"Begin shows",
					["farmyardShows"],
					["farmyardBreeding", "farmyardRestraints"]
				);

				frag.append(rule);
			}
		}

		/**
		 * Creates a new rule button
		 * @param {string|string[]} descText The base description for the rule
		 * @param {string} boldText The part in bold
		 * @param {string} linkText The link text
		 * @param {string[]} enabled Variables to be set to 1
		 * @param {string[]} disabled Variables to be set to 0
		 */
		function makeRule(descText, boldText, linkText, enabled, disabled) {
			const frag = new DocumentFragment();

			const desc = document.createElement("div");
			const bold = App.UI.DOM.makeElement("span", boldText, "bold");
			const link = document.createElement("span");

			if (Array.isArray(descText)) {
				desc.append(`${descText[0]} `, bold, ` ${descText[1]}. `);
			} else {
				desc.append(bold, ` ${descText}. `);
			}

			link.append(App.UI.DOM.passageLink(linkText, "Farmyard", () => {
				enabled.forEach(i => V[i] = 1);
				disabled.forEach(i => V[i] = 0);
			}));

			desc.append(link);
			frag.append(desc);

			return frag;
		}

		return frag;
	}

	function upgrades() {
		const frag = new DocumentFragment(),

			farmyardUpgrades = V.farmyardUpgrades,

			pumpCost = Math.trunc(5000 * V.upgradeMultiplierArcology),
			fertilizerCost = Math.trunc(10000 * V.upgradeMultiplierArcology),
			hydroponicsCost = Math.trunc(20000 * V.upgradeMultiplierArcology),
			seedsCost = Math.trunc(25000 * V.upgradeMultiplierArcology),
			machineryCost = Math.trunc(50000 * V.upgradeMultiplierArcology);

		if (!farmyardUpgrades.pump) {
			const desc = document.createElement("div");
			const upgrade = createUpgrade(
				"Upgrade the water pump",
				pumpCost,
				'slightly decreases upkeep costs',
				"pump"
			);

			desc.append(`${farmyardNameCaps} is currently using the basic water pump that it came with.`);

			frag.append(desc, upgrade);
		} else {
			const desc = document.createElement("div");

			desc.append(`The water pump in ${V.farmyardName} is a more efficient model, slightly improving the amount of crops it produces.`);

			frag.append(desc);

			if (!farmyardUpgrades.fertilizer) {
				const upgrade = createUpgrade(
					"Use a higher-quality fertilizer",
					fertilizerCost,
					'moderately increases crop yield and slightly increases upkeep costs',
					"fertilizer"
				);

				frag.append(upgrade);
			} else {
				const desc = document.createElement("div");

				desc.append(`${farmyardNameCaps} is using a higher-quality fertilizer, moderately increasing the amount of crops it produces and raising slightly raising upkeep costs.`);

				frag.append(desc);

				if (!farmyardUpgrades.hydroponics) {
					const upgrade = createUpgrade(
						"Purchase an advanced hydroponics system",
						hydroponicsCost,
						'moderately decreases upkeep costs',
						"hydroponics"
					);

					frag.append(upgrade);
				} else {
					const desc = document.createElement("div");

					desc.append(`${farmyardNameCaps} is outfitted with an advanced hydroponics system, reducing the amount of water your crops consume and thus moderately reducing upkeep costs.`);

					frag.append(desc);

					if (!farmyardUpgrades.seeds) {
						const upgrade = createUpgrade(
							"Purchase genetically modified seeds",
							seedsCost,
							'moderately increases crop yield and slightly increases upkeep costs',
							"seeds"
						);

						frag.append(upgrade);
					} else {
						const desc = document.createElement("div");

						desc.append(`${farmyardNameCaps} is using genetically modified seeds, significantly increasing the amount of crops it produces and moderately increasing upkeep costs.`);

						frag.append(desc);

						if (!farmyardUpgrades.machinery) {
							const upgrade = createUpgrade(
								"Upgrade the machinery",
								machineryCost,
								'moderately increases crop yield and slightly increases upkeep costs',
								"machinery"
							);

							frag.append(upgrade);
						} else {
							const desc = document.createElement("div");

							desc.append(`The machinery in ${V.farmyardName} has been upgraded, and is more efficient, significantly increasing crop yields and significantly decreasing upkeep costs.`);

							frag.append(desc);
						}
					}
				}
			}
		}

		function createUpgrade(linkText, price, effect, type) {
			const desc = document.createElement("div");
			const link = App.UI.DOM.makeElement("div", '', "indent");
			const note = App.UI.DOM.makeElement("span", '', "note");
			const cost = App.UI.DOM.makeElement("span", '', "yellowgreen");

			cost.append(cashFormat(price));

			link.append(App.UI.DOM.passageLink(linkText, "Farmyard", () => {
				cashX(forceNeg(price), "farmyard");
				farmyardUpgrades[type] = 1;
			}));

			note.append(` Costs `, cost, ` and ${effect}.`);
			link.append(note);
			desc.append(link);

			return desc;
		}

		return frag;
	}

	function animals() {
		const frag = new DocumentFragment(),

			baseCost = Math.trunc(5000 * V.upgradeMultiplierArcology),
			upgradedCost = Math.trunc(10000 * V.upgradeMultiplierArcology);

		let farmyardKennels = V.farmyardKennels;
		let farmyardStables = V.farmyardStables;
		let farmyardCages = V.farmyardCages;

		// MARK: Kennels

		const CL = V.canines.length;

		const dogs = CL === 1 ? V.canines[0] : CL < 3 ?
			`several different breeds of dogs` :
			`all kinds of dogs`;
		const canines = CL === 1 ? V.canines[0].species === "dog" ?
			V.canines[0].breed : V.canines[0].speciesPlural : CL < 3 ?
			`several different ${V.canines.every(
				c => c.species === "dog") ?
				`breeds of dogs` : `species of canines`}` :
			`all kinds of canines`;

		const kennels = document.createElement("div");
		const kennelsUpgrade = App.UI.DOM.makeElement("div", '', "indent");
		const kennelsNote = App.UI.DOM.makeElement("span", '', "note");
		const kennelsCost = App.UI.DOM.makeElement("span", '', "yellowgreen");

		if (farmyardKennels === 0) {
			kennels.append(App.UI.DOM.passageLink("Add kennels", "Farmyard",
				() => {
					cashX(forceNeg(baseCost), "farmyard");
					V.farmyardKennels = 1;
				}));

			kennelsCost.append(cashFormat(baseCost));
			kennelsNote.append(` Costs `, kennelsCost, `, will incur upkeep costs, and unlocks domestic canines`);

			kennels.append(kennelsNote);
		} else if (farmyardKennels === 1) {
			kennels.append(App.UI.DOM.passageLink("Kennels", "Farmyard Animals"));
			kennels.append(` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${dogs}`}.`);

			if (V.rep > 10000) {
				kennelsUpgrade.append(App.UI.DOM.passageLink("Upgrade kennels", "Farmyard",
					() => {
						cashX(forceNeg(upgradedCost), "farmyard");
						V.farmyardKennels = 2;
					}));

				kennelsCost.append(cashFormat(upgradedCost));
				kennelsNote.append(` Costs `, kennelsCost, `, will incur additional upkeep costs, and unlocks exotic canines`);

				kennelsUpgrade.append(kennelsNote);
				kennels.append(kennelsUpgrade);
			}
		} else if (farmyardKennels === 2) {
			kennels.append(App.UI.DOM.passageLink("Large kennels", "Farmyard Animals"));
			kennels.append(` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${canines}`}.`);
		}

		// MARK: Stables

		const HL = V.hooved.length;

		const hooved = HL === 1 ? V.hooved[0] : HL < 3 ?
			`several different types of hooved animals` :
			`all kinds of hooved animals`;

		const stables = document.createElement("div");
		const stablesUpgrade = App.UI.DOM.makeElement("div", '', "indent");
		const stablesNote = App.UI.DOM.makeElement("span", '', "note");
		const stablesCost = App.UI.DOM.makeElement("span", '', "yellowgreen");

		if (farmyardStables === 0) {
			stables.append(App.UI.DOM.passageLink("Add stables", "Farmyard",
				() => {
					cashX(forceNeg(baseCost), "farmyard");
					V.farmyardStables = 1;
				}));

			stablesCost.append(cashFormat(baseCost));
			stablesNote.append(` Costs `, stablesCost, `, will incur upkeep costs, and unlocks domestic hooved animals`);

			stables.append(stablesNote);
		} else if (farmyardStables === 1) {
			stables.append(App.UI.DOM.passageLink("Stables", "Farmyard Animals"));
			stables.append(` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`);

			if (V.rep > 10000) {
				stablesUpgrade.append(App.UI.DOM.passageLink("Upgrade stables", "Farmyard",
					() => {
						cashX(forceNeg(upgradedCost), "farmyard");
						V.farmyardStables = 2;
					}));

				stablesCost.append(cashFormat(upgradedCost));
				stablesNote.append(` Costs `, stablesCost, `, will incur additional upkeep costs, and unlocks exotic hooved animals`);

				stablesUpgrade.append(stablesNote);
				stables.append(stablesUpgrade);
			}
		} else if (farmyardStables === 2) {
			stables.append(App.UI.DOM.passageLink("Large stables", "Farmyard Animals"));
			stables.append(` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`);
		}

		// MARK: Cages

		const FL = V.felines.length;

		const cats = FL === 1 ? V.felines[0] : FL < 3 ?
			`several different breeds of cats` :
			`all kinds of cats`;
		const felines = FL === 1 ? V.felines[0].species === "cat" ?
			V.felines[0].breed : V.felines[0].speciesPlural : FL < 3 ?
			`several different ${V.felines.every(
				c => c.species === "cat") ?
				`breeds of cats` : `species of felines`}` :
			`all kinds of felines`;

		const cages = document.createElement("div");
		const cagesUpgrade = App.UI.DOM.makeElement("div", '', "indent");
		const cagesNote = App.UI.DOM.makeElement("span", '', "note");
		const cagesCost = App.UI.DOM.makeElement("span", '', "yellowgreen");

		if (farmyardCages === 0) {
			cages.append(App.UI.DOM.passageLink("Add cages", "Farmyard",
				() => {
					cashX(forceNeg(baseCost), "farmyard");
					V.farmyardCages = 1;
				}));

			cagesCost.append(cashFormat(baseCost));
			cagesNote.append(` Costs `, cagesCost, `, will incur upkeep costs, and unlocks domestic felines`);

			cages.append(cagesNote);
		} else if (farmyardCages === 1) {
			cages.append(App.UI.DOM.passageLink("Cages", "Farmyard Animals"));
			cages.append(` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${cats}`}.`);

			if (V.rep > 10000) {
				cagesUpgrade.append(App.UI.DOM.passageLink("Upgrade cages", "Farmyard",
					() => {
						cashX(forceNeg(upgradedCost), "farmyard");
						V.farmyardCages = 2;
					}));

				cagesCost.append(cashFormat(upgradedCost));
				cagesNote.append(` Costs `, cagesCost, `, will incur additional upkeep costs, and unlocks exotic felines`);

				cagesUpgrade.append(cagesNote);
				cages.append(cagesUpgrade);
			}
		} else if (farmyardCages === 2) {
			cages.append(App.UI.DOM.passageLink("Large cages", "Farmyard Animals"));
			cages.append(` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${felines}`}.`);
		}

		// MARK: Remove Housing

		const removeHousing = document.createElement("div");
		const removeHousingNote = App.UI.DOM.makeElement("span", '', "note");
		const removeHousingCost = App.UI.DOM.makeElement("span", '', "yellowgreen");

		const removeHousingPrice = ((farmyardKennels + farmyardStables + farmyardCages) * 5000) * V.upgradeMultiplierArcology;

		if (farmyardKennels || farmyardStables || farmyardCages) {
			removeHousing.append(document.createElement("br"));

			removeHousing.append(App.UI.DOM.passageLink("Remove the animal housing", "Farmyard",
				() => {
					V.farmyardKennels = 0;
					V.farmyardStables = 0;
					V.farmyardCages = 0;

					V.farmyardShows = 0;
					V.farmyardBreeding = 0;
					V.farmyardRestraints = 0;

					V.canines = [];
					V.hooved = [];
					V.felines = [];

					clearAnimalsBought();
					cashX(forceNeg(removeHousingPrice), "farmyard");
				}));

			removeHousingCost.append(cashFormat(removeHousingPrice));
			removeHousingNote.append(` Will cost `, removeHousingCost);
			removeHousing.append(removeHousingNote);
		}

		frag.append(kennels, stables, cages, removeHousing);

		return frag;
	}

	function rename() {
		const frag = new DocumentFragment();

		const renameDiv = App.UI.DOM.makeElement("div", '', "farmyard-rename");
		const renameNote = App.UI.DOM.makeElement("span", '', "note");

		renameDiv.append(`Rename ${V.farmyardName}: `);
		renameNote.append(` Use a noun or similar short phrase`);

		renameDiv.append(App.UI.DOM.makeTextBox(V.farmyardName, newName => {
			V.farmyardName = newName;
		}));

		renameDiv.append(renameNote);

		frag.append(renameDiv);

		return frag;
	}

	function clearAnimalsBought() {
		for (const i in V.animalsBought) {
			V.animalsBought[i] = 0;
		}
	}

	return frag;
};


code:
:: Farmyard [nobr jump-to-safe jump-from-safe]

/* TODO: add "plots" of "crops" */
/* TODO: allow slaves that can't walk to put on shows */
/* TODO: write placeholders */

<<includeDOM App.Facilities.Farmyard.farmyard()>>

repo_name: Welptard/fc

license: mit


code:
:: Farmyard Animals [nobr]

<<set $nextButton = "Back", $nextLink = "Farmyard", $returnTo = "Farmyard Animals", $encyclopedia = "Farmyard">>

/* TODO: write some descriptions for the different animals in their cages */

<<if $farmyardKennels > 0 || $farmyardStables > 0 || $farmyardCages > 0>>

''Domestic Animals''

<<if $farmyardKennels > 0>>

	__Dogs__

//Cost <<print cashFormat(20000)>> each// /* TODO: this number is mostly a placeholder, will need adjusting */

	<<if $animalsBought.labradorRetrievers <= 0>>
		<<link "Purchase dogs" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.labradorRetrievers = 1, $animalsBought.canines += 1, $canines.push({
			species: "dog", speciesPlural: "dogs", breed: "Labrador Retrievers", type: "canine", dickSize: "big", ballType: "dog"
		})>><</link>>

	<<else>>
		Dogs
		<<if $activeCanine.breed != "Labrador Retriever">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Labrador Retriever", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
<</if>>

<<if $farmyardStables > 0>>

	__Hooved Animals__

//Cost <<print cashFormat(20000)>> each// /* TODO: this number is mostly a placeholder, will need adjusting */

	<<if $animalsBought.horses <= 0>>
		<<link "Purchase horses" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.horses = 1, $animalsBought.hooved += 1, $hooved.push("horses")>><</link>>

	<<else>>
		Horses
		<<if $activeHooved.species != "horse">>
			[[Set as active hooved|Farmyard Animals][$activeHooved = {species: "horse", speciesCap: "Horse", speciesPlural: "horses", type: "hooved", dickSize: "huge", ballType: "horse"}]]
		<<else>>
			//Set as active hooved//
		<</if>>

	<</if>>
	<<if $animalsBought.bulls <= 0>>
		<<link "Purchase bulls" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.bulls = 1, $animalsBought.hooved += 1, $hooved.push("bulls")>><</link>>

	<<else>>
		Bulls
		<<if $activeHooved.species != "bull">>
			[[Set as active hooved|Farmyard Animals][$activeHooved = {species: "bull", speciesCap: "Bull", speciesPlural: "bulls", type: "hooved", dickSize: "huge", ballType: "horse"}]]
		<<else>>
			//Set as active hooved//
		<</if>>

	<</if>>
	<<if $animalsBought.pigs <= 0>>
		<<link "Purchase pigs" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.pigs = 1, $animalsBought.hooved += 1, $hooved.push("pigs")>><</link>>

	<<else>>
		Pigs
		<<if $activeHooved.species != "pig">>
			[[Set as active hooved|Farmyard Animals][$activeHooved = {species: "pig", speciesCap: "Pig", speciesPlural: "pigs", type: "hooved", dickSize: "large", ballType: "horse"}]]
		<<else>>
			//Set as active hooved//
		<</if>>

	<</if>>
<</if>>
<</if>>

<<if $farmyardKennels > 1 || $farmyardStables > 1 || $farmyardCages > 1>>

''Exotic Animals''

<<if $farmyardKennels > 1>>

	__Canines__

//Cost <<print cashFormat(20000)>> each//

	<<if $animalsBought.wolves <= 0>>
		<<link "Purchase wolves" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.wolves = 1, $animalsBought.canines += 1, $canines.push({
			species: "wolf", speciesPlural: "wolves", type: "canine", dickSize: "large", ballType: "wolf"
		})>><</link>>

	<<else>>
		/*A couple of adult wolves are lounging about in their kennels.(OLD)*/
		Wolves
		<<if $activeCanine.species != "wolf">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "wolf", speciesCap: "Wolf", speciesPlural: "wolves", type: "canine", dickSize: "large", ballType: "wolf"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
<</if>>

<<if $farmyardCages > 1>>

	__Felines__

//Cost <<print cashFormat(30000)>> each// /* TODO: this number is mostly a placeholder, will need adjusting */

	<<if $animalsBought.lions <= 0>>
		<<link "Purchase lions" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(30000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.lions = 1, $animalsBought.felines += 1, $felines.push({
			species: "lion", speciesPlural: "lions", type: "feline", dickSize: "large", ballType: "lion"})>><</link>>

	<<else>>
		/*Most of the lions are sunning themselves. (OLD)*/
		Lions
		<<if $activeFeline.species != "lion">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "lion", speciesCap: "Lion", speciesPlural: "lions", type: "feline", dickSize: "large", ballType: "lion"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
<</if>>
<</if>>


code:
App.Data.Facilities.farmyard = {
	baseName: "farmyard",
	genericName: null,
	jobs: {
		farmhand: {
			position: "farmhand",
			assignment: Job.FARMYARD,
			publicSexUse: false,
			fuckdollAccepted: false
		}
	},
	defaultJob: "farmhand",
	manager: {
		position: "farmer",
		assignment: Job.FARMER,
		careers: App.Data.misc.farmerCareers,
		skill: "farmer",
		publicSexUse: false,
		fuckdollAccepted: false,
		broodmotherAccepted: false,
		shouldWalk: true,
		shouldHold: true,
		shouldSee: true,
		shouldHear: true,
		shouldTalk: false,
		shouldThink: true,
		requiredDevotion: 51
	}
};

App.Entity.Facilities.FarmHandJob = class extends App.Entity.Facilities.FacilitySingleJob {
	/**
	 * @override
	 */
	get assignment() {
		return `work in ${this.facility.name}`;
	}
};

App.Entity.facilities.farmyard = new App.Entity.Facilities.SingleJobFacility(
	App.Data.Facilities.farmyard, {
		farmhand: new App.Entity.Facilities.FarmHandJob()
	}
);


code:
:: Farmyard Report [nobr]

<<includeDOM App.Facilities.Farmyard.farmyardReport()>>


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @returns {number}
 */
App.Facilities.Farmyard.foodAmount = function(slave) {
	let food = 150;

	if (!slave) {
		throw `Current slave is not valid. Please report this`;
	}

	if (V.farmyardUpgrades.pump) {
		food += 15;
	}

	if (V.farmyardUpgrades.fertilizer) {
		food += 35;
	}

	if (V.farmyardUpgrades.seeds) {
		food += 65;
	}

	if (V.farmyardUpgrades.machinery) {
		food += 65;
	}

	if (S.Farmer) {
		food *= 1.1;

		if (S.Farmer.skill.farmer >= V.masteredXP) {
			food *= 1.2;
		}

		if (setup.farmerCareers.includes(S.Farmer.career)) {
			food *= 1.2;
		}
	}

	if (slave.devotion > 50) {
		food *= 1.1;
	} else if (slave.devotion < -50) {
		food *= 0.8;
	}

	if (slaveResting(slave)) {
		food *= 0.9;
	} else if (slave.health.tired + 20 >= 90 && !willWorkToDeath(slave)) {
		slave.devotion -= 10;
		slave.trust -= 5;
		food *= 0.9;
	}

	if (slave.muscles > 30) {										// slave is muscular or more
		food *= 1.1;
	} else if (slave.muscles <= -6) {								// slave is weak or less
		food *= 0.8;
	}

	if (slave.weight > 95) {										// slave is overweight or more
		food *= 0.9;
	} else if (slave.weight > 130) {								// slave is fat or more
		food *= 0.8;
	} else if (slave.weight > 160) {								// slave is obese or more
		food *= 0.7;
	} else if (slave.weight > 190) {								// slave is very obese or more
		food *= 0.6;
	}

	if (!canSee(slave)) {											// slave is blind
		food *= 0.6;
	} else if (!canSeePerfectly(slave)) {							// slave is nearsighted
		food *= 0.8;
	}

	if (slave.hears === -1) {										// slave is hard of hearing
		food *= 0.8;
	} else if (slave.hears < -1) {									// slave is deaf
		food *= 0.6;
	}

	food *= restEffects(slave, 20);
	food = Math.trunc(Math.max(food, 1));

	return food;
};


code:
:: Food Market [nobr]

<<if $useTabs == 0>>__The Food Market__<</if>>

<<set _foodValue = Math.round(($foodStored*$farmyardFoodCost + Number.EPSILON) * 100) / 100>>
<<set _maxFood = Math.trunc($cash/$farmyardFoodCost)>>
The food market has @@.chocolate;<<print massFormat($foodStored)>>@@ in storage, valued at a total of @@.yellowgreen;<<print cashFormat(_foodValue)>>.@@

<<set $nextLink = "Main">>

<<link "Buy <<= massFormat(1)>>" _link>><<set cashX(forceNeg($farmyardFoodCost*1), "farmyard"), $foodStored += 1>><</link>>
| <<link "<<= massFormat(10)>>" _link>><<set cashX(forceNeg($farmyardFoodCost*10), "farmyard"), $foodStored += 10>><</link>>
| <<link "<<= massFormat(100)>>" _link>><<set cashX(forceNeg($farmyardFoodCost*100), "farmyard"), $foodStored += 100>><</link>>
| <<link "<<= massFormat(1000)>>" _link>><<set cashX(forceNeg($farmyardFoodCost*1000), "farmyard"), $foodStored += 1000>><</link>>
| <<link "<<= massFormat(10000)>>" _link>><<set cashX(forceNeg($farmyardFoodCost*10000), "farmyard"), $foodStored += 10000>><</link>>
| <<link "<<= massFormat(100000)>>" _link>><<set cashX(forceNeg($farmyardFoodCost*100000), "farmyard"), $foodStored += 100000>><</link>>
| <<link "max" _link>><<set cashX(forceNeg(_maxFood*$farmyardFoodCost), "farmyard"), $foodStored += _maxFood>><</link>>
<<if $foodStored > 0>>

	<<link "Sell <<= massFormat(1)>>" _link>><<set cashX(($farmyardFoodCost*1), "farmyard"), $foodStored -= 1>><</link>>
	<<if $foodStored >= 10>>
		| <<link "<<= massFormat(10)>>" _link>><<set cashX(($farmyardFoodCost*10), "farmyard"), $foodStored -= 10>><</link>>
	<</if>>
	<<if $foodStored >= 100>>
		| <<link "<<= massFormat(100)>>" _link>><<set cashX(($farmyardFoodCost*100), "farmyard"), $foodStored -= 100>><</link>>
	<</if>>
	<<if $foodStored >= 1000>>
		| <<link "<<= massFormat(1000)>>" _link>><<set cashX(($farmyardFoodCost*1000), "farmyard"), $foodStored -= 1000>><</link>>
	<</if>>
	<<if $foodStored >= 10000>>
		| <<link "<<= massFormat(10000)>>" _link>><<set cashX(($farmyardFoodCost*10000), "farmyard"), $foodStored -= 10000>><</link>>
	<</if>>
	<<if $foodStored >= 100000>>
		| <<link "<<= massFormat(100000)>>" _link>><<set cashX(($farmyardFoodCost*100000), "farmyard"), $foodStored -= 100000>><</link>>
	<</if>>
	| <<link "max" _link>><<set cashX(($farmyardFoodCost*$foodStored), "farmyard"), $foodStored = 0>><</link>>
<</if>>
<<if $food > 0>>

	<<link "Store <<= massFormat(1)>>" _link>><<set $foodStored += 1, $food -= 1>><</link>>
	<<if $food >= 10>>
		| <<link "<<= massFormat(10)>>" _link>><<set $foodStored += 10, $food -= 10>><</link>>
	<</if>>
	<<if $food >= 100>>
		| <<link "<<= massFormat(100)>>" _link>><<set $foodStored += 100, $food -= 100>><</link>>
	<</if>>
	<<if $food >= 1000>>
		| <<link "<<= massFormat(1000)>>" _link>><<set $foodStored += 1000, $food -= 1000>><</link>>
	<</if>>
	<<if $food >= 10000>>
		| <<link "<<= massFormat(10000)>>" _link>><<set $foodStored += 10000, $food -= 10000>><</link>>
	<</if>>
	<<if $food >= 100000>>
		| <<link "<<= massFormat(100000)>>" _link>><<set $foodStored += 100000, $food -= 10000>><</link>>
	<</if>>
	| <<link "max" _link>><<set $foodStored += $food, $food = 0>><</link>>
<</if>>
<<if $foodStored > 0>>

	<<link "Retrieve <<= massFormat(1)>>" _link>><<set $food += 1, $foodStored -= 1>><</link>>
	<<if $foodStored >= 10>>
		| <<link "<<= massFormat(10)>>" _link>><<set $food += 10, $foodStored -= 10>><</link>>
	<</if>>
	<<if $foodStored >= 100>>
		| <<link "<<= massFormat(100)>>" _link>><<set $food += 100, $foodStored -= 100>><</link>>
	<</if>>
	<<if $foodStored >= 1000>>
		| <<link "<<= massFormat(1000)>>" _link>><<set $food += 1000, $foodStored -= 1000>><</link>>
	<</if>>
	<<if $foodStored >= 10000>>
		| <<link "<<= massFormat(10000)>>" _link>><<set $food += 10000, $foodStored -= 10000>><</link>>
	<</if>>
	<<if $foodStored >= 100000>>
		| <<link "<<= massFormat(10000)>>" _link>><<set $food += 100000, $foodStored -= 10000>><</link>>
	<</if>>
	| <<link "max" _link>><<set $food += $foodStored, $foodStored = 0>><</link>>
<</if>>


code:
:: Food Report [nobr]

$arcologies[0].name produced <<= massFormat($foodLastWeek)>> of food this week. Blah blah write some more stuff here.


code:
:: P food crisis [nobr]

/* feel free to move this into a different folder */

<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>

<<if ($PC.skill.trading >= 100) || ($PC.career == "capitalist")>>
	<<set _price = 2500>>
<<elseif ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>
	<<set _price = 5000>>
<<else>>
	<<set _price = 10000>>
<</if>>

<<switch $foodCrisis>>
<<case 1>>

	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.

	Supplies steadily began to dwindle, and it wasn't long before the prices of food began to rise as a result. <<if $arcologyUpgrade.hydro == 1>>Even the hydroponics system you had installed earlier could barely put a dent in the needs of your citizens.<</if>> 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.

	<<link "Provide them with ample rations">>
		<<replace "#result">>
		You have enough to go around, so you decide to help the desperate citizens. You have a number of rationing stations set up throughout $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 @@.green;thrilled@@ to hear that their leader is looking out for them.
		<<run repX(5000, "event")>>
		<<set cashX(forceNeg(_price*2), "farmyard")>>
		<<set $rations = 2>>
		<</replace>>
	<</link>>
	<<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>//This will cost <<print cashFormat(_price*2)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price*2)>> and incur significant upkeep costs//<</if>>

<<link "Give them enough to survive on">>
		<<replace "#result">>
		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 $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 @@.green;happy@@ to hear that their leader is looking out for them.
		<<run repX(2500, "event")>>
		<<set cashX(forceNeg(_price), "farmyard")>>
		<<set $rations = 1>>
		<</replace>>
	<</link>>
	<<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>//This will cost <<print cashFormat(_price)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price)>> and incur significant upkeep costs//<</if>>

<<link "They can figure their problem out on their own">>
		<<replace "#result">>
		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 @@.red;reflects poorly on you.@@
		<<run repX(-500, "event")>>
		<</replace>>
	<</link>>

<<case 2>>

	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 $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 of the "middle class" /* TODO: still not really happy with this */ citizens. 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.

	<<link "Give them generous rations as well">>
		<<replace "#result">>
		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 @@.green;very pleased@@ to hear that you are taking care of them as well.
		<<run repX(5000, "event")>>
		<<set cashX(forceNeg(_price*2), "farmyard")>>
		<<set $rations = 4>>
		<</replace>>
	<</link>>
	<<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>//This will cost <<print cashFormat(_price*2)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price*2)>> and incur significant upkeep costs//<</if>>

<<link "Provide them with enough sustenance to survive on too">>
		<<replace "#result">>
		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 @@.green;pleased@@ to hear that you would provide for them at all.
		<<run repX(2500, "event")>>
		<<set cashX(forceNeg(_price), "farmyard")>>
		<<set $rations = 3>>
		<</replace>>
	<</link>>
	<<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>//This will cost <<print cashFormat(_price)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price)>> and incur significant upkeep costs//<</if>>

<<link "Change your mind about giving out any rations at all">>
		<<replace "#result">>
		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 @@.red;angry@@ that you would go back on your word.
		<<run repX(-1000, "event")>>
		<<set $rations = 0>>
		<</replace>>
	<</link>>

<<case 3>>

	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, then, before the wealthier citizens of $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.

	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 $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.

<<link "Set up a food market">>
		<<replace "#result">>
		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 @@.green;glad@@ to hear that you are looking out for their best interests.
		<<run repX(5000, "event")>>
		<<set cashX(forceNeg(_price*5), "farmyard")>>
		<<set $foodMarket = 1>>
		<<unset $rations>>
		<</replace>>
	<</link>>
	<<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>//This will cost an initial investment of <<print cashFormat(_price*5)>>, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost an initial investment of <<print cashFormat(_price*5)>>//<</if>>

<<link "Politely decline their offer, but continue giving them rations">>
		<<replace "#result">>
		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 $arcologies[0].name, but are ultimately @@.green;glad@@ to hear that you'll continue taking care of them.
		<<run repX(2500, "event")>>
		<<set cashX(forceNeg(_price), "farmyard")>>
		<<set $rations = 5>>
		<</replace>>
	<</link>>
	<<if ($PC.skill.trading >= 50) || ($PC.career == "capitalist")>>//This will cost <<print cashFormat(_price)>> and some upkeep, @@.springgreen;reduced by your knowledge of trading@@//<<else>>//This will cost <<print cashFormat(_price)>> and incur significant upkeep costs//<</if>>

<<link "Turn down their offer and end rationing completely">>
		<<replace "#result">>
		While a new place to buy, sell, and store food in $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 @@.red;angry@@ at the fact that you seem not to care about them at all, but that's their problem.
		<<run repX(-1000, "event")>>
		<<unset $rations>>
		<</replace>>
	<</link>>

<</switch>>


code:
/* Putting them here because commenting them out was breaking for some reason */

	<<if $animalsBought.germanShepherds == 0>>
		<<link "Purchase German Shepherds" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.germanShepherds = 1, $animalsBought.canines += 1, $canines.push("German Shepherds")>><</link>>

	<<elseif $animalsBought.germanShepherds == 1>>
		German Shepherds
		<<if $activeCanine.breed != "German Shepherd">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "German Shepherd", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.goldenRetrievers == 0>>
		<<link "Purchase Golden Retrievers" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.goldenRetrievers = 1, $animalsBought.canines += 1, $canines.push("Golden Retrievers")>><</link>>

	<<elseif $animalsBought.goldenRetrievers == 1>>
		Golden Retrievers
		<<if $activeCanine.breed != "Golden Retriever">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Golden Retriever", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.frenchBulldogs == 0>>
		<<link "Purchase French Bulldogs" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.frenchBulldogs = 1, $animalsBought.canines += 1, $canines.push("French Bulldogs")>><</link>>

	<<elseif $animalsBought.frenchBulldogs == 1>>
		French Bulldogs
		<<if $activeCanine.breed != "French Bulldog">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "French Bulldog", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.bulldogs == 0>>
		<<link "Purchase Bulldogs" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.bulldogs = 1, $animalsBought.canines += 1, $canines.push("Bulldogs")>><</link>>

	<<elseif $animalsBought.bulldogs == 1>>
		Bulldogs
		<<if $activeCanine.breed != "Bulldog">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Bulldog", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.beagles == 0>>
		<<link "Purchase Beagles" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.beagles = 1, $animalsBought.canines += 1, $canines.push("Beagles")>><</link>>

	<<elseif $animalsBought.beagles == 1>>
		Beagles
		<<if $activeCanine.breed != "Beagle">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Beagle", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.poodles == 0>>
		<<link "Purchase Poodles" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.poodles = 1, $animalsBought.canines += 1, $canines.push("Poodles")>><</link>>

	<<elseif $animalsBought.poodles == 1>>
		Poodles
		<<if $activeCanine.breed != "Poodle">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Poodle", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.rottweilers == 0>>
		<<link "Purchase Rottweilers" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.rottweilers = 1, $animalsBought.canines += 1, $canines.push("Rottweilers")>><</link>>

	<<elseif $animalsBought.rottweilers == 1>>
		Rottweilers
		<<if $activeCanine.breed != "Rottweiler">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Rottweiler", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.yorkshireTerriers == 0>>
		<<link "Purchase Yorkshire Terriers" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.yorkshireTerriers = 1, $animalsBought.canines += 1, $canines.push("Yorkshire Terriers")>><</link>>

	<<elseif $animalsBought.yorkshireTerriers == 1>>
		Yorkshire Terriers
		<<if $activeCanine.breed != "Yorkshire Terrier">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Yorkshire Terrier", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.siberianHuskies == 0>>
		<<link "Purchase Siberian Huskies" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.siberianHuskies = 1, $animalsBought.canines += 1, $canines.push("Siberian Huskies")>><</link>>

	<<elseif $animalsBought.siberianHuskies == 1>>
		Siberian Huskies
		<<if $activeCanine.breed != "Siberian Husky">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dog", speciesCap: "Dog", speciesPlural: "dogs", breed: "Siberian Husky", type: "canine", dickSize: "big", ballType: "dog"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>

<<if $farmyardCages > 0>>

	Cats:

	<<if $animalsBought.siameses == 0>>
		<<link "Purchase Siamese cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.siameses = 1, $animalsBought.felines += 1, $felines.push("Siamese cats")>><</link>>

	<<elseif $animalsBought.siameses == 1>>
		Siamese cats
		<<if $activeFeline.breed != "Siamese">>
			[[Set as active canine|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Siamese", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.persians == 0>>
		<<link "Purchase Persian cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.persians = 1, $animalsBought.felines += 1, $felines.push("Persian cats")>><</link>>

	<<elseif $animalsBought.persians == 1>>
		Persian cats
		<<if $activeFeline.breed != "Persian">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Persian", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.maineCoons == 0>>
		<<link "Purchase Maine Coon cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.maineCoons = 1, $animalsBought.felines += 1, $felines.push("Maine Coon cats")>><</link>>

	<<elseif $animalsBought.maineCoons == 1>>
		Maine Coon cats
		<<if $activeFeline.breed != "Maine Coon">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Maine Coon", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.ragdolls == 0>>
		<<link "Purchase Ragdoll cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.ragdolls = 1, $animalsBought.felines += 1, $felines.push("Ragdoll cats")>><</link>>

	<<elseif $animalsBought.ragdolls == 1>>
		Ragdoll cats
		<<if $activeFeline.breed != "Ragdoll">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Ragdoll", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.bengals == 0>>
		<<link "Purchase Bengal cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.bengals = 1, $animalsBought.felines += 1, $felines.push("Bengal cats")>><</link>>

	<<elseif $animalsBought.bengals == 1>>
		Bengal cats
		<<if $activeFeline.breed != "Bengal">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Bengal", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.abbysinians == 0>>
		<<link "Purchase Abbysinian cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.abbysinians = 1, $animalsBought.felines += 1, $felines.push("Abbysinian cats")>><</link>>

	<<elseif $animalsBought.abbysinians == 1>>
		Abbysinian cats
		<<if $activeFeline.breed != "Abbysinian">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Abbysinian", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.birmans == 0>>
		<<link "Purchase Birman cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.birmans = 1, $animalsBought.felines += 1, $felines.push("Birman cats")>><</link>>

	<<elseif $animalsBought.birmans == 1>>
		Birman cats
		<<if $activeFeline.breed != "Birman">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Birman", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.orientalShorthairs == 0>>
		<<link "Purchase Oriental Shorthair cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.orientalShorthairs = 1, $animalsBought.felines += 1, $felines.push("Oriental Shorthair cats")>><</link>>

	<<elseif $animalsBought.orientalShorthairs == 1>>
		Oriental Shorthair cats
		<<if $activeFeline.breed != "Oriental Shorthair">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Oriental Shorthair", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.sphynxes == 0>>
		<<link "Purchase Sphynx cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.sphynxes = 1, $animalsBought.felines += 1, $felines.push("Sphynx cats")>><</link>>

	<<elseif $animalsBought.sphynxes == 1>>
		Sphynx cats
		<<if $activeFeline.breed != "Sphynx">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Sphynx", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.russianBlues == 0>>
		<<link "Purchase Russian Blue cats" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.russianBlues = 1, $animalsBought.felines += 1, $felines.push("Russian Blue cats")>><</link>>

	<<elseif $animalsBought.russianBlues == 1>>
		Russian Blue cats
		<<if $activeFeline.breed != "Russian Blue">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cat", speciesCap: "Cat", speciesPlural: "cats", breed: "Russian Blue", type: "feline", dickSize: "small", ballType: "cat"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
<</if>>

	<<if $animalsBought.foxes == 0>>
		<<link "Purchase foxes" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.foxes = 1, $animalsBought.canines += 1, $canines.push("foxes")>><</link>>

	<<elseif $animalsBought.foxes == 1>>
		/*Red foxes play in one corner of their kennels, chasing one another.(OLD)*/
		Foxes
		<<if $activeCanine.species != "fox">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "fox", speciesCap: "Fox", speciesPlural: "foxes", type: "canine", dickSize: "large", ballType: "fox"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.jackals == 0>>
		<<link "Purchase jackals" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.jackals = 1, $animalsBought.canines += 1, $canines.push("jackals")>><</link>>

	<<elseif $animalsBought.jackals == 1>>
		/*A group of male jackals are fighting over a potential mate, causing quite a ruckus.(OLD)*/
		Jackals
		<<if $activeCanine.species != "jackal">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "jackal", speciesCap: "Jackal", speciesPlural: "jackals", type: "canine", dickSize: "large", ballType: "jackal"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>
	<<if $animalsBought.dingos == 0>>
		<<link "Purchase dingos" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.dingos = 1, $animalsBought.canines += 1, $canines.push("dingos")>><</link>>

	<<elseif $animalsBought.dingos == 1>>
		/*The dingos are eating their meal, growling at each other when one gets to close to another's food.(OLD)*/
		Dingos
		<<if $activeCanine.species != "dingo">>
			[[Set as active canine|Farmyard Animals][$activeCanine = {species: "dingo", speciesCap: "Dingo", speciesPlural: "dingos", type: "canine", dickSize: "large", ballType: "dingo"}]]
		<<else>>
			//Set as active canine//
		<</if>>

	<</if>>

<<if $farmyardStables > 1>>

	Hooved Animals:

	<<if $animalsBought.zebras == 0>>
		<<link "Purchase zebras" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(20000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.zebras = 1, $animalsBought.hooved += 1, $hooved.push("zebras")>><</link>>
	<<elseif $animalsBought.zebras == 1>>
		Zebras
		<<if $activeHooved.species != "zebra">>
			[[Set as active hooved|Farmyard Animals][$activeHooved = {species: "zebra", speciesCap: "Zebra", speciesPlural: "zebras", type: "hooved", dickSize: "huge", ballType: "zebra"}]]
		<<else>>
			//Set as active hooved//
		<</if>>
	<</if>>

<</if>>

<<if $animalsBought.cougars == 0>>
		<<link "Purchase cougars" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(30000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.cougars = 1, $animalsBought.felines += 1, $felines.push("cougars")>><</link>>

	<<elseif $animalsBought.cougars == 1>>
		/*The cougars are sleeping, their lean bodies scattered around under trees. (OLD)*/
		Cougars
		<<if $activeFeline.species != "cougar">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "cougar", speciesCap: "Cougar", speciesPlural: "cougars", type: "feline", dickSize: "large", ballType: "cougar"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.jaguars == 0>>
		<<link "Purchase jaguars" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(30000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.jaguars = 1, $animalsBought.felines += 1, $felines.push("jaguars")>><</link>>

	<<elseif $animalsBought.jaguars == 1>>
		/*You can see a few jaguars laying around in the trees in their enclosure. (OLD)*/
		Jaguars
		<<if $activeFeline.species != "jaguar">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "jaguar", speciesCap: "Jaguar", speciesPlural: "jaguars", type: "feline", dickSize: "large", ballType: "jaguar"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.lynx == 0>>
		<<link "Purchase lynxs" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(30000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.lynx = 1, $animalsBought.felines += 1, $felines.push("lynx")>><</link>>

	<<elseif $animalsBought.lynx == 1>>
		/*The lynxes are playfully running around their enclosure. (OLD)*/
		Lynx
		<<if $activeFeline.species != "lynx">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "lynx", speciesCap: "Lynx", speciesPlural: "lynx", type: "feline", dickSize: "large", ballType: "lynx"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.leopards == 0>>
		<<link "Purchase leopards" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(30000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.leopards = 1, $animalsBought.felines += 1, $felines.push("leopards")>><</link>>

	<<elseif $animalsBought.leopards == 1>>
		/*The leopards are lazing about in the trees in their enclosure. (OLD)*/
		Leopards
		<<if $activeFeline.species != "leopard">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "leopard", speciesCap: "Leopard", speciesPlural: "leopards", type: "feline", dickSize: "large", ballType: "leopard"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>
	<<if $animalsBought.tigers == 0>>
		<<link "Purchase tigers" "Farmyard Animals">><<set cashX(forceNeg(Math.trunc(30000*$upgradeMultiplierArcology)), "farmyard"), $animalsBought.tigers = 1, $animalsBought.felines += 1, $felines.push("tigers")>><</link>>

	<<elseif $animalsBought.tigers == 1>>
		/*Some of the tigers are swimming, and the ones that aren't are lazing about. (OLD)*/
		Tigers
		<<if $activeFeline.species != "tiger">>
			[[Set as active feline|Farmyard Animals][$activeFeline = {species: "tiger", speciesCap: "Tiger", speciesPlural: "tigers", type: "feline", dickSize: "large", ballType: "tiger"}]]
		<<else>>
			//Set as active feline//
		<</if>>

	<</if>>


code:
App.Facilities.Farmyard.farmyardReport = function farmyardReport() {
	let frag = new DocumentFragment();

	const slaves = App.Utils.sortedEmployees(App.Entity.facilities.farmyard);
	const devBonus = (V.farmyardDecoration !== "standard") ? 1 : 0;
	const Farmer = S.Farmer;

	let profits = 0;
	let foodWeek = 0;
	let farmerBonus = 0;

	// MARK: Farmer

	function farmerChanges() {
		farmerHealth(Farmer);
		farmerDevotion(Farmer);
		farmerTrust(Farmer);
		farmerLivingRules(Farmer);
		farmerRestRules(Farmer);
		farmerCashBonus(Farmer);
	}

	function farmerHealth(slave) {
		if (slave.health.condition < -80) {
			improveCondition(Farmer, 20);
		} else if (slave.health.condition < -40) {
			improveCondition(Farmer, 15);
		} else if (slave.health.condition < 0) {
			improveCondition(Farmer, 10);
		} else if (slave.health.condition < 90) {
			improveCondition(Farmer, 7);
		}
	}

	function farmerDevotion(slave) {
		slave.devotion += devBonus;

		if (slave.devotion < 45) {
			slave.devotion += 5;
		}
	}

	function farmerTrust(slave) {
		if (slave.trust < 45) {
			slave.trust += 5;
		}
	}

	const farmerLivingRules = slave => slave.rules.living = 'luxurious';
	const farmerRestRules = slave => slave.rules.rest = 'restrictive';

	function farmerCashBonus(slave) {
		let FarmerCashBonus = Math.min(0.2, slave.skill.farmer * 0.002);

		FarmerCashBonus += slave.intelligence + slave.intelligenceImplant > 15 ? 0.05 : 0;
		FarmerCashBonus += slave.dick > 2 && canPenetrate(slave) ? 0.05 : 0;
		FarmerCashBonus += !canSmell(slave) ? 0.05 : 0;

		if (slave.actualAge > 35) {
			FarmerCashBonus += 0.05;
		} else if (!V.AgePenalty) {
			FarmerCashBonus += 0.05;
		}

		if (setup.farmerCareers.includes(slave.career)) {
			FarmerCashBonus += 0.05;
			if (slave.skill.farmer >= V.masteredXP) {
				FarmerCashBonus += 0.05;
			}
		} else if (slave.skill.farmer >= V.masteredXP) {
			FarmerCashBonus += 0.05;
		}

		// TODO: keep this?
		if (Farmer.relationshipTarget === slave.ID) {
			FarmerCashBonus -= 0.05;
		} else if (areRelated(Farmer, slave)) {
			FarmerCashBonus += 0.05;
		}

		FarmerCashBonus *= restEffects(Farmer);

		return FarmerCashBonus;
	}

	function farmerText() {
		let r = [];

		r.push(farmerIntro(Farmer));
		r.push(farmerRelationshipPC(Farmer));
		r.push(farmerFetishEffects(Farmer, farmerFetish(Farmer)));
		r.push(farmerSkill(Farmer));
		r.push(farmerExperience(Farmer));
		r.push(farmerTiredness(Farmer));
		r.push(farmerIntelligence(Farmer));
		r.push(farmerSmell(Farmer));
		r.push(farmerRelationshipSlaves(Farmer));
		r.push(farmerContracts(Farmer));

		return r.join(' ');
	}

	function farmerFetish(slave) {
		if (slave.fetish !== 'dom') {
			if (fetishChangeChance(slave) > jsRandom(0, 100)) {
				slave.fetishKnown = 1;
				slave.fetish = 'dom';
				return 1;
			}
		} else if (!slave.fetishKnown) {
			slave.fetishKnown = 1;
			return 1;
		} else {
			slave.fetishStrength += 4;
			return 2;
		}
	}

	function farmerFetishEffects(slave, fetish = 0) {
		const {he, his, himself, He} = getPronouns(slave);

		if (fetish === 1) {
			return `${He} isn't above sampling the merchandise ${himself}; before long it's obvious to ${his} workers that ${he} <span class="lightcoral">really likes fucking them.</span> `;
		} else if (fetish === 2) {
			return `${He}'s careful that all of the farmhands under ${his} supervision are all ready to work every morning, and ${he} <span class="lightsalmon">becomes more dominant.</span> `;
		}
	}

	function farmerSkill(slave) {
		const {he, his, His} = getPronouns(slave);

		let r = [];

		if (slave.skill.farmer <= 10) {
			r.push(`Though ${slave.slaveName} does ${his} best to manage the farmyard, with ${his} lack of skill ${he} can do little.`);
		} else if (slave.skill.farmer <= 30) {
			r.push(`${slave.slaveName}'s basic skills marginally <span class="yellowgreen">improve</span> business at ${V.farmyardName}.`);
		} else if (slave.skill.farmer <= 60) {
			r.push(`${slave.slaveName}'s skills <span class="yellowgreen">improve</span> business at ${V.farmyardName}.`);
		} else if (slave.skill.farmer < 100) {
			r.push(`${slave.slaveName}'s skills greatly <span class="yellowgreen">improve</span> business at ${V.farmyardName}.`);
		} else {
			r.push(`${slave.slaveName}'s mastery immensely <span class="yellowgreen">improves</span> business at ${V.farmyardName}.`);
		}

		if (slave.actualAge > 35) {
			r.push(`${His} age and experience also contribute.`);
		}

		return r.join(' ');
	}

	function farmerExperience(slave) {
		const {he, his, him, He} = getPronouns(slave);

		if (setup.farmerCareers.includes(slave.career)) {
			return `${He} has experience from ${his} life before ${he} was a slave that helps ${him} in the difficult life of managing animals and property.`;
		} else if (slave.skill.farmer >= V.masteredXP) {
			return `${He} has experience from working for you that helps ${him} in the difficult life of managing animals and property.`;
		} else {
			slave.skill.farmer += jsRandom(1, Math.ceil((slave.intelligence + slave.intelligenceImplant) / 32));
		}
	}

	function farmerTiredness(slave) {
		const {he, his, him, He} = getPronouns(slave);

		if (slaveResting(slave)) {
			return `To avoid exhaustion, ${he} has to take breaks to maintain ${his} strength, limiting how much ${he} can work.`;
		}
	}

	function farmerRelationshipSlaves(Farmer) {
		const {he, his, He} = getPronouns(Farmer);

		let r = [];

		for (const slave of slaves) {
			if (Farmer.rivalryTarget === slave.ID) {
				r.push(`${He} leverages the fact that ${he} is ${slave.slaveName}'s superior to make ${his} ${rivalryTerm(Farmer)}'s life a living hell.`);
				slave.devotion -= 2; slave.trust -= 2;

				if (canDoVaginal(slave)) {
					seX(slave, 'vaginal', 'public', 'penetrative', 10);
				}

				if (canDoAnal(slave)) {
					seX(slave, 'anal', 'public', 'penetrative', 10);
				}

				seX(slave, 'oral', 'public', 'penetrative', 10);
				if (jsRandom(1, 100) > 65) {
					Farmer.rivalry++; slave.rivalry++;
				}
			} else if (Farmer.relationshipTarget === slave.ID) {
				r.push(`${He} dotes over ${his} ${relationshipTerm(Farmer)}, ${slave.slaveName}, making sure ${he} isn't worked too hard, but unfortunately manages to get in the way of ${his} work.`);
				slave.devotion++;
			} else if (areRelated(Farmer, slave)) {
				r.push(`${He} pays special attention to ${his} ${relativeTerm(Farmer, slave)}, ${slave.slaveName}, making sure ${he} is treated well and showing off ${his} skills.`);
				slave.trust++;
			}
		}

		return r;
	}

	function farmerContracts(slave) {
		const {he, his, himself} = getPronouns(slave);

		let r = [];
		let seed = V.farmyardShowgirls ? App.Facilities.Farmyard.farmShowsIncome(slave) : jsRandom(1, 10) * (jsRandom(150, 170) + (farmerBonus * 10));

		if (V.farmyardShows && !V.farmyardShowgirls) {
			r.push(`
Since ${he} doesn't have enough showgirls to entertain your arcology's citizens, ${he} puts on shows with your animals on ${his} own, earning ${cashFormat(seed)}.
`);
		} else if (!V.farmyardFarmers) {
			r.push(`<p class="indent">Since ${V.farmyardName} doesn't have anyone tending to the crops, ${he} looks after them ${himself}, earning <span class="yellowgreen">${cashFormat(seed)}.</span></p>`);
		}

		return r;
	}

	function farmerRelationshipPC(slave) {
		const {he, his, wife} = getPronouns(slave);

		if (slave.relationship === -3 && slave.devotion > 50) {
			return `As your loving ${wife}, ${he} does ${his} best to ensure ${V.farmyardName} runs smoothly.`;
		}
	}

	function farmerIntelligence(slave) {
		const {He} = getPronouns(slave);

		if (slave.intelligence + slave.intelligenceImplant > 15) {
			return `${He} is a clever manager.`;
		}
	}

	function farmerSmell(slave) {
		const {him, His} = getPronouns(slave);

		if (!canSmell(slave)) {
			return `${His} lack of a sense of smell protects ${him} from that omnipresent barnyard stench.`;
		}
	}

	const farmerIntro = slave => `<span class="indent">${SlaveFullName(slave)} is serving as the Farmer</span>.`;

	if (Farmer) {
		const farmerEffects = App.UI.DOM.appendNewElement("p", frag, '', "indent");

		V.i = V.slaveIndices[Farmer.ID];
		App.Utils.setLocalPronouns(Farmer);	// needed for "include"s

		if (V.showEWD) {
			const farmerEntry = App.UI.DOM.appendNewElement("div", frag, '', "slave-report");

			if (V.seeImages && V.seeReportImages) {
				App.UI.DOM.appendNewElement("div", farmerEntry, App.Art.SlaveArtElement(Farmer, 0, 0), ["imageRef", "tinyImg"]);
			}

			farmerEntry.append(App.EndWeek.favoriteIcon(Farmer), " ");
			$(farmerEntry).append(`<span class="slave-name">${SlaveFullName(Farmer)}</span> is serving as the Farmer.`);
			$(farmerEntry).append(App.SlaveAssignment.standardSlaveReport(Farmer, false));
		} else {
			App.SlaveAssignment.standardSlaveReport(Farmer, true);
		}

		farmerChanges();
		$(farmerEffects).append(farmerText());
	}

	// MARK: Farmhands

	function farmhandCount(count) {
		return `<strong>There ${count > 1 ? `are ${count} farmhands` : `is one farmhand`} working out of ${V.farmyardName}.</strong>`;
	}

	function farmhandLivingRules(slave) {
		switch (V.farmyardDecoration) {
			case 'Degradation':
			case 'standard':
				slave.rules.living = 'spare';
				break;
			case 'Roman Revivalist':
				slave.rules.living = 'luxurious';
				break;
			default:
				slave.rules.living = 'normal';
				break;
		}
	}

	function farmhandHealth(slave) {
		if (slave.health.condition < -80) {
			improveCondition(slave, 20);
		} else if (slave.health.condition < -40) {
			improveCondition(slave, 15);
		} else if (slave.health.condition < 0) {
			improveCondition(slave, 10);
		} else if (slave.health.condition < 90) {
			improveCondition(slave, 7);
		}
	}

	function farmhandDevotion(slave) {
		if (slave.devotion <= 20 && slave.trust >= -20) {
			slave.devotion -= 5; slave.trust -= 5;
		} else if (slave.devotion < 45) {
			slave.devotion += 4;
		} else if (slave.devotion > 50) {
			slave.devotion -= 4;
		}
	}

	function farmhandProfit(slave) {
		let incomeStats = getSlaveStatisticData(slave, slave.assignment === Job.FARMYARD ? V.facility.farmyard : undefined);
		return incomeStats.income;
	}

	function farmhandFood(slave) {
		let incomeStats = getSlaveStatisticData(slave, slave.assignment === Job.FARMYARD ? V.facility.farmyard : undefined);
		let foodWeek = incomeStats.food || 0;

		if (V.farmMenials > 0) {
			foodWeek += (V.farmMenials * 350);
		}

		return foodWeek;
	}

	function farmhandTrust(slave) {
		if (slave.trust < 30) {
			slave.trust += 5;
		}
	}

	function farmhandEnergy(slave) {
		if (slave.energy > 40 && slave.energy < 95) {
			slave.energy++;
		}
	}

	if (slaves) {
		const intro = App.UI.DOM.appendNewElement("p", frag, '', "indent");

		$(intro).append(farmhandCount(slaves.length));

		for (const slave of slaves) {
			V.i = V.slaveIndices[slave.ID];	// FIXME: V.i is deprecated

			slave.devotion += devBonus;

			App.Utils.setLocalPronouns(slave);	// needed for "include"s

			if (V.showEWD) {
				const slaveEntry = App.UI.DOM.appendNewElement("div", frag, '', "slave-report");

				if (V.seeImages && V.seeReportImages) {
					App.UI.DOM.appendNewElement("div", slaveEntry, App.Art.SlaveArtElement(slave, 0, 0), ["imageRef", "tinyImg"]);
				}

				slaveEntry.append(App.EndWeek.favoriteIcon(slave), " ");
				$(slaveEntry).append(`<span class="slave-name">${SlaveFullName(slave)}</span> `);

				if (slave.choosesOwnAssignment === 2) {
					$(slaveEntry).append(App.SlaveAssignment.choosesOwnJob(slave));
				} else {
					$(slaveEntry).append(`is working out of ${V.farmyardName}.`);
				}

				farmhandLivingRules(slave);
				farmhandHealth(slave);
				farmhandDevotion(slave);
				farmhandTrust(slave);
				farmhandEnergy(slave);
				farmhandFood(slave);

				profits += farmhandProfit(slave);

				const farmhandContent = App.UI.DOM.appendNewElement("div", slaveEntry, '', "indent");

				$(farmhandContent).append(App.SlaveAssignment.workTheFarm(slave));
				$(slaveEntry).append(App.SlaveAssignment.standardSlaveReport(slave, false));
			} else {	// silently discard return values
				App.SlaveAssignment.workTheFarm(slave);
				App.SlaveAssignment.standardSlaveReport(slave, true);
			}
		}
	}

	// MARK: Menials

	if (V.farmMenials) {
		let farmMenialProductivity = 9;

		if (V.farmyardUpgrades.pump) {
			farmMenialProductivity += 1;
		}

		if (V.farmyardUpgrades.fertilizer) {
			farmMenialProductivity += 2;
		}

		if (V.farmyardUpgrades.seeds) {
			farmMenialProductivity += 3;
		}

		if (V.farmyardUpgrades.machinery) {
			farmMenialProductivity += 3;
		}

		foodWeek += (V.farmMenials * farmMenialProductivity);
	}

	// MARK: Farmyard

	function farmyardStatsRecords() {
		const f = V.facility.farmyard;

		if (typeof f === "undefined") {
			return;
		}

		f.farmhandIncome = 0;
		f.customers = 0;
		f.farmhandCosts = 0;
		f.rep = 0;
		f.maintenance = V.farmyard * V.facilityCost;
		f.totalIncome = f.farmhandIncome + f.adsIncome;
		f.totalExpenses = f.farmhandCosts + f.maintenance;
		f.profit = f.totalIncome - f.totalExpenses;

		for (let i of f.income.values()) {
			f.farmhandIncome += i.income + i.adsIncome;
			f.customers += i.customers;
			f.farmhandCosts += i.cost;
			f.rep += i.rep;
		}
	}

	function farmyardDecoration() {
		let r = [];

		// TODO: add checks for the different FSs
		if (V.farmyardDecoration !== 'standard') {
			const decorationEffects = App.UI.DOM.appendNewElement("p", frag, '', "indent");
			const farmyardNameCaps = capFirstChar(V.farmyardName);

			$(decorationEffects).append(document.createElement("br"));

			r.push(`${farmyardNameCaps}'s customer's enjoyed`);

			if (V.seeBestiality && V.policies.bestialityOpenness && (V.canines || V.hooved || V.felines)) {
				r.push(`<span class="green">watching farmhands fuck animals in ${V.farmyardDecoration} surroundings.</span>`);
			} else if (V.farmyardShows) {
				r.push(`<span class="green">watching farmhands put on shows in ${V.farmyardDecoration} surroundings.</span>`);
			} else {
				r.push(`<span class="green">partaking of ${V.farmyardName}'s fine produce in its ${V.farmyardDecoration} décor.</span>`);
			}

			$(decorationEffects).append(r.join(' '));
		}

		return r;
	}

	function farmyardProfit(profit, food) {
		const profitContent = App.UI.DOM.appendNewElement("p", frag, '', "indent");
		const farmyardNameCaps = capFirstChar(V.farmyardName);

		let r = [];

		$(profitContent).append(document.createElement("br"));

		if (profit || food) {
			r.push(farmyardNameCaps);

			if (profit) {
				r.push(`makes you <span class="yellowgreen">${cashFormat(Math.trunc(profit))}</span>`);
			}

			if (V.foodMarket) {
				if (profit && food) {
					r.push(`and`);
				}
				if (food) {
					r.push(`produced <span class="chocolate"> ${massFormat(food)}</span> of food`);
				}
			}
			r.push(`this week.`);
		}

		return $(profitContent).append(r.join(' '));
	}

	// FIXME: no idea what I'm doing here
	const statsSpan = document.createElement("span");

	farmyardStatsRecords();
	farmyardProfit(profits, foodWeek);
	farmyardDecoration();

	V.food += foodWeek;

	frag.append(App.Facilities.Farmyard.Stats(false));
	statsSpan.append(App.Facilities.Farmyard.Stats(true));

	return frag;
};


code:
/**
 * @param {App.Entity.SlaveState} slave
 * @returns {number}
 */
App.Facilities.Farmyard.farmShowsIncome = function(slave) {
	const arcology = V.arcologies[0];
	const heavyMods = SlaveStatsChecker.modScore(slave).total > 20;

	const sexualQuirks = ["perverted", "unflinching"];
	const behavioralQuirks = ["sinful"];
	const fetishes = ["humiliation", "masochist"];

	let cash = 7500;

	if (!slave) {
		return null;
	} else {
		if (S.Farmer) {
			cash *= 1.1;
			if (S.Farmer.skill.farmer >= V.masteredXP) {
				cash *= 1.1;
			}
		}

		// MARK: FS Effects

		if (arcology.FSSupremacist !== "unset") {
			if (isSuperiorRace(slave)) {
				if (V.seeBestiality) {
					cash *= 0.8;
					repX(-10, "shows");
				} else {
					cash *= 1.2;
				}
			} else {
				cash *= 0.9;
			}
		}

		if (arcology.FSSubjugationist !== "unset") {
			if (isInferiorRace(slave)) {
				if (V.seeBestiality) {
					cash *= 1.2;
					repX(10, "shows");
				} else {
					cash *= 0.8;
				}
			} else {
				cash *= 0.9;
			}
		}

		if (arcology.FSRepopulationFocus !== "unset") {
			if (isPreg(slave)) {
				if (slave.eggType === "human") {
					cash *= 1.2;
					repX(15, "shows");
				} else {
					cash *= 0.8;
					repX(-15, "shows");
				}
			}
		}

		if (arcology.FSRestart !== "unset") {
			if (isPreg(slave)) {
				if (isEliteBreeder(slave)) {
					if (slave.eggType === "human") {
						cash *= 0.7;
						repX(-20, "shows");
					} else {
						cash *= 0.6;
						repX(-25, "shows");
					}
				} else {
					if (slave.eggType === "human") {
						cash *= 0.8;
						repX(-15, "shows");
					} else {
						cash += 0.9;
						repX(-10, "shows");
					}
				}
			} else {
				if (V.seeBestiality && isEliteBreeder(slave)) {
					cash *= 0.7;
					repX(-10, "shows");
				}
			}
		}

		if (arcology.FSGenderRadicalist !== "unset") {
			if (slave.genes === "XX") {
				if (slave.dick > 0) {
					cash *= 1.2;
					repX(10, "shows");
				} else {
					cash *= 0.9;
					repX(-5, "shows");
				}
			}
		}

		if (arcology.FSGenderFundamentalist !== "unset") {
			if (isPreg(slave) || setup.fakeBellies.includes(slave.bellyAccessory)) {
				cash *= 1.1;
				repX(10, "shows");
			} else {
				cash *= 0.9;
				repX(-5, "shows");
			}

			// FIXME: keep this? not sure it makes sense
			if (slave.genes === "XX") {
				if (slave.dick > 0) {
					cash *= 0.8;
				} else {
					cash *= 1.1;
				}
			}
		}

		if (arcology.FSPaternalist !== "unset") {
			if (V.seeBestiality) {
				if (V.farmyardBreeding) {
					if (V.farmyardRestraints) {
						cash *= 0.5;
					} else {
						cash *= 0.7;
					}
				} else {
					if (V.farmyardRestraints) {
						cash *= 0.8;
					} else {
						cash *= 0.9;
					}
				}
			} else {
				// TODO: something here?
			}
		}

		if (arcology.FSDegradationist !== "unset") {
			if (V.seeBestiality) {
				if (V.farmyardBreeding) {
					if (V.farmyardRestraints) {
						cash *= 1.5;
					} else {
						cash *= 1.3;
					}
				} else {
					if (V.farmyardRestraints) {
						cash *= 1.2;
					} else {
						cash *= 1.1;
					}
				}
			} else {
				// TODO: something here?
			}
		}

		if (arcology.FSBodyPurist !== "unset") {
			if (SlaveStatsChecker.isModded(slave)) {
				if (heavyMods) {
					cash *= 0.7;
					repX(-15, "shows");
				} else {
					cash *= 0.8;
					repX(-10, "shows");
				}
			}
		}

		if (arcology.FSTransformationFetishist !== "unset") {
			if (SlaveStatsChecker.isModded(slave)) {
				if (heavyMods) {
					cash *= 1.3;
					repX(15, "shows");
				} else {
					cash *= 1.2;
					repX(10, "shows");
				}
			}
		}

		if (arcology.FSYouthPreferentialist !== "unset") {
			if (isYoung(slave)) {
				cash *= 1.2;
				repX(10, "shows");
			} else {
				cash *= 0.8;
				repX(-5, "shows");
			}
		}

		if (arcology.FSMaturityPreferentialist !== "unset") {
			if (!isYoung(slave)) {
				cash *= 1.2;
				repX(10, "shows");
			} else {
				cash *= 0.8;
				repX(-5, "shows");
			}
		}

		if (arcology.FSSlimnessEnthusiast !== "unset") {
			if (slimLawPass(slave)) {
				cash *= 1.1;
				repX(10, "shows");
			} else {
				cash *= 0.9;
				repX(-5, "shows");
			}
		}

		// FIXME: marked for possible rewrite
		if (arcology.FSAssetExpansionist !== "unset") {
			if (isStacked(slave)) {
				cash *= 1.1;
				repX(10, "shows");
			}
		}

		if (arcology.FSPastoralist !== "unset") {
			if (slave.boobs >= 1000) {
				cash *= 1.2;
				repX(10, "shows");
			}

			if (slave.lactation > 0) {
				cash *= 1.1;
				repX(5, "shows");
			}
		}

		// FIXME: marked for review
		if (arcology.FSPhysicalIdealist !== "unset") {
			if (genderLawPass(slave)) {
				cash *= 1.1;
				repX(10, "shows");
			} else {
				cash *= 0.9;
				repX(-5, "shows");
			}

			if (slave.muscles > 30) {								// slave is muscular or more
				cash *= 1.1;
			} else {
				cash *= 0.9;
			}
		}

		if (arcology.FSHedonisticDecadence !== "unset") {
			if (slave.weight > 10) {								// slave is curvy or more
				cash *= 1.1;
			} else {
				cash *= 0.9;
			}
		}

		if (arcology.FSChattelReligionist !== "unset") { 			// TODO: I don't know what to put for this one
			if (slave.devotion < 21) { 								// if slave is careful or less
				cash *= 0.9;
			}
		}

		if (arcology.FSPetiteAdmiration !== "unset") {
			if (heightPass(slave)) {
				cash *= 1.1;
				repX(10, "shows");
			} else {
				cash *= 0.9;
				repX(-5, "shows");
			}
		}

		if (arcology.FSStatuesqueGlorification !== "unset") {
			if (heightPass(slave)) {
				cash *= 1.1;
				repX(10, "shows");
			} else {
				cash *= 0.9;
				repX(-5, "shows");
			}
		}

		if (arcology.FSRomanRevivalist !== "unset") {
			// TODO:
		}

		if (arcology.FSAztecRevivalist !== "unset") {
			// TODO:
		}

		if (arcology.FSEgyptianRevivalist !== "unset") {
			// TODO:
		}

		if (arcology.FSEdoRevivalist !== "unset") {
			// TODO:
		}

		if (arcology.FSArabianRevivalist !== "unset") {
			// TODO:
		}

		if (arcology.FSChineseRevivalist !== "unset") {
			// TODO:
		}

		// Close FS Effects

		if (setup.entertainmentCareers.includes(slave.career)) {
			cash *= 1.1;
		}

		// FIXME: can slaves' careers overlap categories?
		if (setup.farmerCareers.includes(slave.career)) {
			cash *= 1.1;
		}

		if (slave.prestige === 1) { 								// slave is prestigious
			cash *= 1.1;
		} else if (slave.prestige === 2) { 							// slave is very prestigious
			cash *= 1.5;
		} else if (slave.prestige === 3) { 							// slave is extremely prestigious
			cash *= 1.9;
		}

		if (slave.porn.prestige === 1) { 							// slave is prestigious from porn
			cash *= 1.1;
		} else if (slave.porn.prestige === 2) { 					// slave is very prestigious from porn
			cash *= 1.4;
		} else if (slave.porn.prestige === 3) { 					// slave is extremely prestigious from porn
			cash *= 1.7;
		}

		// FIXME: needed when using healthPenalty()?
		if (slave.health.condition > 50) {							// slave is very healthy or more
			cash *= 1.2;
		} else if (slave.health.condition < -20) {
			cash *= 0.9;
		}

		// TODO: add checks for family and relationships

		if (slave.face > 40) {										// slave is beautiful or more
			cash *= 1.4;
		} else if (slave.face > 10) {								// slave is very pretty or more
			cash *= 1.1;
		} else if (slave.face < -10) {								// slave is less than unattractive
			cash *= 0.9;
		} else if (slave.face < -40) {								// slave is less than ugly
			cash *= 0.7;
		}

		setSlaveDevotion(cash);
		setSlaveTrust(cash);

		if (slave.weight > 30) { 									// slave is curvy or more
			if (arcology.FSHedonisticDecadence !== "unset") {
				cash *= 0.8;
			}
		} else if (slave.weight < -30) { 							// slave is very thin or less
			cash *= 0.8;											// TODO: put this on a scale
		}

		// FIXME: marked for rewrite
		if (slave.muscles > 30) { 									// slave is muscular or more
			cash *= 0.9;
		} else if (slave.muscles < -30) {							// slave is very weak or less
			cash *= 0.6;
		}

		if (!canSeePerfectly(slave)) {
			if (canSee(slave)) {
				cash *= 0.8;
			} else {
				cash *= 0.6;
			}
		}

		if (!canHear(slave)) {
			cash *= 0.8;
		}

		if (isPreg(slave)) {
			cash *= 0.8;											// TODO: not sure how to incorporate pregnancy
		}
		// TODO: incorporate skills
		cash *= healthPenalty(slave);

		if (slave.intelligence > 50) {								// slave is very smart or better
			cash *= 1.4;
		} else if (slave.intelligence < -50) {						// slave is very slow or less
			cash *= 0.6;
		}

		if (slave.energy > 95) {									// slave is a nymphomaniac
			cash *= 1.5;
		} else if (slave.energy > 80) {								// slave has powerful sex drive
			cash *= 1.3;
		} else if (slave.energy > 60) {								// slave has good sex drive
			cash *= 1.1;
		} else if (slave.energy > 40) {								// slave has average sex drive
			cash *= 0.9;
		} else if (slave.energy > 20) {								// slave has poor sex drive
			cash *= 0.8;
		} else {													// slave has no sex drive
			cash *= 0.6;
		}

		switch (slave.fetish) {
			case "submissive":
			case "humiliation":
				if (V.seeBestiality) {
					if (slave.fetishKnown) {
						cash *= 1.1;
					} else {
						slave.fetishKnown = jsRandom(1, 100) > 80 ? 1 : 0;
					}
				} else {
					if (slave.fetishKnown) {
						cash *= 0.9;
					} else {
						slave.fetishKnown = jsRandom(1, 100) > 80 ? 1 : 0;
					}
				}
				break;

			default:
				break;
		}

		switch (slave.behavioralFlaw) {
			case "devout":
			case "arrogant":
				cash *= 0.9;
				break;

			default:
				break;
		}

		switch (slave.behavioralQuirk) {
			case "sinful":
				cash *= 1.1;
				break;

			default:
				break;
		}

		switch (slave.sexualFlaw) {
			case "shamefast":
				cash *= 1.1;
				break;

			default:
				break;
		}

		switch (slave.sexualQuirk) {
			case "perverted":
				cash *= 1.1;
				break;

			default:
				break;
		}

		return cash;
	}

	function setSlaveDevotion(amount) {
		const slaveApproves = () =>
			sexualQuirks.includes(slave.sexualQuirk) ||
			behavioralQuirks.includes(slave.behavioralQuirk) ||
			fetishes.includes(slave.fetish);

		if (slave.devotion > 50) {
			amount *= 1.5;

			if (V.seeBestiality) {
				if (slaveApproves) {
					slave.devotion += 2;
				} else {
					slave.devotion--;
				}
			}

			if (V.farmyardBreeding) {
				if (slaveApproves) {
					slave.devotion += 2;
				} else {
					slave.devotion--;
				}
			}

			if (V.farmyardRestraints) {
				if (slaveApproves) {
					slave.devotion += 3;
				} else {
					slave.devotion -= 2;
				}
			}
		} else if (slave.devotion < -50) {
			amount *= 0.5;

			if (V.seeBestiality) {
				if (slaveApproves) {
					slave.devotion++;
				} else {
					slave.devotion -= 2;
				}
			}

			if (V.farmyardBreeding) {
				if (slaveApproves) {
					slave.devotion++;
				} else {
					slave.devotion -= 2;
				}
			}

			if (V.farmyardRestraints) {
				if (slaveApproves) {
					slave.devotion += 2;
				} else {
					slave.devotion -= 3;
				}
			}
		}

		return amount;
	}

	function setSlaveTrust(amount) {
		const slaveApproves = () =>
			sexualQuirks.includes(slave.sexualQuirk) ||
			behavioralQuirks.includes(slave.behavioralQuirk) ||
			fetishes.includes(slave.fetish);

		if (slave.trust > 50) {
			amount *= 1.2;

			if (V.seeBestiality) {
				if (slaveApproves) {
					slave.trust += 2;
				} else {
					slave.trust--;
				}
			}

			if (V.farmyardBreeding) {
				if (slaveApproves) {
					slave.trust += 2;
				} else {
					slave.trust--;
				}
			}

			if (V.farmyardRestraints) {
				if (slaveApproves) {
					slave.trust += 3;
				} else {
					slave.trust -= 2;
				}
			}
		} else if (slave.trust < -50) {
			amount *= slave.devotion > 50 ? 1.2 : 0.9;

			if (V.seeBestiality) {
				if (slaveApproves) {
					slave.trust++;
				} else {
					slave.trust -= 2;
				}
			}

			if (V.farmyardBreeding) {
				if (slaveApproves) {
					slave.trust++;
				} else {
					slave.trust -= 2;
				}
			}

			if (V.farmyardRestraints) {
				if (slaveApproves) {
					slave.trust += 2;
				} else {
					slave.trust -= 3;
				}
			}
		}

		return amount;
	}
};