code:
App.Facilities.MilkmaidSelect = function() {
	const f = document.createDocumentFragment();

	if (S.Milkmaid) {
		f.append(`${SlaveFullName(S.Milkmaid)} is working as your Milkmaid, looking after your livestock, helping them give milk${V.seeDicks > 0 ? ' and semen' : ''}. `);
		f.append(App.UI.DOM.link("Remove Milkmaid", () => {
			removeJob(S.Milkmaid, Job.MILKMAID);
		},
		[], "Dairy"
		));
	} else {
		f.append(`No Milkmaid assigned, appoint one from your devoted slaves.`);
	}

	f.append(App.UI.SlaveList.facilityManagerSelection(App.Entity.facilities.dairy, "Dairy"));
	return f;
};


code:
App.Facilities.Dairy.dairy = class Dairy extends App.Facilities.Facility {
	constructor() {
		const dairy = App.Entity.facilities.dairy;
		const decommissionHandler = () => {
			V.dairy = 0;
			V.dairyDecoration = "standard";
			V.dairyFeedersUpgrade = 0;
			V.dairyPregUpgrade = 0;
			V.dairyStimulatorsUpgrade = 0;
			V.dairyFeedersSetting = 0;
			V.dairyPregSetting = 0;
			V.dairyStimulatorsSetting = 0;
			V.dairyHyperPregRemodel = 0;
			V.dairyRestraintsUpgrade = 0;
			V.dairyUpgradeMenials = 0;
			V.cumPipeline = 0;
			V.milkPipeline = 0;

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

		super(
			dairy,
			decommissionHandler,
		);

		V.nextButton = "Back to Main";
		V.nextLink = "Main";
		V.encyclopedia = "Dairy";

		if (V.dairyRestraintsSetting !== 2 || V.dairyRestraintsUpgrade !== 1) {
			if (V.dairyStimulatorsSetting > 1) {
				V.dairyStimulatorsSetting = 1;
			}
			if (V.dairyPregSetting > 1) {
				V.dairyPregSetting = 1;
			}
			if (V.dairyFeedersSetting > 1) {
				V.dairyFeedersSetting = 1;
			}
		}
	}

	/** @returns {string} */
	get intro() {
		const text = [];

		if (V.dairyRestraintsSetting > 1) {
			text.push(`${this.facility.nameCaps} is an industrial facility, but there's a viewing gallery for visitors.`);
		} else {
			text.push(this.facility.nameCaps);
		}
		text.push(this.decorations);

		if (this.facility.hostedSlaves > 2) {
			text.push(`${this.facility.nameCaps} is working steadily.`);

			if (V.dairyRestraintsUpgrade === 1 && V.dairyRestraintsSetting > 1) {
				text.push(`Each cow is strapped into their own milking machine. The machines are set up in rows, alternating forward and backward so that the cows are interleaved as closely as possible without touching.`);

				if (V.dairyFeedersUpgrade === 1 && V.dairyFeedersSetting > 0) {
					if (V.dairyFeedersSetting === 2) {
						text.push(`A phallic feeding tube completely fills each cow's mouth and throat, making it eerily quiet in there. Occasionally one of the cows convulses when a particularly long rush of food and drugs flows down their gullet.`);
					} else {
						text.push(`When feeding is required, a phallus extends into cows' mouths.`);
					}
				}
				if (V.dairyStimulatorsUpgrade === 1 && V.dairyStimulatorsSetting > 0) {
					if (V.dairyStimulatorsSetting === 2) {
						text.push(`Every cow is being sodomized by a massive phallus. Most are pumping away gently, the strokes taking a long time to push the half-${V.showInches === 2 ? `yard` : `meter`} of shaft into each slave's rectum and pull it out again. When a slave's balls are ready to give cum, however, the pace quickens, and the agonized slave wriggles in involuntary desperation to escape until they finally stiffen, squirt, and slump in exhaustion.`);
					} else {
						text.push(`Each cow's anus is periodically fucked by a machine phallus that ejaculates hydration directly up their butt. When a slave's balls are ready to give cum, they are mercilessly sodomized until prostate stimulation forces an orgasm.`);
					}
				}
				if (V.dairyPregUpgrade === 1 && V.dairyPregSetting > 0) {
					if (V.dairyPregSetting === 3) {
						text.push(`Fertile cows' vaginas are constantly penetrated by huge dildos that ejaculate extra strong fertility drugs into their progressively distending wombs. The drugs induce intense arousal and excessive female lubrication, so the constant dildo rape fills ${this.facility.name} with occasional gushing noises and nonstop moaning.`);
					} else if (V.dairyPregSetting === 2) {
						text.push(`Fertile cows' vaginas are constantly penetrated by huge dildos that ejaculate fertility drugs. The drugs produce excessive female lubrication, so the constant dildo rape fills ${this.facility.name} with occasional gushing noises.`);
					} else {
						text.push(`The fertile cows are visibly pregnant.`);
					}
				}
			} else {
				text.push(`The row of milking machines is available for cows to use.`);

				if (V.dairyRestraintsSetting > 0) {
					text.push(`When they do, the machines gently restrain them until they are completely done.`);
				}
				if (V.dairyFeedersUpgrade === 1 && V.dairyFeedersSetting > 0) {
					text.push(`The machines mount convenient phallic feeders for slaves to suck for tasty food while they're milked.`);
				}
				if (V.dairyPregUpgrade === 1 && V.dairyPregSetting > 0) {
					text.push(`The fertile cows are visibly pregnant.`);
				}
				if (V.dairyStimulatorsUpgrade === 1 && V.dairyStimulatorsSetting > 0) {
					text.push(`The machines gently sodomize cows who need the extra nutrition and treatment the dildos can ejaculate into them${V.seeDicks > 0 ? `, and fuck them more vigorously when they need help ejaculating.` : ``}`);
				}
			}
		} else if (V.bioreactorsXY + V.bioreactorsXX + V.bioreactorsHerm + V.bioreactorsBarren > 0) {
			text.push(`${this.facility.nameCaps} is quiet and calm. The only sounds are faint sucking and gushing noises.`);
		} else if (this.facility.hostedSlaves > 0) {
			text.push(`${this.facility.nameCaps} is sparsely populated.`);
		} else if (S.Milkmaid) {
			text.push(`${S.Milkmaid.slaveName} is alone in ${this.facility.name}, and has nothing to do but clean and maintain the equipment.`);
		} else {
			text.push(`${this.facility.nameCaps} is empty and quiet.`);
		}

		return text.join(' ');
	}

	/** @returns {string} */
	get decorations() {
		/** @type {FC.Facilities.Decoration} */
		let FS = null;

		if (V.dairyRestraintsSetting > 1) {
			FS = {
				"Roman Revivalist": `The screens there review each slave's liquid contributions to the state in minute detail.`,
				"Neo-Imperialist": `The sleek screens display a variety of statistics on each slave's vitals and production.`,
				"Aztec Revivalist": `The strange sight of the milking machines, designed to look like fertility statues gives the space an imposing feeling.`,
				"Egyptian Revivalist": `The screens there list a tally of each slave's contributions to the harvest this season. They also identify related slaves who occupy multi-slave milking machines so that they may feed each other directly.`,
				"Edo Revivalist": `It looks out on a strangely contradictory sight: a beautiful and terrible combination of modern slavery and technology, placed amongst tatami mats and rice paper partitions.`,
				"Arabian Revivalist": `It looks out on a strangely contradictory sight: a beautiful and terrible combination of modern slavery and technology, placed inside brightly tiled walls.`,
				"Chinese Revivalist": `The milking machines are fascinating: they're encased in decorative carvings, making it look like the slaves are in the embrace of traditional Chinese depictions of lions, bears, and dragons.`,
				"Chattel Religionist": `It presents the inmates as lessons, here to expiate their sins in a purgatory created by technology.`,
				"Degradationist": `The screens there feature, among a sea of facts and figures about each slave, their most recent brain scan.`,
				"Repopulationist": `The gallery is placed for a good view of each slave's swelling breasts and growing pregnancy. A screen is prominently displayed before each slave, detailing the number of babies she produced and the current number occupying their womb.`,
				"Eugenics": `The screens there tell very little about the slaves within. That information is privy only to Society's Elite.`,
				"Asset Expansionist": `It's designed for VIP visits, since this place is arguably the present apogee of expansionism. Nowhere else can breasts become so large. This is a place for pride.`,
				"Transformation Fetishist": `It's designed for VIP visits, since this place is arguably the present apogee of transformationism. Nowhere else can slaves be so radically changed, from humans into something less — and something more.`,
				"Gender Radicalist": `The gallery is placed for a good view of each slave's front, from their head to what's between their spread legs.`,
				"Gender Fundamentalist": `The gallery is placed for a good view of each slave's breasts, belly, and cunt. Visitors can critically compare each feminine advantage.`,
				"Physical Idealist": `The gallery is placed for a good view of each slave's body. Though muscles are at a lower premium here, there is intense interest in such radical changes to human biology.`,
				"Supremacist": `The screens there give information about each cow, but the data they present is also predictive. They imply a vision for a world in which more subhumans serve in this way. Many more.`,
				"Subjugationist": `The screens there give information about each cow, but the data they present is also predictive. They imply a vision for a world in which more milking machines have ${V.arcologies[0].FSSubjugationistRace} components. Many more.`,
				"Paternalist": `The screens there include feeds that show what media is being pumped into the slaves through their machines. It's designed to provide as much mental stimulation as possible.`,
				"Pastoralist": `The screens there let the production figures speak for themselves. There may be more personable cows out there, but they don't produce milk like these do.`,
				"Maturity Preferentialist": `The screens there give each slave's productivity and forecast it into the future. The facility is unmatched at extracting value from mature bodies.`,
				"Youth Preferentialist": `The screens there give each slave's productivity and forecast it into the future. The best bodies here have many, many years of productivity ahead of them.`,
				"Body Purist": `The screens there offer reams of data on each slave's product purity. Drugs are necessary here, and each body's balance results in a different grade of product.`,
				"Slimness Enthusiast": `The screens there alternate live views of the fashionably slim cows in their stalls with brief infomercials on the specialized techniques and equipment ${this.facility.name} uses to extract milk from such modest udders.`,
				"Hedonistic": `The gallery is placed for a good view of each slave's fattened body and the undulations running through them from the force of the milkers${V.dairyPregSetting || V.dairyFeedersSetting || V.dairyStimulatorsSetting ? ` and other assorted tubes and dildos` : ``}.`,
				"Intellectual Dependency": `The screens there feature an active scan showcasing each slave's diminishing brain activity.`,
				"Slave Professionalism": `It serves as a dire warning to what happens to unskilled, moronic slaves.`,
				"Petite Admiration": `The gallery is placed for a good view of each slave's petite body. Those that don't fit in a standard milking unit are kept well out of sight.`,
				"Statuesque Glorification": `The gallery is placed for a good view of each slave's body. Fascinated visitors may peruse each slave's productivity statistics contrasted against their height on a corresponding touchscreen.`,
				"standard": `Fascinated visitors may peruse each slave's productivity statistics on a corresponding touchscreen.`,
			};
		} else {
			FS = {
				"Roman Revivalist": `is functional and clean, using traditional methods wherever possible. At one end of the long row of stalls there is an alcove with a shrine to the Roman goddess of bountiful harvests.`,
				"Neo-Imperialist": `is cold and industrial, filled with the latest in industrial harvesting technology. The slaves do their duty underneath the hanging banners of your house, reminding them who owns their very bodies and all they produce.`,
				"Aztec Revivalist": `is sterile and organized, using traditional methods wherever possible. At one end of the long row of stalls there is an alcove with a shrine to the Aztec god of the Earth.`,
				"Egyptian Revivalist": `is functional and clean, using traditional methods wherever possible. At one end of the long row of stalls there is an alcove with a shrine to the Egyptian god of bountiful harvests.`,
				"Edo Revivalist": `is clean and traditional. The stalls are constructed of bamboo and carefully shaped wood, and muscle power is used wherever possible. Cows exercise and help out by walking on a wooden wheel that raises fresh water to ${this.facility.name}.`,
				"Arabian Revivalist": `is clean and traditional. Its dusky stone walls keep it so warm that the cows go nude, basking in the hot sun between milkings.`,
				"Chinese Revivalist": `is clean and traditional. The stalls are constructed of bamboo and carefully shaped wood, and muscle power is used wherever possible. Cows exercise and help out by fetching and carrying as best they can.`,
				"Chattel Religionist": `is functional and clean. There are nice quotations from the holy book on the walls, and there is a little shrine designed to allow a cow who has difficulty standing to make their devotions comfortably.`,
				"Degradationist": `is harsh and utilitarian. There are stands to restrain cows who aren't being milked for dosing, punishment, or sexual use. There are cattle prods here and there to use on resistant cows, unproductive cows, or cows one wishes to hear scream.`,
				"Repopulationist": `is comfortable and well-kept. The milking machines are specially designed to maximize a pregnant cow's comfort. After a milking, cows have a wide selection of soft furniture to choose from, so comfortable that most fall fast asleep.`,
				"Eugenics": `is comfortable, well-kept and well-monitored. Cows are kept track of at all times to make sure no-one tries to increase milk production via pregnancy.`,
				"Asset Expansionist": `looks misleadingly industrial at first glance. Though the cows here are free-range, the facility mounts a system of slings and cranes to allow slaves with massive udders to walk around with their tits suspended from the ceiling.`,
				"Transformation Fetishist": `looks like a medical facility at first glance. Transformation is just as much a priority as production: there are surgical and drug injection machines right here.`,
				"Gender Radicalist": `is comfortable and well-kept. The milking machines include perianal vibrators to massage slaves from butthole to cock while they give cum.`,
				"Gender Fundamentalist": `is comfortable and well-kept. The milking machines include vibrators so that cows can get off while they're milked.`,
				"Physical Idealist": `could be mistaken for a gym with milking machines. Cows here are expected to keep fit between milkings, since the best milk comes from cattle who are healthy, muscular, and strong.`,
				"Supremacist": `is spartan, since that's all subhuman cows need. There are cattle prods here and there to use on resistant cows, unproductive cows, or subhuman cows one wishes to hear scream.`,
				"Subjugationist": `is spartan, since that's all ${V.arcologies[0].FSSubjugationistRace} cows need. There are cattle prods here and there to use on resistant cows, unproductive cows, or ${V.arcologies[0].FSSubjugationistRace} cows one wishes to hear scream.`,
				"Paternalist": `is comfortable and well-kept. Rather than stalls, ${this.facility.name} has an open arrangement of machines cows can use freely, and a lovely common area they can relax in afterward.`,
				"Pastoralist": `is state of the art, but is also brilliantly designed to look like a barn. All the advanced machinery retracts when not in use, leaving the cows in a clean, airy pastoral paradise. It smells of summer.`,
				"Maturity Preferentialist": `is inviting and homelike. After a milking, cows have a wide selection of soft furniture to choose from, so comfortable that most fall fast asleep.`,
				"Youth Preferentialist": `is functional, but fun. There are all sorts of fun activities to keep the cows amused between milkings, cleverly adapted for girls with massive mammaries.`,
				"Body Purist": `is state of the art, and spotlessly clean. All attention here is on the cows, to keep them happy, productive, and pure.`,
				"Slimness Enthusiast": `is quite unusual. Since the cows it milks may not necessarily have gigantic boobs, the milking machines here can adapt to drain cream from any body.`,
				"Hedonistic": `is comfortable and fun. The stalls are filled with thick, soft pillows to lounge on while hooked to the milking machines and with plenty of toys to make use of while getting milked. Cows here are expected to binge eat between milkings, since the best milk comes from cattle who are immobile, stuffed with food and hugely fat.`,
				"Intellectual Dependency": `is simple and fun. Getting situated for milking is easy enough for even the dumbest cow to figure out and there are all sorts of activities to keep the cows amused between milkings.`,
				"Slave Professionalism": `is functional and clean. A wide selection of informative documentaries and books are available for cows to keep their minds sharp while the milker does its business.`,
				"Petite Admiration": `is comfortable and well-kept. While designed for miniature cows, accommodations for large udders allow even the lankiest of cattle to make use of the machinery.`,
				"Statuesque Glorification": `is comfortable and well-kept. While designed for towering cows, accommodations for large udders allow even the shortest of cattle to make use of the machinery; even if they need help to reach it.`,
				"standard": `is comfortable and well-kept. It features nice rest areas for cows to lounge in after a milking, and exercise equipment to keep them healthy.`,
			};
		}

		const res = FS[V.dairyDecoration];

		if (!res) {
			throw new Error(`Unknown V.dairyDecoration value of '${V.dairyDecoration}' found in decorations().`);
		}

		return res;
	}

	/** @returns {FC.Facilities.Expand} */
	get expand() {
		return {
			desc: `${this.facility.nameCaps} can support ${V.dairy} milkers. There ${numberWithPluralOne(this.facility.hostedSlaves, 'is', 'are')} currently ${numberWithPluralOne(this.facility.hostedSlaves, 'cow')} being drained in ${V.dairyName}.`,
			removeSlave: "get milked",
		};
	}

	/** @returns {FC.IUpgrade[]}*/
	get upgrades() {
		return [
			{
				property: "dairyFeedersUpgrade",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps} is equipped to feed and clean slaves normally.`,
						link: `Upgrade the milking machines with intubators`,
						cost: 10000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						note: ` and will increase upkeep costs`,
					},
					{
						value: 1,
						text: `The milking machines can hold feeders in slaves' mouths and inject drugs into their bodies, ensuring ideal nutrition and production.`,
					}
				],
			},

			{
				property: "dairyPregUpgrade",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps} is not prepared to support cow pregnancies, and therefore cannot be used to contract out fertile slaves' wombs.`,
						link: `Upgrade the dairy to support pregnancies`,
						cost: 2500 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						note: ` and will increase upkeep costs`,
					},
					{
						value: 1,
						text: `${this.facility.nameCaps} can support cow pregnancies.`,
					}
				],
			},
			{
				property: "dairyStimulatorsUpgrade",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps} does not automatically sodomize.`,
						link: `Upgrade the cockmilking machines with sodomizers`,
						cost: 10000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						note: ` and will increase upkeep costs`,
					},
					{
						value: 1,
						text: `The milking machines mount reciprocating dildos that can sodomize the slaves, delivering extra nutrition and pharmaceuticals. ${V.seeDicks ? `The prostate stimulation also serves to increase semen production, where appropriate.` : ``}`,
					}
				],
			},
			{
				property: "dairyPrepUpgrade",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps}'s industrial machines can only accept slaves with loose holes.`,
						link: `Install a preparatory raper`,
						cost: 5000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						prereqs: [
							() => (V.dairyPregSetting === 2 || V.dairyStimulatorsSetting === 2)
						],
					},
					{
						value: 1,
						text: `${this.facility.nameCaps} features a preparatory raper designed to gape slaves for integration.`,
					}
				],
			},
			{
				property: "dairyRestraintsUpgrade",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps} is not equipped to restrain recalcitrant cows.`,
						link: `Equip the dairy with milking racks`,
						cost: 5000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
					},
					{
						value: 1,
						text: `${this.facility.nameCaps} is equipped to restrain cows.`,
					}
				],
			},
			{
				property: "dairyHyperPregRemodel",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `${this.facility.nameCaps}'s milking racks can be remodeled to hold hyper-pregnant cattle.`,
						link: `Expand the milking racks`,
						cost: 10000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						prereqs: [
							() => !!V.seeHyperPreg,
							() => V.dairyRestraintsSetting === 2,
							() => V.dairyStimulatorsSetting === 2,
							() => V.dairyFeedersSetting === 2,
							() => V.dairyPregSetting > 0,
						],
					},
					{
						value: 1,
						text: `${this.facility.nameCaps}'s milking racks have been remodeled to allow cows' abnormal pregnancies room to grow.`,
					}
				],
			},
			{
				property: "dairySlimMaintainUpgrade",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `Dairy cows' breasts will expand normally as a result of the milking process.`,
						link: `Optimize the milking process to preserve small breast sizes`,
						cost: 5000 * V.upgradeMultiplierArcology,
						handler: () => {
							V.PC.skill.engineering += 0.1;
							V.dairySlimMaintain = 1;
						},
						prereqs: [
							() => V.arcologies[0].FSSlimnessEnthusiast > 80,
						],
					},
					{
						value: 0,
						upgraded: 1,
						text: `Dairy cows' breasts will expand normally as a result of the milking process.`,
						link: `Optimize the milking process to preserve small breast sizes`,
						cost: 5000 * V.upgradeMultiplierArcology,
						handler: () => {
							V.PC.skill.engineering += 0.1;
							V.dairySlimMaintain = 1;
						},
						prereqs: [
							() => V.arcologies[0].FSSlimnessEnthusiast > 20,
							() => V.arcologies[0].FSSlimnessEnthusiast <= 80,
						],
					},
					{
						value: 1,
						text: V.arcologies[0].FSSlimnessEnthusiast > 20
							? `Thanks to advances precipitated by the arcology's commitment to the fashion of slimmer slaves, ${this.facility.name} has been updated with optimized milkers for small breasts, and a customized drug regimen to extract maximum output while maintaining fashionably small breast sizes.`
							: `${this.facility.name} has been updated with milkers optimized for small breasts and a customized drug regimen to extract maximum output without causing excessive growth.`,
					}
				],
			},
			{
				property: "dairyUpgradeMenials",
				tiers: [
					{
						value: 0,
						upgraded: 1,
						text: `There is no provision for milking menial Bioreactors.`,
						link: `Add hose hookups`,
						cost: 5000 * V.upgradeMultiplierArcology,
						handler: () => V.PC.skill.engineering += 0.1,
						prereqs: [
							() => V.arcologies[0].FSPaternalist === "unset",
						],
					},
					{
						value: 1,
						text: V.menialBioreactors > 0
							? `Menial Bioreactors are restrained here and there, in every unused space. Hoses run from their nipples${V.seeDicks > 0 ? ` and penises` : ``} into the machinery, and from the machinery into their mouths${V.seeDicks > 0 ? `, anuses, and the pussies beneath their pregnant bellies` : ` and anuses`}.`
							: `In addition to the standard milking machines, ${this.facility.name} includes numerous hose hookups for menial Bioreactors. When there's space, any menial milkers you own can be placed in any empty space and connected.`,
					}
				],
			},
		];
	}

	/** @returns {FC.Facilities.Rule[]} */
	get rules() {
		const effectFunc = (arg) => this._getEffect(arg); // bind to this
		return [
			{
				property: "dairyFeedersSetting",
				prereqs: [
					() => V.dairyFeedersUpgrade > 0,
				],
				options: [
					{
						get text() { return `The feeders have been disabled.`; },
						link: `Deactivate`,
						value: 0,
						dialog: {
							get content() { return effectFunc('feeders'); },
						},
					},
					{
						get text() { return `The feeders are active.`; },
						link: `Moderate`,
						value: 1,
						dialog: {
							get content() { return effectFunc('feeders'); },
						},
					},
					{
						get text() { return `The feeders are industrial.`; },
						link: `Industrial`,
						value: 2,
						dialog: {
							get content() { return effectFunc('feeders'); },
						},
						prereqs: [
							() => V.dairyRestraintsSetting > 1,
						],
					},
				],
			},
			{
				property: "dairyPregSetting",
				prereqs: [
					() => V.dairyPregUpgrade > 0,
				],
				options: [
					{
						get text() { return `Fertile cows' wombs are not for hire.`; },
						link: `Not for hire`,
						value: 0,
						dialog: {
							get content() { return effectFunc('preg'); },
						},
					},
					{
						get text() { return `Fertile cows' wombs are for hire.`; },
						link: `Moderate`,
						value: 1,
						dialog: {
							get content() { return effectFunc('preg'); },
						},
					},
					{
						get text() { return `Fertile cows' wombs are industrially employed.`; },
						link: `Industrial`,
						value: 2,
						dialog: {
							get content() { return effectFunc('preg'); },
						},
						prereqs: [
							() => V.dairyRestraintsSetting > 1,
						],
					},
					{
						get text() { return `Fertile cows' wombs are worked to capacity.`; },
						link: `Mass production`,
						value: 3,
						dialog: {
							get content() { return effectFunc('preg'); },
						},
						prereqs: [
							() => V.seeExtreme > 0,
							() => V.seeHyperPreg > 0,
							() => V.dairyRestraintsSetting > 1,
							() => V.dairyHyperPregRemodel === 1,
						],
					},
				],
			},
			{
				property: "dairyStimulatorsSetting",
				prereqs: [
					() => V.dairyStimulatorsUpgrade > 0,
				],
				options: [
					{
						get text() { return `The sodomizers are inactive.`; },
						link: `Deactivate`,
						value: 0,
						dialog: {
							get content() { return effectFunc('stimulators'); },
						},
					},
					{
						get text() { return `The sodomizers are active.`; },
						link: `Moderate`,
						value: 1,
						dialog: {
							get content() { return effectFunc('stimulators'); },
						},
					},
					{
						get text() { return `The sodomizers are industrial, employing dildos the size of horse phalli.`; },
						link: `Industrial`,
						value: 2,
						dialog: {
							get content() { return effectFunc('stimulators'); },
						},
						prereqs: [
							() => !!V.seeExtreme,
							() => V.dairyRestraintsSetting > 1,
						],
					},
				],
			},
			{
				property: "dairyRestraintsSetting",
				prereqs: [
					() => V.dairyFeedersUpgrade > 0,
				],
				options: [
					{
						get text() { return `The cows are restrained only when necessary, allowing obedient cows freedom to range around.`; },
						link: `Deactivate`,
						value: 0,
						dialog: {
							get content() { return effectFunc('restraints'); },
						},
					},
					{
						get text() { return `The cows are restrained when being milked, giving the machines full play.`; },
						link: `Free range`,
						value: 1,
						dialog: {
							get content() { return effectFunc('restraints'); },
						},
					},
					{
						get text() { return `The cows are restrained permanently, allowing use of industrial techniques even devoted cows would flinch at.`; },
						link: `Permanent machine milking`,
						value: 2,
						dialog: {
							get content() { return effectFunc('restraints'); },
						},
					},
				],
			},
			{
				property: "createBioreactors",
				prereqs: [
					() => V.bioreactorsAnnounced !== 0,
					() => V.dairyRestraintsSetting === 2,
					() => V.dairyStimulatorsSetting === 2,
					() => V.dairyFeedersSetting === 2,
				],
				options: [
					{
						get text() { return `Perfected cows will be left as slaves.`; },
						link: `Deactivate`,
						value: 0,
					},
					{
						get text() { return `Perfected cows will be converted into equipment, permanently removing them from slave status.`; },
						link: `Convert`,
						value: 1,
					},

				],
			},
			{
				property: "dairySlimMaintain",
				prereqs: [
					() => !!V.dairySlimMaintainUpgrade,
				],
				options: [
					{
						get text() { return `Milking will operate as normal and will allow the breasts of slimmer slaves to expand.`; },
						link: `Normal operation`,
						value: 0,
						note: `This will not remove existing lactation implants.`
					},
					{
						get text() { return `Milking will limit the breast growth of slimmer slaves while maximizing their milk output.`; },
						link: `Preserve breast sizes`,
						value: 1,
						note: `This will allow the automatic administration of lactation-inducing drugs.`
					},
				],
			},
			{
				property: "dairyImplantsSetting",
				prereqs: [
					() => V.dairySlimMaintain === 0,
				],
				options: [
					{
						get text() { return `Naturally lactating cows, cows with non-lactating breasts, and cows incapable of producing cum will undergo lactation implant surgery to increase their milk output. Cows with working prostates will have them enhanced.`; },
						link: `Maximize milk production`,
						value: 0,
					},
					{
						get text() { return `All cows will undergo lactation implant surgery to increase their milk output.`; },
						link: `Maximize all production`,
						value: 1,
					},
					{
						get text() { return `Cows will not undergo surgical procedures to maximize production.`; },
						link: `Restrict maximization surgery`,
						value: 2,
					},
					{
						get text() { return `Non-lactating cows incapable of producing cum will undergo manual stimulation to promote natural production.`; },
						link: `Encourage natural lactation`,
						value: 3,
					},
				],
			},
			{
				property: "dairyWeightSetting",
				prereqs: [],
				options: [
					{
						get text() { return `Cow diets are not being monitored.`; },
						link: `Deactivate`,
						value: -1,
					},
					{
						get text() { return `Cows are being kept at least chubby.`; },
						link: `Chubby`,
						value: 0,
						note: V.dairySlimMaintainUpgrade === 1 || V.arcologies[0].FSSlimnessEnthusiast > 20
							? `Slimness controls will override all weight settings.`
							: null,
					},
					{
						get text() { return `Cows are being kept overweight.`; },
						link: `Overweight`,
						value: 1,
						note: V.dairySlimMaintainUpgrade === 1 || V.arcologies[0].FSSlimnessEnthusiast > 20
							? `Slimness controls will override all weight settings.`
							: null,
					},
					{
						get text() { return `Cows are being kept fat.`; },
						link: `Fat`,
						value: 2,
						note: V.dairySlimMaintainUpgrade === 1 || V.arcologies[0].FSSlimnessEnthusiast > 20
							? `Slimness controls will override all weight settings.`
							: null,
					},
					{
						get text() { return `Cows are being kept very fat.`; },
						link: `Very fat`,
						value: 3,
						note: V.dairySlimMaintainUpgrade === 1 || V.arcologies[0].FSSlimnessEnthusiast > 20
							? `Slimness controls will override all weight settings.`
							: null,
					},
					{
						get text() { return `Cows are being kept so fat they can barely move.`; },
						link: `Immobile`,
						value: 4,
						note: V.dairySlimMaintainUpgrade === 1 || V.arcologies[0].FSSlimnessEnthusiast > 20
							? `Slimness controls will override all weight settings.`
							: null,
					},
				],
			},
			{
				property: "milkmaidImpregnates",
				prereqs: [
					() => !!S.Milkmaid,
				],
				options: [
					{
						get text() { return `${S.Milkmaid.slaveName} will not keep the cows pregnant ${getPronouns(S.Milkmaid).himself}.`; },
						link: `Forbid`,
						value: 0,
					},
					{
						get text() { return `Keeping the cows pregnant is part of ${S.Milkmaid.slaveName}'s job.`; },
						link: `Allow`,
						value: 1,
					},
				],
			},
			{
				property: "dairyHormonesSetting",
				prereqs: [],
				options: [
					{
						get text() { return `Hormone application is left to your discretion.`; },
						link: `Deactivate`,
						value: -1,
					},
					{
						get text() { return `Cows will not be given hormones.`; },
						link: `No hormones`,
						value: 0,
						note: `Favors milk production when possible.`,
					},
					{
						get text() { return `Cows will be given hormones.`; },
						link: `Normal dosage`,
						value: 1,
						note: `Favors milk production when possible.`,
					},
					{
						get text() { return `Cows will undergo intense hormone treatment.`; },
						link: `Maximum dosage`,
						value: 2,
						note: `Favors milk production when possible.`,
					},
				],
			},
		];
	}

	/** @returns {HTMLDivElement} */
	get stats() {
		return App.UI.DOM.makeElement("div", App.Facilities.Dairy.Stats(true));
	}

	/** @returns {HTMLDivElement} */
	get warning() {
		const div = document.createElement("div");

		if (V.dairyPregSetting > 1 || V.dairyFeedersSetting > 1 || V.dairyStimulatorsSetting > 1) {
			App.Events.addNode(div, [
				`<span class="warning">Current milking machine settings will have dramatic and possibly irreversible effects on cow bodies and minds.</span>`
			]);
		}

		return div;
	}

	/**
	 * Returns the dialog text to display when setting a rule.
	 *
	 * @param {'feeders'|'stimulators'|'preg'|'restraints'} setting
	 */
	_getEffect(setting) {
		const text = [];

		const {He: HeU, he: heU, him: himU, his: hisU, himself: himselfU} = getNonlocalPronouns(V.seeDicks);

		if (this.facility.hostedSlaves > 1) {
			if (setting === "feeders") {
				if (V.dairyFeedersSetting < 2) {
					text.push(`In unison, the milking machines withdraw their feeders from the slaves' throats. The slaves gag and cough, strings of feeding fluid and saliva running between their lips and the heads of the feeding phalli. These remain close to their faces so that the slaves can suck them off once they get hungry, which they will, soon. The slaves' mouths and tongues are very tired, and most of them rest with their mouths open and their tongues hanging out.`);
				} else {
					text.push(`In unison, the milking machines press their feeding phalli into the slaves' mouths and down their throats. Once situated, they begin to facefuck the slaves, who gag and struggle as they figure out how to breathe while this is going on. Once each slave is no longer panicking and is inhaling and exhaling regularly, there is a hydraulic sound and the transparent reservoir of feeding fluid near their head begins to drain. The slaves swallow desperately, their bellies beginning to swell with nutrition and drugs.`);
				}
			} else if (setting === "preg") {
				if (V.dairyPregSetting < 2) {
					for (const slave of this.facility.employees()) {
						const {him, his} = getPronouns(slave);

						if (slave.vagina.isBetween(-1, 3)) {
							text.push(`${slave.slaveName}'s milking machine ejects ${him}, since it cannot fit the mandated dildo into ${his} tight cunt.`);

							removeJob(slave, Job.DAIRY);
						}
						if (V.dairyPregSetting > 0) {
							WombCleanGenericReserve(slave, "incubator", 9999);
							WombCleanGenericReserve(slave, "nursery", 9999);

							if (slave.broodmother > 0 || slave.bellyImplant !== -1) {
								text.push(`${slave.slaveName}'s milking machine ejects ${him}, since it detected a foreign body in ${his} womb blocking its required functions.`);

								removeJob(slave, Job.DAIRY);
							}
						}
					}

					text.push(`In unison, the milking machines withdraw their dildos from the pregnant slaves' vaginas. The auxiliary drug injectors hiss as the slaves are filled with drugs that promote natural lubrication. The slaves begin to shift awkwardly as they feel their pussies begin to drool slick female fluids. Once a machine judges that its slave's cunt is sufficiently wet, it readies a gigantic dildo. The slaves cannot see their own groins, but as soon as the heads of the dildos touch their pussylips, they begin to`);

					if (V.dairyFeedersSetting < 2) {
						text.push(`struggle instinctively against their restraints, and the more energetic ones begin to weep.`);
					} else {
						text.push(`struggle instinctively against their restraints.`);
					}

					text.push(`As the massive phalli begin to ejaculate fertility drugs and semen, they drive all resistance out of the poor girls.`);
				} else {
					text.push(`In unison, the milking machines withdraw their monstrous dildos from the pregnant slaves' stretched cunts. Their pussies' overcharged production of natural lubricant produces a gush of pent-up female fluids from each loose vagina as the phalli slide clear.`);

					if (V.dairyFeedersSetting < 2) {
						text.push(`The slaves moan with relief at the sudden reduction in fullness. Being penetrated like that while pregnant must be quite uncomfortable.`);
					} else {
						text.push(`The slaves are silent, since their mouths and throats are being fucked by the feeders, but most of them relax a little in their restraints.`);
					}

					text.push(`The machines do replace the withdrawn dildos with more reasonably sized phalli and resume thrusting, but the slaves are relieved anyway.`);
				}
			} else if (setting === "stimulators") {
				if (V.dairyStimulatorsSetting < 2) {
					for (const slave of this.facility.employees()) {
						const {him, his} = getPronouns(slave);

						if (slave.vagina.isBetween(-1, 3)) {
							text.push(`${slave.slaveName}'s milking machine ejects ${him}, since it cannot fit its massive anal dildo up ${his} tight asshole.`);

							removeJob(slave, Job.DAIRY);
						}
					}

					text.push(`In unison, the milking machines shove their dildos deep into slaves' anuses, ejaculating large quantities of lubricant deep inside their rectums. The slaves start in surprise at the sudden rush of warm slick fluid, and then relax as the phalli withdraw themselves from their butts. Their relief is short-lived, however, as their assholes are only empty for a moment. The reasonably sized dildos are replaced with dildos the size of horse cocks. As soon as the slaves feel the heads of these monstrous phalli press inexorably against their sphincters,`);

					if (V.dairyStimulatorsSetting < 2) {
						text.push(`they begin to scream and struggle instinctively. As the constant assrape that will define their existences for the foreseeable future begins in earnest, their whining`);
					} else {
						text.push(`they begin to struggle wildly. As the constant assrape that will define their existences for the foreseeable future begins in earnest, their wriggling`);
					}

					text.push(`gradually diminishes as each slave is exhausted and slumps within their restraints. The machines take no notice, and continue the relentless sodomy.`);
				} else {
					text.push(`In unison, the milking machines withdraw their gargantuan dildos from the slaves' loosened anuses.`);

					if (V.dairyStimulatorsSetting < 2) {
						text.push(`Several of the more energetic slaves begin to cry quietly with relief`);
					} else {
						text.push(`The slaves are silent, since their mouths and throats are being fucked by the feeders, but most of them slump against their machines with relief`);
					}

					text.push(`as their sphincters gradually recover from wide open to merely gaping. The machines switch out the withdrawn dildos for phalli that are just large, but the slaves barely react at all as they are penetrated. After what their sphincters have been through, a merely big dick is nothing to them.`);
				}
			} else if (setting === "restraints") {
				if (V.dairyRestraintsSetting < 2) {
					if (V.dairyRestraintsSetting === 1) {
						for (const slave of this.facility.employees()) {
							const {he, him} = getPronouns(slave);

							if (slave.indentureRestrictions > 1) {
								text.push(`${slave.slaveName}'s milking machine declines to restrain ${him}, since ${he} is encoded as an indentured servant protected from restraint for milking.`);

								removeJob(slave, Job.DAIRY);
							}
						}

						text.push(`The next cow to stumble over to a milking machine to be drained is gently but firmly embraced by its restraints, allowing it to suck ${himU} dry and violate ${himU} without any regard for ${hisU} feelings. Most of the cows accept this new wrinkle in their lives, since the restraints let them go afterward, and the milking machines bring temporary relief. Some, however, begin to regard the machines with concern.`);
					} else {
						text.push(`The next cow to stumble over to a milking machine to be drained finds to ${hisU} surprise that ${heU} is not restrained while it sucks ${himU} dry. ${HeU} wiggles around experimentally, verifying that ${heU} is indeed free to pull ${himselfU} away from its ministrations if ${heU} wishes. There's little actual impact on the cows' behavior, since they still need the relief the machines offer.`);
					}
				} else {
					if (V.dairyRestraintsSetting === 1) {
						for (const slave of this.facility.employees()) {
							const {he, him} = getPronouns(slave);

							if (slave.indentureRestrictions > 1) {
								text.push(`${slave.slaveName}'s milking machine declines to restrain ${him}, since ${he} is encoded as an indentured servant protected from restraint for milking.`);

								removeJob(slave, Job.DAIRY);
							}
						}

						text.push(`The next time a cow tries to get up after being milked, ${heU} finds to ${hisU} sudden terror that the machine will not let ${himU} go. It continues to add fluids to ${hisU} body, and remove them from ${hisU} nipples, ignoring ${hisU} mounting panic as ${heU} realizes that it's to be ${hisU} new partner and lover, on a level far more intimate than any possible human relationship. The other cows approach their machines with trepidation, but the mounting pressure in their udders forces them to embrace their immurement despite their terror.`);
					} else {
						text.push(`The next time a cow finishes an intensive milking period, ${hisU} restraints loosen. ${HeU} does not move for a long time, as though ${heU} is unable to believe that ${heU} is, at least in an immediate and local sense, free. Finally, ${heU} prises ${himselfU} out of ${hisU} milking machine's embrace, thick strings of fluid leading from it to ${hisU} orifices as ${heU} pulls each one off of its corresponding port.`);
					}
				}
			}
		}

		return text.join(' ');
	}

	/** @returns {HTMLDivElement[]} */
	get customNodes() {
		return [
			this.warning,
		];
	}
};

repo_name: Banyanael/fc

license: mit


code:
App.Data.Facilities.dairy = {
	baseName: "dairy",
	genericName: null,
	jobs: {
		cow: {
			position: "cow",
			assignment: Job.DAIRY,
			publicSexUse: false,
			fuckdollAccepted: false
		}
	},
	defaultJob: "cow",
	manager: {
		position: "milkmaid",
		assignment: Job.MILKMAID,
		careers: App.Data.Careers.Leader.milkmaid,
		skill: "milkmaid",
		publicSexUse: false,
		fuckdollAccepted: false,
		broodmotherAccepted: false,
		shouldWalk: true,
		shouldHold: true,
		shouldSee: true,
		shouldHear: true,
		shouldTalk: false,
		shouldThink: true,
		requiredDevotion: 21
	},
	decorated: true
};

App.Entity.Facilities.DairyCowJob = class extends App.Entity.Facilities.FacilitySingleJob {
	/**
	 * @override
	 * @returns {string}
	 */
	get assignment() {
		return `be milked in ${this.facility.name}`;
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {string[]}
	 */
	checkRequirements(slave) {
		let r = super.checkRequirements(slave);

		if ((slave.indentureRestrictions > 0) && (V.dairyRestraintsSetting > 1)) {
			r.push(`${slave.slaveName}'s indenture forbids extractive Dairy service.`);
		}
		if ((slave.indentureRestrictions > 1) && (V.dairyRestraintsSetting > 0)) {
			r.push(`${slave.slaveName}'s indenture allows only free range milking.`);
		}
		if (slave.breedingMark === 1 && V.propOutcome === 1 && V.eugenicsFullControl !== 1 && V.arcologies[0].FSRestart !== "unset" && V.dairyRestraintsSetting > 0) {
			r.push(`${slave.slaveName} may only be a free range cow.`);
		}
		if ((V.dairyPregSetting > 0) && ((slave.bellyImplant !== -1) || (slave.broodmother !== 0))) {
			r.push(`${slave.slaveName}'s womb cannot accommodate current machine settings.`);
		}

		if (!isAmputee(slave) && (this.facility.option("RestraintsUpgrade") !== 1) &&
			!App.Entity.Facilities.Job._isBrokenEnough(slave, 20, -50, -20, -50)) {
			r.push(`${slave.slaveName} must be obedient in order to be milked at ${this.facility.name}.`);
		}

		if ((slave.lactation === 0) && (slave.balls === 0)) {
			// the slave does not produce useful liquids now. Let's find out can the dairy make it lactate
			if ((V.dairySlimMaintainUpgrade !== 1 && V.dairySlimMaintain <= 0) && V.dairyImplantsSetting !== 1 && V.dairyImplantsSetting !== 3) {
				// dairy settings disallow any procedures
				r.push(`${slave.slaveName} is not lactating ` + ((V.seeDicks > 0) ? 'or producing semen ' : '') + `and ${this.facility.name}'s current settings forbid the automatic implantation of lactation inducing drugs or manual stimulation to induce it, and thus cannot be a cow.`);
			} else if (slave.boobs <= 300) {
				r.push(`${slave.slaveName} is not lactating ` + ((V.seeDicks > 0) ? 'or producing semen ' : '') + 'and have not enough breast tissue to induce lactation.');
			}
		}
		if ((V.dairyStimulatorsSetting >= 2) && (slave.anus <= 2) && (V.dairyPrepUpgrade !== 1)) {
			r.push(`${slave.slaveName}'s anus cannot accommodate current machine settings.`);
		}
		if ((V.dairyPregSetting >= 2) && (slave.vagina <= 2) && (slave.ovaries !== 0) && (V.dairyPrepUpgrade !== 1)) {
			r.push(`${slave.slaveName}'s vagina cannot accommodate current machine settings.`);
		}

		return r;
	}
};

App.Entity.Facilities.Dairy = class extends App.Entity.Facilities.SingleJobFacility {
	constructor() {
		super(App.Data.Facilities.dairy,
			{
				cow: new App.Entity.Facilities.DairyCowJob()
			});
	}

	/** @override */
	get nonEmployeeOccupantsCount() {
		return V.bioreactorsXY + V.bioreactorsXX + V.bioreactorsHerm + V.bioreactorsBarren;
	}
};

App.Entity.facilities.dairy = new App.Entity.Facilities.Dairy();


code:
App.Facilities.Dairy.inflation = function() {
	const inflatedSlaves = {
		milk: 0,
		cum: 0
	};
	for (const s of V.slaves) {
		if (s.inflationMethod === 1 || s.inflationMethod === 2) {
			if (s.inflationType === "milk") {
				inflatedSlaves.milk++;
			} else if (s.inflationType === "cum") {
				inflatedSlaves.cum++;
			}
		}
	}
	return inflatedSlaves;
};


code:
App.Facilities.Dairy.freeRangeAssignmentScene = function(slave) {
	/* This scene wants V.dairyRestraintsSetting === 0 && slave.devotion > 0 && slave.fetish !== "mindbroken" */
	const node = new DocumentFragment();

	V.nextButton = "Continue";
	V.nextLink = V.returnTo;
	let r = [];
	const {
		He, His,
		he, him, his, himself
	} = getPronouns(slave);

	App.UI.DOM.drawOneSlaveRight(node, slave);

	r.push(`${slave.slaveName} reports to the dairy.`);
	if (slave.energy > 90 ) {
		r.push(`${He} rejoices since ${he} is actually eager to be milked.`);
	}
	App.Events.addParagraph(node, r);
	r = [];

	/* AROUSAL WHEN ENTERING */
	let aroused = false;
	if (App.Entity.facilities.dairy.employeesIDs().size > 1 && canSee(slave)) {
		r.push(`While`);
		if (canWalk(slave)) {
			r.push(`walking`);
		} else if (canMove(slave)) {
			r.push(`being helped`);
		} else {
			r.push(`being carried`);
		}
		r.push(`to ${his} designated stall, ${he} passes the other cows currently at their milking machines. Not being hurried, ${he} occasionally watches a cow in detail.`);
		App.Events.addParagraph(node, r);
		r = [];
		if (slave.fetish === "boobs") {
			/* TODO: check if there actually are lactating cows at the dairy */
			aroused = true;
			r.push(`${He} cannot help but to feel aroused at the view of all those udders being thoroughly milked.`);
			if (slave.sexualFlaw === "breast growth") {
				r.push(`${He} is already fantasizing of having ${his} breasts expanded to ridiculous proportions${(slave.lactation > 0) ? ` so ${he} can produce even more milk` : ""}.`);
			}
		} else if (slave.fetish === "pregnancy" && V.dairyPregSetting === 1) {
			aroused = true;
			r.push(`The automatic impregnators are currently active. They are not running on an industrial setting, but on a gentler one. Every fertile cow's pussy is filled with a dildo attached on a mechanical arm. There is a wide range of sizes. Some dildos are small and provide expert stimulation for the sensitive areas. Other cows seem to prefer forearm-length horse-cocks for more intense stimulation. The automatic thrusting speeds vary, too, but all of them fill the slave completely so not a drop of sperm can leak out. Some cows are currently asleep. Their respective stimulators are comfortably resting deeply buried in their vaginas, keeping the loads right where they belong. Whenever a cow reaches climax, the sodomizers can thrust at ridiculous speeds to encourage fertilization. The sight of all those lovely baby bumps arouses ${slave.slaveName}.`);
			if (slave.sexualFlaw === "breeder" && isFertile(slave)) {
				r.push(`${He} cannot wait to get impregnated too.`);
			}
		} else if (slave.fetish === "buttslut" && V.dairyStimulatorsSetting === 1) {
			aroused = true;
			r.push(`The automatic sodomizers are currently active. They are not running on an industrial setting, but on a gentler one. Every cow's anus is filled with a dildo attached on a mechanical arm. There is a wide range of sizes. Some dildos are small and provide expert stimulation for the sensitive areas. Other cows seem to prefer forearm-length horse-cocks for more intense stimulation. The automatic thrusting speeds vary, too. Some cows are currently asleep. Their respective stimulators are comfortably resting deeply buried in their behinds. Whenever a cow reaches climax, the sodomizers can thrust at ridiculous speeds. Good thing they provide not only nutrition, but lubrication, too. The sight of all those lovely rear-ends relentlessly reamed arouses ${slave.slaveName}.`);
			if (slave.sexualFlaw === "anal addict") {
				r.push(`${He} cannot wait to be sodomized, too.`);
			}
		}
		App.Events.addParagraph(node, r);
		r = [];

		const cow = V.slaves.find(s => s.assignment === "work in the dairy" && s.ID !== slave.ID && s.balls >= 10 && s.dick > 0);
		if (cow) {
			const {
				He2, His2,
				he2, his2, him2,
			} = getPronouns(cow).appendSuffix("2");
			aroused = true;
			App.UI.DOM.drawOneSlaveRight(node, cow);
			r.push(`The hyper-endowed cum-cow ${cow.slaveName} is the pride of ${V.dairyName}. ${He2} is limply hanging on ${his2} milking chair, panting heavily because of the constant suction on ${his2} dick. ${He2} is obviously nearing climax. Soon,`);
			if (hasAnyNaturalEyes(cow)) {
				r.push(his2);
				if (hasBothNaturalEyes(cow)) {
					r.push(`eyes bulge`);
				} else {
					r.push(`eye bulges`);
				}
				r.push(`and`);
			}
			r.push(`${his2} muscles tense.`);
			if (V.dairyStimulatorsSetting === 1) {
				if (cow.prostate !== 0) {
					r.push(`${His2} anus clenches around the dildo in ${his2} rear. The automatic sodomizer speeds up to give ${his2} prostate a helpful pounding.`);
				} else {
					r.push(`${He2} lacks a prostate, so the automatic sodomizer is forced to pound ${him2} mercilessly to make ${him2} cum.`);
				}
			} else if (V.MilkmaidID !== 0 && S.Milkmaid.dick > 4 && canPenetrate(S.Milkmaid)) {
				r.push(`${S.Milkmaid.slaveName} quickly steps in and penetrates ${his2} rear to push ${him2} powerfully over the edge.`);
			} else {
				r.push(`${His2} butthole opens and closes.`);
			}
			r.push(`${His2} cock twitches as it begins to unload. Inhumanly large amounts of semen spurt into the receptacle which encases ${his2} dick. ${His2} orgasm does not seem to end for minutes. The milking machine keeps ${him2} cumming longer than naturally possible. Only primal moans escape ${his2} throat. As ${his2} orgasm finally subsides, ${he2} slumps back, grinning in post-orgasmic bliss. All things considered, ${cow.slaveName} seems to be very happy with being a cow.`);
			if (cow.dickTat === "bovine patterns" ) {
				r.push(`Even ${his2} dick is tattooed to look like a bull's.`);
			}
			App.Events.addParagraph(node, r);
			r = [];
			App.UI.DOM.appendNewElement("div", node, `"Moo," ${he2} moans lustily, imitating a cow.`);
		}
	/* TODO: watch a specific cow, e.g. lover or relative or huge-titted */
	}

	if (aroused) {
		r.push(`All this lewd display turns ${slave.slaveName} on and ${he} is almost overcome by lust. ${He} realizes ${he} probably should not have taken so much interest in the other cows.`);
		if (slave.dick > 0) {
			r.push(`${He} feels ${his} blood rush into ${his}`);
			if (slave.dick > 8) {
				r.push(`gargantuan`);
			} else if (slave.dick > 6) {
				r.push(`huge`);
			} else if (slave.dick > 2) {
				r.push(`fair-sized`);
			} else {
				r.push(`small`);
			}
			r.push(`dick.`);
		}
		if (slave.vagina > -1 ) {
			r.push(`${His} pussy moistens.`);
		}
		if (slave.lactation > 0) {
			if (slave.nipples === "fuckable") {
				r.push(`Milk begins to leak out of ${his} nipplecunts.`);
			} else {
				r.push(`${His} milk-dripping nipples stiffen.`);
			}
		}
	} /* AROUSAL WHEN ENTERING END*/
	App.Events.addParagraph(node, r);
	r = [];

	/* GETTING IN */
	r.push(`Eventually, ${slave.slaveName} arrives at ${his} designated milking stall.`);
	let assayedSlave = randomRelatedSlave(slave, s => s.assignment === Job.DAIRY);
	let assayType;
	if (assayedSlave) {
		assayType = relativeTerm(slave, assayedSlave);
	} else if (slave.relationship > 0) {
		assayedSlave = getSlave(slave.relationshipTarget);
		if (assayedSlave && assayedSlave.assignment === Job.DAIRY) {
			switch (slave.relationship) {
				case 1:
					assayType = "friend";
					break;
				case 2:
					assayType = "best friend";
					break;
				case 3:
					assayType = "fuckbuddy";
					break;
				case 4:
					assayType = "lover";
					break;
				case 5:
					assayType = "slave wife";
					break;
			}
		}
	}
	if (assayType) {
		const {
			He2
		} = getPronouns(assayedSlave).appendSuffix("2");
		App.UI.DOM.drawOneSlaveRight(node, assayedSlave);
		r.push(`${His} ${assayType} ${assayedSlave.slaveName} is at the dairy, too. ${He2} is in the adjacent stall. The two of them are going to be milked right next to each other.`);
	}
	App.Events.addParagraph(node, r);
	r = [];

	App.UI.DOM.drawOneSlaveRight(node, S.Milkmaid);
	r.push(`The only "furniture" in the stall looks like a dentist's chair. Despite the medical appearance, when ${he}`);
	if (slave.devotion > 90) {
		r.push(`eagerly`);
	} else if (slave.slaveName < 40) {
		r.push(`hesitantly`);
	}
	r.push(`gets into the chair it turns out to be quite comfortable.`);
	if (V.MilkmaidID === 0) {
		r.push(`Automated machinery springs to life, preparing ${him} for milking.`);
	} else {
		r.push(`Your appointed milkmaid ${S.Milkmaid.slaveName} helps ${slave.slaveName} with installing the milking devices.`);
	}
	if (slave.lactation > 0 ) {
		r.push(`Suction cups are attached`);
		if (slave.nipples === "fuckable" || slave.nipples === "flat") {
			r.push(`over`);
		} else {
			r.push(`to`);
		}
		r.push(`${his} nipples.`);
	}
	if (slave.balls > 0) {
		if (slave.dick > 8) {
			r.push(`A huge receptacle is attached to ${his} over-sized member.`);
		} else if (slave.dick > 6) {
			r.push(`A large cock-milker is attached to ${his} huge dick.`);
		} else if (slave.dick > 2) {
			r.push(`A special cock-milker is attached to ${his} dick.`);
		} else if (slave.dick > 0) {
			r.push(`A suction cup is attached to ${his} small dicklet. Due to the embarrassingly small size of ${his} penis, the very kind of cup is used that normally goes on nipples.`);
		} else {
			r.push(`A suction cup is attached over ${his} hidden cumhole.`);
		}
	}
	App.Events.addParagraph(node, r);
	r = [];
	if (V.dairyFeedersSetting === 1) {
		r.push(`Near the headrest of the chair, an artificial phallus is installed. The cow can easily reach it with ${his} mouth. The phallus provides hydration and nutrition when sucked. The supplement consists of excess or low-quality milk and cum from the dairy itself as well as aphrodisiacs and hormones enhancing lactation and semen production.`);
		if (slave.sexualFlaw === "cum addict" || slave.fetish === "cumslut") {
			r.push(`${slave.slaveName}`);
			r.push(`eagerly shoves the artificial phallus into ${his} mouth. ${He} gives it an experimental suckle. To ${his} joy, ${he} soon is rewarded with a fresh spurt of semen-like nutrition supplement. Then ${he} readjusts the holder to keep the phallus lodged in ${his} mouth, effectively forcing ${himself} to keep sucking the artificial dick.`);
		}
	}
	App.Events.addParagraph(node, r);
	r = [];
	r.push(`The milking chair comes with a small screen, providing mental stimulation for the cow. It is highly pornographic, of course. It also includes live-streams of close-ups from the cows being milked or their orifices being penetrated. ${slave.slaveName} selects ${his} favorite program`);
	if (canSee(slave)) {
		r.push(`to watch.`);
	} else if (canHear(slave)) {
		r.push(`to listen to.`);
	} else {
		r.push(`to feel the vibrations from.`);
	}
	r.push(`It features`);
	if (slave.attrXY > slave.attrXX || slave.behavioralQuirk === "adores men") {
		r.push(`men`);
	} else {
		r.push(`women`);
	}
	if (slave.fetish === "submissive") {
		r.push(`submitting to their sexual partners.`);
	} else if (slave.fetish === "cumslut") {
		if (slave.attrXY > slave.attrXX || slave.behavioralQuirk === "adores men") {
			r.push(`jacking off directly into the camera.`);
		} else {
			r.push(`sucking dick for all it's worth.`);
		}
		if (V.dairyFeedersSetting === 1 ) {
			r.push(`The dairy feeders ejaculations are synced with the events in the video. ${slave.slaveName} receives a load of cum-like nutrition every time a dick shoots. It really draws ${him} into the pornography.`);
		}
	} else if (slave.fetish === "humiliation") {
		r.push(`being humiliated.`);
	} else if (slave.fetish === "buttslut") {
		r.push(`being fucked in the ass.`);
		if (V.dairyStimulatorsSetting === 1) {
			r.push(`The dairy stimulators are synced to the videos. The automatic sodomizers thrust in exactly the same way as the dicks or dildos in the video. ${slave.slaveName} is amazed by this advanced pornography. It feels like it was ${him} being fucked in the videos all over.`);
		}
	} else if (slave.fetish === "dom") {
		r.push(`dominating their sexual partners.`);
	} else if (slave.fetish === "masochist") {
		r.push(`being flogged.`);
	} else if (slave.fetish === "sadist") {
		r.push(`abusing their sexual partners.`);
	} else if (slave.fetish === "pregnancy") {
		if (slave.attrXY > slave.attrXX || slave.behavioralQuirk === "adores men") {
			r.push(`fucking pregnant women.`);
		} else {
			r.push(`being fucked while pregnant.`);
			if (V.dairyPregSetting > 0) {
				r.push(`The dairy stimulators are synced to the videos. The impregnating dildo thrusts in exactly the same way as the dicks or dildos in the video. ${slave.slaveName} is amazed by this advanced pornography. It feels like it was ${him} being fucked and cummed inside in the videos all over.`);
			}
		}
	} else {
		r.push(`engaging in vanilla intercourse.`);
	}
	App.Events.addParagraph(node, r);
	r = [];

	r.push(`Sexual stimulation increases product output.`);
	if (V.MilkmaidID === 0 && V.dairyStimulatorsSetting === 0) {
		r.push(`Unfortunately, there is neither a milkmaid providing personal assistance nor automatic sodomizers installed in your dairy.`);
	} else {
		if (V.MilkmaidID !== 0) {
			const {
				He2,
				he2, his2
			} = getPronouns(S.Milkmaid).appendSuffix("2");
			r.push(`Your milkmaid ${S.Milkmaid.slaveName} is working in the dairy. Whenever a cow needs ${his2} assistance, ${he2} is happy to help.`);
			if (S.Milkmaid.dick > 1 && canPenetrate(S.Milkmaid)) {
				r.push(`Most often, ${he2} uses ${his2} cock to penetrate the cows.`);
			} else {
				r.push(`Lacking penile equipment of appropriate size, ${he2} relies on ${his2} tongue to stimulate the cow's sexual organs.`);
			}
			r.push(`${He2} is quite skilled in giving mammary massages and handjobs, too.`);
			if (V.milkmaidImpregnates === 1 && canPenetrate(S.Milkmaid) && S.Milkmaid.pubertyXY === 1 && S.Milkmaid.ballType === "human") {
				r.push(`If at all possible, it is ${his2} duty to thoroughly knock up ${his2} charges.`);
			}
			App.Events.addParagraph(node, r);
			r = [];
		}
		if (V.dairyStimulatorsSetting > 0) {
			r.push(`Automated sodomizers help the cows produce by penetrating their anuses. The milking chairs built-in sensors measure ${slave.slaveName}'s anal capacity.`);

			if (slave.anus === 0 ) {
				r.push(`The machine detects an unused rear-end. In order to protect ${his} anal virginity, the automatic sodomizer stays inactive.`);
			} else {
				r.push(`In order to provide adequate stimulation for ${his}`);
				if (slave.anus > 3) {
					r.push(`gaping anus, the automatic sodomizer is equipped with a gigantic horse-like phallus. It wobbles menacingly.`);
				} else if (slave.anus > 2) {
					r.push(`well-used rear-end, the automatic sodomizer is equipped with a large phallus. It is nicely ribbed for extra stimulation.`);
				} else {
					r.push(`anus, the automatic sodomizer is equipped with a fair-sized silicone phallus.`);
				}
				r.push(`Lubrication spurts from a hole at the tip, giving the artificial phallus a very lifelike pre-dripping look. Gently, the mechanical arm pushes the phallus into ${slave.slaveName}'s behind.`);

				if (slave.fetish === "buttslut" || slave.sexualFlaw === "anal addict") {
					r.push(`${He} shudders with joy.`);
				}
				r.push(`Soon, the automatic sodomizer pumps the dildo in and out of ${his} butt-hole.`);
				if (slave.balls > 0 && slave.scrotum > 0) {
					r.push(`${His}`);
					if (slave.balls > 5 ) {
						r.push(`massive`);
					}
					r.push(`balls swing back and forth.`);
				}
				if (slave.dick > 0 ) {
					if (slave.prostate !== 0) {
						r.push(`The dildo stimulates ${his} prostate perfectly. Pre-cum begins to leak from ${his} cock.`);
					}
					/* TODO: the next lines feel non-canon */
					r.push(`The milking machine remains at this setting for longer than normal. Pre-cum is considered a delicacy and is harvested as much as possible before having a negative impact on cum production.`);
				}
			}
			App.Events.addParagraph(node, r);
			r = [];
		}
		if (V.dairyPregSetting > 0) {
			r.push(`Ejaculate squirting dildos keep the slave's wombs stuffed with seed until they are confirmed pregnant and aid in preparing them for childbirth.`);
			if (isFertile(slave)) {
				r.push(`Since ${he} is quite fertile, it springs to life.`);
				if (slave.vagina === 0) {
					r.push(`The machine detects a virgin pussy. In order to protect ${his} virginity, the automatic dildo returns to its housing.`);
				} else {
					r.push(`In order to provide adequate stimulation for ${his}`);
					if (slave.vagina > 3) {
						r.push(`gaping vagina, the automatic dildo is equipped with a gigantic horse-like phallus. It wobbles menacingly.`);
					} else if (slave.vagina > 2) {
						r.push(`well-used rear-end, the automatic dildo is equipped with a large phallus. It is nicely ribbed for extra stimulation.`);
					} else {
						r.push(`vagina, the automatic dildo is equipped with a fair-sized silicone phallus.`);
					}
					r.push(`Lubrication spurts from a hole at the tip, giving the artificial phallus a very lifelike pre-dripping look. Gently, the mechanical arm pushes the phallus into ${slave.slaveName}'s pussy.`);

					if (slave.fetish === "pregnancy" || slave.sexualFlaw === "breeder") {
						r.push(`${He} shudders with joy.`);
					}
					r.push(`Soon, the automatic impregnator pumps the dildo in and out of ${his} body, frequently releasing large loads of potent cum directly into ${his} womb.`);
				}
			}
		}
	}
	/* GETTING IN END */
	App.Events.addParagraph(node, r);
	r = [];

	/* MILKING ROUTINE */
	if (slave.lactation > 0) {
		r.push(`The milking cups`);
		if (slave.nipples === "fuckable" || slave.nipples === "flat") {
			r.push(`over`);
		} else {
			r.push(`on`);
		}
		r.push(`${his} nipples begin to pulse rhythmically. Soon, a steady flow of breast-milk is sucked away into the storage tanks.`);
	}
	if (slave.dick > 0) {
		r.push(`The milking machine uses suction to draw ${his} dick into the receptacle.`);
		if (slave.dick > 10) {
			r.push(`${His} dick is too large to even consider getting hard again, so it just attaches firmly to the tip.`);
		} else if (slave.dick > 8) {
			r.push(`${He} is on the verge of passing out as most of ${his} blood volume rushes into ${his} dick. ${He} cannot possibly reach a full erection without the machine's help. ${He} fights to stay awake so ${he} can enjoy ${his} inhuman cock at throbbing hardness.`);
		} else if (slave.dick > 6) {
			r.push(`${He} feels dizzy as most of ${his} blood volume rushes into ${his} dick. It is not easy for ${his} body to maintain an erection. But with the machine's help, ${he} can produce a full throbbing hard-on.`);
		} else {
			r.push(`It brings ${him} to a full, throbbing erection within seconds.`);
		}
		r.push(`The machine strokes ${his} dick mechanically, but very pleasurably.`);
	}
	r.push(`It does not take long for ${slave.slaveName} to reach ${his} first orgasm of many. ${His} muscles tense.`);
	if (slave.dick > 0) {
		r.push(`${His}`);
		if (slave.balls > 5 ) {
			r.push(`cum-engorged`);
		}
		r.push(`balls draw up.`);
		r.push(`${His}`);
		if (slave.dick > 8 ) {
			r.push(`gargantuan member`);
		} else if (slave.dick > 6 ) {
			r.push(`huge cock`);
		} else {
			r.push(`dick`);
		}
		r.push(`twitches and flexes within its receptacle.`);
		if (slave.balls >= 50) {
			r.push(`A special tank beneath ${him} holds ${his} monolithic balls' endless ejaculate while the machine struggles to suck it away.`);
		} else if (slave.balls >= 37) {
			r.push(`A special tank attached to the hose holds ${his} titanic balls' near endless ejaculate while the machine struggles to suck it away.`);
		} else if (slave.balls >= 25) {
			r.push(`A special reservoir attached to the hose holds ${his} massive balls' ridiculous ejaculate while the machine struggles to suck it away.`);
		} else if (slave.balls >= 10) {
			r.push(`The machine strains to suck down the giant load from ${his} huge balls.`);
		} else if (slave.balls > 5) {
			r.push(`The copious ejaculation from ${his} over-sized balls give the machine something to work on.`);
		} else if (slave.balls > 0) {
			r.push(`${His} ejaculate is quickly sucked away.`);
		} else {
			r.push(`${His} ballslessness impedes cum-production, but ejaculating feels nice, anyway.`);
		}
	}
	if (slave.dick < 1 && slave.balls > 0 && slave.prostate > 0) {
		r.push(`Cum splashes from ${his} urethra and is quickly sucked away.`);
	}
	if (slave.lactation > 0) {
		App.Events.addParagraph(node, r);
		r = [];
		r.push(`The milking cups`);
		if (slave.nipples === "fuckable" || slave.nipples === "flat") {
			r.push(`over`);
		} else {
			r.push(`on`);
		}
		r.push(`${his} nipples switch from rhythmic pulsing into intense suction. Aided by ${his} orgasm, milk spurts from ${his} nipples`);
		if (slave.boobs > 20000) {
			r.push(`in obscenely massive amounts. ${His} immense breasts seem to never empty.`);
		} else if (slave.boobs > 10000) {
			r.push(`in absurdly large amounts. ${His} gargantuan breasts do not seem to get less milk-laden for a long time.`);
		} else if (slave.boobs > 5000) {
			r.push(`in powerful jets. ${His} huge breasts can provide multiple liters of milk.`);
		} else if (slave.boobs > 1000) {
			r.push(`for quite some time. ${His} large breasts can store an impressive volume of milk.`);
		} else if (slave.boobs > 700) {
			r.push(`until there is enough for whitening a cup of coffee. ${His} average breasts cannot store much more milk.`);
		} else if (V.arcologies[0].FSSlimnessEnthusiast > 80) {
			r.push(`for a surprisingly long time. Your arcology succeeded in optimized the milking process for small breasts.`);
		} else {
			r.push(`for a short time. ${His} small tits cannot dispense much milk at once.`);
		}
	}
	App.Events.addParagraph(node, r);
	r = [];
	if (slave.prostate !== 0 && slave.dick === 0 && slave.balls === 0) {
		r.push(`${slave.slaveName}`);
		r.push(`has no cock, but a functional prostate gland. It's attached to ${his} urethra, so ${he} squirts`);
		if (slave.prostate > 2) {
			r.push(`massively`);
		} else {
			r.push(`copiously`);
		}
		r.push(`while ${he} orgasms. The exotic fluid is caught by a basin positioned under ${his}`);
		if (slave.vagina >= 0 ) {
			r.push(`dripping pussy.`);
		} else {
			r.push(`featureless crotch.`);
		}
	}
	App.Events.addParagraph(node, r);
	r = [];
	r.push(`With the first milking cycle being over, ${slave.slaveName} drifts into a relaxing slumber.`);
	if (V.dairyFeedersSetting === 1 && (slave.sexualFlaw === "cum addict" || slave.fetish === "cumslut")) {
		r.push(`${He} grins madly around the phallus ${he} stuffed in ${his} mouth.`);
	}
	if (V.dairyPregSetting > 0 && isFertile(slave) && slave.vagina > 0) {
		r.push(`${He} gets comfortable around ${his} cum-bloated belly as the impregnator continues its task.`);
	}
	if (slave.lactation > 0) {
		r.push(`The milking cups`);
		if (slave.nipples === "fuckable" || slave.nipples === "flat") {
			r.push(`over`);
		} else {
			r.push(`on`);
		}
		r.push(`${his} nipples pulse slower and with less vigor. The lactation never fully subsides. The steady but gentle suction helps increasing milk production without actually draining the breasts.`);
		slave.lactationDuration = 2;
		slave.boobs -= slave.boobsMilk;
		slave.boobsMilk = 0;
	}
	if (slave.dick > 0) {
		r.push(`The suction on ${his} dick stops, allowing ${his} abused member to go soft and have some rest.`);
	}
	if (slave.balls > 0 && slave.scrotum > 0) {
		r.push(`${His} balls rest, dangling down and relieved. They have already started to produce more cum. They seem to wait for their next chance to unload.`);
	}
	App.Events.addParagraph(node, r);
	App.Events.addParagraph(node, [`The next milking cycle will start soon.`]);
	/* MILKING ROUTINE END */
	return node;
};