code:
// this code applies RA rules onto slaves

window.DefaultRules = (function() {
	"use strict";
	let V;
	let r;
	let pronouns;
	let he;
	let him;
	let his;

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {object}
	 */
	function DefaultRules(slave) {
		if (slave.useRulesAssistant === 0) { return r; } // exempted

		V = State.variables;
		r = "";
		pronouns = getPronouns(slave);
		he = pronouns.pronoun;
		him = pronouns.object;
		his = pronouns.possessive;
		let rule = MergeRules(slave);
		if (Object.keys(rule).length === 0) { return r; } // no rules apply

		AssignJobToSlave(slave, rule);
		if (slave.fuckdoll === 0) {
			ProcessClothing(slave, rule);
			ProcessCollar(slave, rule);
			ProcessEyewear(slave, rule);
			ProcessEarwear(slave, rule);
			ProcessDildos(slave, rule);
			ProcessDickAccessories(slave, rule);
			ProcessAnalAccessories(slave, rule);
			ProcessChastity(slave, rule);
			ProcessShoes(slave, rule);
			ProcessBellyAccessories(slave, rule);
			ProcessLegAccessory(slave, rule);
		}
		ProcessBellyImplant(slave, rule);
		if (isFertile(slave) || slave.pregWeek < 0) {
			ProcessContraceptives(slave, rule);
		}
		if (slave.preg > 0 && slave.pregKnown === 1 && slave.broodmother === 0) {
			ProcessAbortions(slave, rule);
		}
		ProcessOtherDrugs(slave, rule);
		ProcessAssetGrowthDrugs(slave, rule);
		ProcessEnema(slave, rule);
		ProcessDiet(slave, rule);
		ProcessCuratives(slave, rule);
		ProcessAphrodisiacs(slave, rule);
		ProcessPenisHormones(slave, rule);
		ProcessFemaleHormones(slave, rule);
		ProcessPregnancyDrugs(slave, rule);
		if (slave.fuckdoll === 0) {
			ProcessLivingStandard(slave, rule);
			ProcessSpeech(slave, rule);
			ProcessRelationship(slave, rule);
			ProcessRelease(slave, rule);
			ProcessPunishment(slave, rule);
			ProcessReward(slave, rule);
		}
		ProcessToyHole(slave, rule);
		ProcessDietCum(slave, rule);
		ProcessDietMilk(slave, rule);
		if (V.arcologies[0].FSHedonisticDecadenceResearch === 1) {
			ProcessSolidFood(slave, rule);
		}
		ProcessTeeth(slave, rule);
		ProcessStyle(slave, rule);
		ProcessPiercings(slave, rule);
		ProcessSmartPiercings(slave, rule);
		ProcessTattoos(slave, rule);
		ProcessPornFeedEnabled(slave, rule);
		ProcessPorn(slave, rule);
		ProcessLabel(slave, rule);
		return r;
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {map}
	 */
	function MergeRules(slave) {
		// merge all rules applying on a slave into one big rule
		const rules = V.defaultRules.filter((x) => ruleAppliesP(x.condition, slave));
		slave.currentRules = rules.map((x) => x.ID);
		return mergeRules(rules.map((x) => ProcessAssignments(slave, Object.assign({}, x.set))));
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule	// not sure about this
	 * @returns {object}	// not sure about this
	 */
	function ProcessAssignments(slave, rule) {
		// Before merging rules, we process assignments for each rule separately so we can remove slaves from facilities when they no longer qualify, even if the final "winning" rule assigns them elsewhere
		// We also ignore inapplicable assignments for the current slave, so we only merge assignments that are valid
		switch (rule.setAssignment) {
			case "no default setting":
				delete rule.setAssignment;
				break;

			case "rest":
			case "please you":
				// slaves always qualify for this assignment
				break;

			case "live with your Head Girl":
				if ((V.HGSuiteSlaves < 1 && slave.indentureRestrictions <= 0)) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "be confined in the arcade":
				if ((V.arcadeSlaves < V.arcade && slave.indentureRestrictions <= 0 && (slave.breedingMark !== 1 || V.propOutcome === 0))) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "serve in the master suite":
				if ((V.masterSuiteSlaves < V.masterSuite && (slave.devotion > 20 || slave.trust < -50 || (slave.devotion >= -50 && slave.trust < -20)))) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "get treatment in the clinic":
				if ((V.clinicSlaves < V.clinic && (slave.health < 20 || (slave.chem > 15 && V.Nurse !== 0 && V.clinicUpgradeFilters === 1)) || ((slave.bellyImplant > -1) && (V.bellyImplants === 1)) || slave.preg > 1)) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "rest in the spa":
				if ((V.spaSlaves < V.spa) && (slave.health < 20) || (slave.trust < 60) || (slave.devotion <= 60) || (slave.fetish === "mindbroken") && (slave.devotion >= -20)) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "work as a nanny":
				if ((V.nurserySlaves < V.nursery) && !slave.fuckdoll && (slave.devotion > 20 || slave.trust > 20)) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "work in the brothel":
				if ((V.brothelSlaves < V.brothel && (slave.devotion > 50 || slave.trust > 50 || slave.trust < -50 || (slave.devotion >= -50 && slave.trust < -20)) && (slave.breedingMark !== 1 || V.propOutcome === 0))) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "serve in the club":
				if ((V.clubSlaves < V.club && (slave.devotion > 50 || slave.trust > 50 || slave.trust < -50 || (slave.devotion >= -50 && slave.trust < -20)) && (slave.breedingMark !== 1 || V.propOutcome === 0))) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "work in the dairy":
				if ((V.dairy > V.dairySlaves + V.bioreactorsXY + V.bioreactorsXX + V.bioreactorsHerm + V.bioreactorsBarren)) {
					if ((slave.indentureRestrictions > 0) && (V.dairyRestraintsSetting > 1)) {
						break;
					} else if (((slave.indentureRestrictions > 1) && (V.dairyRestraintsSetting > 0)) || (slave.breedingMark === 1 && V.propOutcome === 1 && V.dairyRestraintsSetting > 0) || ((V.dairyPregSetting > 0) && ((slave.bellyImplant !== -1) || (slave.broodmother !== 0)))) {
						break;
					} else {
						if ((slave.lactation > 0 || ((V.dairySlimMaintainUpgrade === 0 || V.dairySlimMaintain === 0) && (slave.boobs > 300 || slave.dick === 0 || V.dairyImplantsSetting === 1) && V.dairyImplantsSetting !== 2)) || (slave.balls > 0)) {
							if ((slave.devotion > 20) || ((slave.devotion >= -50) && (slave.trust < -20)) || (slave.trust < -50) || (slave.amp === 1) || (V.dairyRestraintsUpgrade === 1)) {
								if ((V.dairyStimulatorsSetting < 2) || (slave.anus > 2) || (V.dairyPrepUpgrade === 1)) {
									if ((V.dairyPregSetting < 2) || (slave.vagina > 2) || (slave.ovaries === 0) || (V.dairyPrepUpgrade === 1)) {
										break;
									} else {
										RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
										delete rule.setAssignment;
									}
								} else {
									RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
									delete rule.setAssignment;
								}
							} else {
								RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
								delete rule.setAssignment;
							}
						} else {
							RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
							delete rule.setAssignment;
						}
					}
				}
				break;

			case "work as a farmhand":
				if ((V.farmyardSlaves < V.farmyard && !slave.fuckdoll)) { // TODO: rework these requirements
					break;
				} else {
					RAFacilityRemove(slave, rule);
					delete rule.setAssignment;
				}
				break;

			case "work as a servant":
				if ((V.servantsQuartersSlaves < V.servantsQuarters && canSee(slave) && canWalk(slave) && (slave.devotion >= -20 || slave.trust < -20 || (slave.devotion >= -50 && slave.trust <= 20)))) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "learn in the schoolroom":
				if ((V.schoolroomSlaves < V.schoolroom && slave.fetish !== "mindbroken" && (slave.devotion >= -20 || slave.trust < -50 || (slave.devotion >= -50 && slave.trust < -20)))) {
					if ((slave.intelligenceImplant < 30) || (slave.voice !== 0 && slave.accent + V.schoolroomUpgradeLanguage > 2) || (slave.skill.oral <= 10 + V.schoolroomUpgradeSkills * 20) || (slave.skill.whoring <= 10 + V.schoolroomUpgradeSkills * 20) || (slave.skill.entertainment <= 10 + V.schoolroomUpgradeSkills * 20) || (slave.skill.anal < 10 + V.schoolroomUpgradeSkills * 20) || ((slave.vagina >= 0) && (slave.skill.vaginal < 10 + V.schoolroomUpgradeSkills * 20))) {
						break;
					} else {
						RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
						delete rule.setAssignment;
					}
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "be confined in the cellblock":
				if ((V.cellblockSlaves < V.cellblock && ((slave.devotion < -20 && slave.trust >= -20) || (slave.devotion < -50 && slave.trust >= -50)))) {
					break;
				} else {
					RAFacilityRemove(slave, rule); // before deleting rule.setAssignment
					delete rule.setAssignment;
				}
				break;

			case "take classes":
				if (slave.intelligenceImplant < 15 && slave.fetish !== "mindbroken" && (slave.devotion >= -20 || slave.trust < -50 || (slave.trust < -20 && slave.devotion >= -50))) {
					break;
				} else {
					delete rule.setAssignment;
				}
				break;

			case "choose her own job":
				if ((slave.fetish !== "mindbroken")) {
					break;
				} else {
					delete rule.setAssignment;
				}
				break;

			case "get milked":
				if ((slave.lactation > 0 || slave.balls > 0)) {
					break;
				} else {
					delete rule.setAssignment;
				}
				break;

			case "be a servant":
				if ((canWalk(slave) && canSee(slave) && (slave.devotion >= -20 || slave.trust < -50 || (slave.trust < -20 && slave.devotion >= -50)))) {
					break;
				} else {
					delete rule.setAssignment;
				}
				break;

			case "work a glory hole":
				if (slave.indentureRestrictions <= 0 && (slave.breedingMark !== 1 || V.propOutcome === 0)) {
					break;
				} else {
					delete rule.setAssignment;
				}
				break;

			case "whore":
			case "serve the public":
			case "stay confined":
				if ((slave.fuckdoll === 0) && (slave.breedingMark !== 1 || V.propOutcome === 0)) {
					break;
				} else {
					delete rule.setAssignment;
				}
				break;

			default:
				r += `<span class="red">raWidgets missing case for assignment 'V.{rule.setAssignment}'</span>.`;
				break;
		}
		return rule;
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function AssignJobToSlave(slave, rule) {
		// place slave on assignment defined by the rule
		if ((rule.setAssignment !== undefined && rule.setAssignment !== "no default setting")) {
			if (((rule.setAssignment === "choose her own job" && !slave.choosesOwnAssignment) || rule.setAssignment !== slave.assignment)) {
				switch (rule.setAssignment) {
					case "live with your Head Girl":
						r += `<br>${slave.slaveName} has been automatically assigned to live in your Head Girl's private suite.`;
						break;
					case "be confined in the arcade":
						r += `<br>${slave.slaveName} has been automatically assigned to be confined in ${V.arcadeName}.`;
						break;
					case "serve in the master suite":
						r += `<br>${slave.slaveName} has been automatically assigned to ${V.masterSuiteName}.`;
						break;
					case "get treatment in the clinic":
						r += `<br>${slave.slaveName} has been automatically assigned to get treatment in ${V.clinicName}.`;
						break;
					case "rest in the spa":
						r += `<br>${slave.slaveName} has been automatically assigned to rest in ${V.spaName}.`;
						break;
					case "work as a nanny":
						r += `<br>${slave.slaveName} has been automatically assigned to work in ${V.nurseryName}.`;
						break;
					case "work in the brothel":
						r += `<br>${slave.slaveName} has been automatically assigned to work in ${V.brothelName}.`;
						break;
					case "serve in the club":
						r += `<br>${slave.slaveName} has been automatically assigned to serve in ${V.clubName}.`;
						break;
					case "work in the dairy":
						r += `<br>${slave.slaveName} has been automatically assigned to be milked in ${V.dairyName}.`;
						break;
					case "work as a farmhand":
						r += `<br>${slave.slaveName} has been automatically assigned to work in ${V.farmyardName}.`;
						break;
					case "work as a servant":
						r += `<br>${slave.slaveName} has been automatically assigned to work in ${V.servantsQuartersName}.`;
						break;
					case "learn in the schoolroom":
						r += `<br>${slave.slaveName} has been automatically assigned to study in ${V.schoolroomName}.`;
						break;
					case "be confined in the cellblock":
						r += `<br>${slave.slaveName} has been automatically assigned to be confined in ${V.cellblockName}.`;
						break;
					case "choose her own job":
						r += `<br>${slave.slaveName} is now allowed to select ${his} own assignments.`;
						break;
					default:
						r += `<br>${slave.slaveName} has been automatically assigned to ${rule.setAssignment}.`;
						break;
				}
				assignJob(slave, rule.setAssignment);
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessClothing(slave, rule) {
		// apply clothes to slave
		if ((rule.clothes !== undefined) && (rule.clothes !== "no default setting")) {
			if ((rule.clothes === "choosing her own clothes")) {
				if ((slave.choosesOwnClothes === 0)) {
					slave.clothes = "choosing her own clothes";
					slave.choosesOwnClothes = 1;
					r += `<br>${slave.slaveName} is now allowed to choose ${his} own clothes.`;
				}
			} else if ((slave.clothes !== rule.clothes)) {
				slave.clothes = rule.clothes;
				slave.choosesOwnClothes = 0;
				r += `<br>${slave.slaveName} is now wearing ${slave.clothes}.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessCollar(slave, rule) {
		// apply collar to slave
		if ((rule.collar !== undefined) && (rule.collar !== "no default setting")) {
			if ((slave.collar !== rule.collar)) {
				r += "<br>";
				if (rule.collar === "preg biometrics" && slave.preg <= -1 && slave.ovaries === 0 && slave.mpreg === 0) {
					slave.collar = "none";
					r += `${slave.slaveName} cannot utilize preg biometrics. `;
				} else if ((rule.collar === "massive dildo gag" && slave.skill.oral <= 50)) {
					slave.collar = "none";
					r += `${slave.slaveName} lacks the oral skill to successfully keep the massive dildo gag in ${his} throat. `;
				} else {
					slave.collar = rule.collar;
				}
				if ((slave.collar === "none")) {
					r += `${slave.slaveName} has been given no collar.`;
				} else if ((slave.collar === "pretty jewelry")) {
					r += `${slave.slaveName} has been given ${slave.collar}.`;
				} else if ((["ball gag", "bell collar", "bit gag", "bowtie", "dildo gag", "massive dildo gag", "neck corset", "porcelain mask"].includes(slave.collar))) {
					r += `${slave.slaveName} has been given a ${slave.collar}.`;
				} else {
					r += `${slave.slaveName} has been given a ${slave.collar} collar.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessEyewear(slave, rule) {
		// apply glasses, contacts to slave
		if ((rule.eyewear !== undefined) && (rule.eyewear !== "no default setting")) {
			switch (rule.eyewear) {
				case "correct with glasses":
					if (slave.eyes === -1) {
						if (slave.eyewear !== "corrective glasses") {
							slave.eyewear = "corrective glasses";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given corrective glasses.`;
						}
					} else {
						if (slave.eyewear !== "none") {
							slave.eyewear = "none";
							r += `<br>${slave.slaveName}'s eyewear has been removed.`;
						}
					}
					break;

				case "correct with contacts":
					if (slave.eyes === -1) {
						if (slave.eyewear !== "corrective contacts") {
							slave.eyewear = "corrective contacts";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given corrective contacts.`;
						}
					} else {
						if (slave.eyewear !== "none") {
							slave.eyewear = "none";
							r += `<br>${slave.slaveName}'s eyewear has been removed.`;
						}
					}
					break;

				case "blur with glasses":
					if (slave.eyes > -1) {
						if (slave.eyewear !== "blurring glasses") {
							slave.eyewear = "blurring glasses";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given blurring glasses.`;
						}
					} else {
						if (slave.eyewear !== "none") {
							slave.eyewear = "none";
							r += `<br>${slave.slaveName}'s eyewear has been removed.`;
						}
					}
					break;

				case "blur with contacts":
					if (slave.eyes > -1) {
						if (slave.eyewear !== "blurring contacts") {
							slave.eyewear = "blurring contacts";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given blurring contacts.`;
						}
					} else {
						if (slave.eyewear !== "none") {
							slave.eyewear = "none";
							r += `<br>${slave.slaveName}'s eyewear has been removed.`;
						}
					}
					break;

				case "universal glasses":
					if (slave.eyes === -1) {
						if (slave.eyewear !== "corrective glasses") {
							slave.eyewear = "corrective glasses";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given corrective glasses.`;
						}
					} else {
						if (slave.eyewear !== "glasses") {
							slave.eyewear = "glasses";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given decorative glasses.`;
						}
					}
					break;

				default:
					if (slave.eyewear !== "none") {
						slave.eyewear = "none";
						r += `<br>${slave.slaveName}'s eyewear has been removed.`;
					}
					break;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessEarwear(slave, rule) {
		// apply earplugs to slave
		if ((rule.earwear !== undefined) && (rule.earwear !== "no default setting")) {
			switch (rule.earwear) {
				case "correct with hearing aids":
					if (slave.hears === -1) {
						if (slave.earwear !== "hearing aids") {
							slave.earwear = "hearing aids";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given hearing aids.`;
						}
					} else {
						if (slave.earwear !== "none") {
							slave.earwear = "none";
							r += `<br>${slave.slaveName}'s earwear has been removed.`;
						}
					}
					break;

				case "muffle with ear plugs":
					if (slave.hears > -1) {
						if (slave.earwear !== "muffling ear plugs") {
							slave.earwear = "muffling ear plugs";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given muffling ear plugs.`;
						}
					} else {
						if (slave.earwear !== "none") {
							slave.earwear = "none";
							r += `<br>${slave.slaveName}'s earwear has been removed.`;
						}
					}
					break;

				case "deafen with ear plugs":
					if (slave.hears > -2) {
						if (slave.earwear !== "deafening ear plugs") {
							slave.earwear = "deafening ear plugs";
							cashX(forceNeg(V.modCost), "slaveMod", slave);
							r += `<br>${slave.slaveName} has been given deafening ear plugs.`;
						}
					} else {
						if (slave.earwear !== "none") {
							slave.earwear = "none";
							r += `<br>${slave.slaveName}'s earwear has been removed.`;
						}
					}
					break;

				default:
					if (slave.earwear !== "none") {
						slave.earwear = "none";
						r += `<br>${slave.slaveName}'s earwear has been removed.`;
					}
					break;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessDildos(slave, rule) {
		// apply vaginal dildos to slave
		if (slave.vagina === 0) {
			ProcessVVirginDildos(slave, rule);
		} else if ((slave.vagina > 0) && (slave.anus === 0)) {
			ProcessAVirginDildos(slave, rule);
		} else if (slave.vagina > 0) {
			ProcessNonVirginDildos(slave, rule);
			ProcessVaginalAttachments(slave, rule);
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessVVirginDildos(slave, rule) {
		// apply vaginal dildos to vaginal virgins
		if ((rule.virginAccessory !== undefined) && (rule.virginAccessory !== "no default setting")) {
			if (slave.vaginalAccessory !== rule.virginAccessory) {
				slave.vaginalAccessory = rule.virginAccessory;
				switch (slave.vaginalAccessory) {
					case "huge dildo":
						r += `<br>${slave.slaveName} is a virgin and has been given a `;
						if (slave.vagina >= 2) {
							r += `massive dildo to permanently gape ${his} cunt.`;
						} else {
							r += `large dildo for ${his} pussy, since it must be stretched before it can accommodate a huge one.`;
							slave.vaginalAccessory = "large dildo";
						}
						break;

					case "long dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so the virgin ${slave.slaveName} has been given a standard length dildo for ${his} pussy.`;
							slave.vaginalAccessory = "dildo";
						}
						break;

					case "long, large dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so the virgin ${slave.slaveName} has been given a standard length large dildo for ${his} pussy.`;
							slave.vaginalAccessory = "large dildo";
						}
						break;

					case "long, huge dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so the virgin ${slave.slaveName} has been given a standard length huge dildo for ${his} pussy.`;
							slave.vaginalAccessory = "huge dildo";
						} else {
							r += `<br>${slave.slaveName} is a virgin and has been given a `;
							if (slave.vagina >= 2) {
								r += `massive and oversized dildo to permanently gape ${his} cunt.`;
							} else {
								r += `long, large dildo for ${his} pussy, since it must be stretched before it can accommodate a huge one.`;
								slave.vaginalAccessory = "long, large dildo";
							}
						}
						break;

					case "none":
						r += `<br>${slave.slaveName} is a virgin and has been instructed not to use a vaginal accessory.`;
						break;

					default:
						r += `<br>${slave.slaveName} is a virgin and has been given a ${slave.vaginalAccessory} for ${his} pussy.`;
						break;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessAVirginDildos(slave, rule) {
		// apply vaginal dildos to anal virgins
		if ((rule.aVirginAccessory !== undefined) && (rule.aVirginAccessory !== "no default setting")) {
			if (slave.vaginalAccessory !== rule.aVirginAccessory) {
				slave.vaginalAccessory = rule.aVirginAccessory;
				switch (slave.vaginalAccessory) {
					case "huge dildo":
						r += `<br>${slave.slaveName} is a virgin and has been given a `;
						if (slave.vagina >= 2) {
							r += `massive dildo to permanently gape ${his} cunt.`;
						} else {
							r += `large dildo for ${his} pussy, since it must be stretched before it can accommodate a huge one.`;
							slave.vaginalAccessory = "large dildo";
						}
						break;

					case "long dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so the virgin ${slave.slaveName} has been given a standard length dildo for ${his} pussy.`;
							slave.vaginalAccessory = "dildo";
						}
						break;

					case "long, large dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so the virgin ${slave.slaveName} has been given a standard length large dildo for ${his} pussy.`;
							slave.vaginalAccessory = "large dildo";
						}
						break;

					case "long, huge dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so the virgin ${slave.slaveName} has been given a standard length huge dildo for ${his} pussy.`;
							slave.vaginalAccessory = "huge dildo";
						} else {
							r += `<br>${slave.slaveName} is a virgin and has been given a `;
							if (slave.vagina >= 2) {
								r += `massive and oversized dildo to permanently gape ${his} cunt.`;
							} else {
								r += `long, large dildo for ${his} pussy, since it must be stretched before it can accommodate a huge one.`;
								slave.vaginalAccessory = "long, large dildo";
							}
						}
						break;

					case "none":
						r += `<br>${slave.slaveName} is a virgin and has been instructed not to use a vaginal accessory.`;
						break;

					default:
						r += `<br>${slave.slaveName} is a virgin and has been given a ${slave.vaginalAccessory} for ${his} pussy.`;
						break;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessNonVirginDildos(slave, rule) {
		// apply vaginal dildos to non-virgins
		if ((rule.vaginalAccessory !== undefined) && (rule.vaginalAccessory !== "no default setting")) {
			if (slave.vaginalAccessory !== rule.vaginalAccessory) {
				slave.vaginalAccessory = rule.vaginalAccessory;
				switch (slave.vaginalAccessory) {
					case "huge dildo":
						r += `<br>${slave.slaveName} has been given a `;
						if (slave.vagina >= 2) {
							r += `massive dildo to permanently gape ${his} cunt.`;
						} else {
							r += `large dildo for ${his} pussy, since it must be stretched before it can accommodate a huge one.`;
							slave.vaginalAccessory = "large dildo";
						}
						break;

					case "long dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so ${slave.slaveName} has been given a standard length dildo for ${his} pussy.`;
							slave.vaginalAccessory = "dildo";
						}
						break;

					case "long, large dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so ${slave.slaveName} has been given a standard length large dildo for ${his} pussy.`;
							slave.vaginalAccessory = "large dildo";
						}
						break;

					case "long, huge dildo":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of cervix penetrating dildos on marked slaves, so ${slave.slaveName} has been given a standard length huge dildo for ${his} pussy.`;
							slave.vaginalAccessory = "huge dildo";
						} else {
							r += `<br>${slave.slaveName} has been given a `;
							if (slave.vagina >= 2) {
								r += `massive and oversized dildo to permanently gape ${his} cunt.`;
							} else {
								r += `long, large dildo for ${his} pussy, since it must be stretched before it can accommodate a huge one.`;
								slave.vaginalAccessory = "long, large dildo";
							}
						}
						break;
					case "none":
						r += `<br>${slave.slaveName} has been instructed not to use a vaginal accessory.`;
						break;

					default:
						r += `<br>${slave.slaveName} has been given a ${slave.vaginalAccessory} for ${his} pussy.`;
						break;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessVaginalAttachments(slave, rule) {
		// apply vaginal accessories to slaves
		if (slave.vaginalAccessory === "none" && slave.vaginalAttachment === "vibrator") {
			slave.vaginalAttachment = "none"; // clears dildo attachment when dildos are removed above
		} else if ((rule.vaginalAttachment !== undefined) && (rule.vaginalAttachment !== "no default setting")) {
			if ((slave.vaginalAttachment !== rule.vaginalAttachment)) {
				slave.vaginalAttachment = rule.vaginalAttachment;
				if (slave.vaginalAccessory !== "none") {
					switch (slave.vaginalAttachment) {
						case "none":
							r += `<br>${slave.slaveName} has been instructed not to use an attachment for ${his} dildo.`;
							break;

						case "vibrator":
							r += `<br>${slave.slaveName}'s dildo has been replaced with a vibrating model.`;
							break;

						default:
							r += `<br>${slave.slaveName} has been given a ${slave.vaginalAttachment}.`;
							break;
					}
				} else {
					switch (slave.vaginalAttachment) {
						case "none":
							r += `<br>${slave.slaveName} has been instructed not to use any vaginal accessories.`;
							break;

						default:
							r += `<br>${slave.slaveName} has been given a ${slave.vaginalAttachment}.`;
							break;
					}
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessDickAccessories(slave, rule) {
		// apply dick accessories to slave
		if ((slave.dick > 0)) {
			if (slave.anus === 0) {
				if ((rule.aVirginDickAccessory !== undefined) && (rule.aVirginDickAccessory !== "no default setting")) {
					if ((slave.dickAccessory !== rule.aVirginDickAccessory)) {
						slave.dickAccessory = rule.aVirginDickAccessory;
						if (slave.dickAccessory === "none") {
							r += `<br>${slave.slaveName} is a virgin and has been instructed not to wear a dick accessory.`;
						} else {
							r += `<br>${slave.slaveName} is a virgin and has been given a ${slave.dickAccessory} accessory for ${his} cock.`;
						}
					}
				}
			} else {
				if ((rule.dickAccessory !== undefined) && (rule.dickAccessory !== "no default setting")) {
					if ((slave.dickAccessory !== rule.dickAccessory)) {
						slave.dickAccessory = rule.dickAccessory;
						if (slave.dickAccessory === "none") {
							r += `<br>${slave.slaveName} has been instructed not to wear a dick accessory.`;
						} else {
							r += `<br>${slave.slaveName} has been given a ${slave.dickAccessory} accessory for ${his} cock.`;
						}
					}
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessChastity(slave, rule) {
		// apply chastity to slave
		if ((rule.chastityVagina !== undefined) && (rule.chastityVagina !== "no default setting")) {
			if (slave.vagina > -1) {
				if ((slave.chastityVagina !== rule.chastityVagina)) {
					slave.chastityVagina = rule.chastityVagina;
					if (rule.chastityVagina === 1) {
						r += `<br>${slave.slaveName} has been given a chastity belt to wear.`;
					} else {
						r += `<br>${slave.slaveName}'s vaginal chastity has been removed.`;
					}
				}
			}
		}
		if ((rule.chastityPenis !== undefined) && (rule.chastityPenis !== "no default setting")) {
			if (slave.dick > 0) {
				if ((slave.chastityPenis !== rule.chastityPenis)) {
					slave.chastityPenis = rule.chastityPenis;
					if (rule.chastityPenis === 1) {
						r += `<br>${slave.slaveName} has been given a chastity cage to wear.`;
					} else {
						r += `<br>${slave.slaveName}'s chastity cage has been removed.`;
					}
				}
			}
		}
		if ((rule.chastityAnus !== undefined) && (rule.chastityAnus !== "no default setting")) {
			if ((slave.chastityAnus !== rule.chastityAnus)) {
				slave.chastityAnus = rule.chastityAnus;
				if (rule.chastityAnus === 1) {
					r += `<br>${slave.slaveName} has been given anal chastity to wear.`;
				} else {
					r += `<br>${slave.slaveName}'s anal chastity has been removed.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessShoes(slave, rule) {
		// apply shoes to slave
		if ((rule.shoes !== undefined) && (rule.shoes !== "no default setting")) {
			if ((slave.shoes !== rule.shoes)) {
				if ((slave.amp !== 1)) {
					slave.shoes = rule.shoes;
					r += `<br>${slave.slaveName}'s shoes have been set to ${slave.shoes}.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessBellyAccessories(slave, rule) {
		// apply belly accessories to slave
		if ((rule.bellyAccessory !== undefined) && (rule.bellyAccessory !== "no default setting")) {
			if ((slave.bellyAccessory !== rule.bellyAccessory)) {
				if ((slave.belly >= 1500 || slave.weight >= 130) && setup.fakeBellies.includes(rule.bellyAccessory)) {
					r += `<br>${slave.slaveName}'s natural belly is too big to properly wear an empathy belly.`;
					slave.bellyAccessory = "none";
				} else {
					slave.bellyAccessory = rule.bellyAccessory;
					if (slave.bellyAccessory === "none") {
						r += `<br>${slave.slaveName} has been instructed not to wear a torso accessory.`;
					} else {
						r += `<br>${slave.slaveName} has been given ${slave.bellyAccessory} to wear.`;
					}
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessLegAccessory(slave, rule) {
		if (rule.legAccessory !== undefined && rule.legAccessory !== "no default setting" && slave.amp !== 1 && slave.legAccessory !== rule.legAccessory) {
			slave.legAccessory = rule.legAccessory;
			r += `<br>${slave.slaveName}'s leg accessory was set to ${rule.legAccessory}.`;
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessAnalAccessories(slave, rule) {
		// apply buttplugs and buttplug accessories to slave
		if (slave.chastityAnus !== 1) {
			if (slave.anus === 0) {
				ProcessAnalVirginButtplugs(slave, rule);
			} else {
				ProcessNonVirginButtplugs(slave, rule);
			}
		}
		ProcessButtplugAttachments(slave, rule);
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessAnalVirginButtplugs(slave, rule) {
		// apply buttplugs to virgins
		if ((rule.aVirginButtplug !== undefined) && (rule.aVirginButtplug !== "no default setting")) {
			if ((slave.buttplug !== rule.aVirginButtplug)) {
				slave.buttplug = rule.aVirginButtplug;
				switch (slave.buttplug) {
					case "huge plug":
						r += `<br>${slave.slaveName} is an anal virgin and has been given a `;
						if ((slave.anus >= 2)) {
							r += `massive plug to permanently gape ${his} asshole.`;
						} else {
							slave.buttplug = "large plug";
							r += `large buttplug for ${his} asshole, since it must be stretched before it can accommodate a huge one.`;
						}
						break;

					case "long plug":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of anal plugs that can damage a growing fetus on marked slaves, so the anal virgin ${slave.slaveName} has been given a standard length plug for ${his} anus.`;
							slave.buttplug = "plug";
						}
						break;

					case "long, large plug":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of anal plugs that can damage a growing fetus on marked slaves, so the anal virgin ${slave.slaveName} has been given a standard length large plug for ${his} anus.`;
							slave.buttplug = "large plug";
						}
						break;

					case "long, huge plug":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of anal plugs that can damage a growing fetus on marked slaves, so the anal virgin ${slave.slaveName} has been given a standard length huge plug for ${his} anus.`;
							slave.buttplug = "huge plug";
						} else {
							r += `<br>${slave.slaveName} is an anal virgin and has been given a `;
							if (slave.anus >= 2) {
								r += `massive and oversized plug to permanently gape ${his} asshole.`;
							} else {
								r += `long, large buttplug for ${his} asshole, since it must be stretched before it can accommodate a huge one.`;
								slave.buttplug = "long, large plug";
							}
						}
						break;

					case "none":
						r += `<br>${slave.slaveName} is an anal virgin and has been instructed not to use an anal accessory.`;
						break;

					default:
						r += `<br>${slave.slaveName} is an anal virgin and has been given a ${slave.buttplug} for ${his} asshole.`;
						break;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessNonVirginButtplugs(slave, rule) {
		// apply buttplugs to non-virgins
		if ((rule.buttplug !== undefined) && (rule.buttplug !== "no default setting")) {
			if ((slave.buttplug !== rule.buttplug)) {
				slave.buttplug = rule.buttplug;
				switch (slave.buttplug) {
					case "huge plug":
						r += `<br>${slave.slaveName} has been given a `;
						if ((slave.anus >= 2)) {
							r += `massive plug to permanently gape ${his} asshole.`;
						} else {
							slave.buttplug = "large plug";
							r += `large buttplug for ${his} asshole, since it must be stretched before it can accommodate a huge one.`;
						}
						break;

					case "long plug":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of anal plugs that can damage a growing fetus on marked slaves, so ${slave.slaveName} has been given a standard length plug for ${his} anus.`;
							slave.buttplug = "plug";
						}
						break;

					case "long, large plug":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of anal plugs that can damage a growing fetus on marked slaves, so ${slave.slaveName} has been given a standard length large plug for ${his} anus.`;
							slave.buttplug = "large plug";
						}
						break;

					case "long, huge plug":
						if (slave.breedingMark === 1 && V.propOutcome === 1) {
							r += `<br>Breeding regulations forbid the use of anal plugs that can damage a growing fetus on marked slaves, so ${slave.slaveName} has been given a standard length huge plug for ${his} anus.`;
							slave.buttplug = "huge plug";
						} else {
							r += `<br>${slave.slaveName} has been given a `;
							if (slave.anus >= 2) {
								r += `massive and oversized plug to permanently gape ${his} asshole.`;
							} else {
								r += `long, large buttplug for ${his} asshole, since it must be stretched before it can accommodate a huge one.`;
								slave.buttplug = "long, large plug";
							}
						}
						break;

					case "none":
						r += `<br>${slave.slaveName} has been instructed not to use an anal accessory.`;
						break;

					default:
						r += `<br>${slave.slaveName} has been given a ${slave.buttplug} for ${his} asshole.`;
						break;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessButtplugAttachments(slave, rule) {
		// apply buttplug accessories to slaves
		if (slave.buttplug === "none" && slave.buttplugAttachment !== "none") {
			slave.buttplugAttachment = "none"; // clears buttplug attachments when buttplugs are removed above
		} else if ((rule.buttplugAttachment !== undefined) && (rule.buttplugAttachment !== "no default setting")) {
			if ((slave.buttplugAttachment !== rule.buttplugAttachment)) {
				slave.buttplugAttachment = rule.buttplugAttachment;
				switch (slave.buttplugAttachment) {
					case "none":
						r += `<br>${slave.slaveName} has been instructed not to use an attachment for ${his} anal accessory.`;
						break;

					default:
						r += `<br>${slave.slaveName} has been given a ${slave.buttplugAttachment} to attach to ${his} buttplug.`;
						break;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessBellyImplant(slave, rule) {
		// Here is belly implant size control, it's used in Surgery Degradation passage to setup devotion and trust changes.
		// silent calls to surgery degradation have been replaced with a js function, which is less hacky
		if ((rule.bellyImplantVol !== undefined) && slave.bellyImplant >= 0 && rule.bellyImplantVol >= 0) {
			r += "<br>";
			if (slave.health > -10) {
				let diff = rule.bellyImplantVol - slave.bellyImplant;
				if (diff >= 5000 && slave.bellyPain === 0 && slave.health > 50) {
					r += `${slave.slaveName}'s belly is way too small, so ${he} has been directed to have intensive belly implant filling procedures throughout this week.`;
					slave.bellyImplant += 1000;
					slave.bellyPain += 2;
					BellySurgery(slave, diff);
				} else if (diff >= 500 && slave.bellyPain < 2) {
					r += `${slave.slaveName}'s belly has not reached the desired size, so ${he} has been directed to have belly implant filling procedures throughout this week.`;
					slave.bellyImplant += 500;
					slave.bellyPain += 1;
					BellySurgery(slave, diff);
				} else if (diff <= -5000) {
					r += `${slave.slaveName}'s belly is way too big, so ${he} has been directed to have intensive belly implant draining procedures throughout this week.`;
					slave.bellyImplant -= 1000;
					BellySurgery(slave, diff);
				} else if (diff <= -500) {
					r += `${slave.slaveName}'s belly is too big, so ${he} has been directed to have belly implant draining procedures throughout this week.`;
					slave.bellyImplant -= 500;
					BellySurgery(slave, diff);
				}
			} else {
				r += `${slave.slaveName} is not healthy enough to safely adjust ${his} belly implant.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} volume
	 */
	function BellySurgery(slave, volume) {
		// this is a port of the belly implant portion of surgeryDegradation.tw
		// that way, we don't have to use ugly hacks
		// the original still exists, and may be worth replacing
		if (volume > 0) { // bellyUp
			SetBellySize(slave);
			if (slave.bellyPain === 1) {
				if (slave.devotion > 50) {
					slave.devotion += 4;
				} else if (slave.devotion >= -20) {
					slave.trust -= 5;
				} else {
					slave.trust -= 10;
					slave.devotion -= 5;
				}
			} else if (slave.bellyPain === 2) {
				if (slave.devotion > 50) {
					slave.devotion += 2;
				} else if (slave.devotion >= -20) {
					slave.trust -= 7;
				} else {
					slave.trust -= 12;
					slave.devotion -= 7;
				}
			}
		} else { // bellyDown
			if (slave.bellyImplant < 0) {
				slave.bellyImplant = 0;
			}
			SetBellySize(slave);
			if (slave.devotion > 50) {
				slave.devotion += 3;
				slave.trust += 3;
			} else if (slave.devotion >= -20) {
				slave.trust += 2;
			} else {
				slave.devotion += 1;
				slave.trust -= 10;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessContraceptives(slave, rule) {
		if ((rule.preg !== undefined) && (rule.preg !== "no default setting")) {
			if (rule.preg === true && slave.preg === 0) {
				r += `<br>${slave.slaveName} is being given contraceptives.`;
				slave.preg = -1;
			} else if (slave.preg === -1 && rule.preg === false) {
				r += `<br>${slave.slaveName} is no longer being put on contraceptives.`;
				slave.preg = 0;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessAbortions(slave, rule) {
		if ((rule.abortion !== undefined) && (rule.abortion !== "no default setting")) {
			if (rule.abortion === "all") {
				if (slave.preg < 4 || (slave.fetish === "mindbroken" || slave.fuckdoll !== 0)) {
					r += `<br>${slave.slaveName}'s pregnancy has been terminated.`;
				} else {
					r += `<br>${slave.slaveName}'s pregnancy has been terminated; `;
					if (slave.sexualFlaw === "breeder") {
						r += `it broke ${his} mind.`;
						slave.fetish = "mindbroken", slave.behavioralQuirk = "none", slave.behavioralFlaw = "none", slave.sexualQuirk = "none", slave.sexualFlaw = "none", slave.devotion = 0, slave.trust = 0;
					} else if (slave.devotion < -50) {
						r += `${he} did not handle it well.`;
						slave.trust -= 10, slave.devotion -= 25;
					} else if (slave.devotion < -20) {
						r += `${he} did not handle it well.`;
						slave.trust -= 10, slave.devotion -= 10;
					} else if (slave.fetish === "pregnancy") {
						r += `${he} did not handle it well.`;
						let fetishModifier = (slave.fetishStrength / 2);
						slave.devotion -= (1 * fetishModifier), (slave.trust -= 1 * fetishModifier);
					} else if (slave.devotion <= 20) {
						r += `${he} did not handle it well.`;
						slave.trust -= 10, slave.devotion -= 5;
					} else if (slave.devotion <= 50) {
						r += `${he} did not handle it well.`;
						slave.trust -= 10;
					} else {
						r += "it had little mental effect.";
					}
				}

				if (lastPregRule(slave, V.defaultRules)) {
					slave.preg = -1;
				} else {
					slave.preg = 0;
				}
				if (slave.abortionTat > -1) {
					slave.abortionTat++, cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
				}
				V.reservedChildren = FetusGlobalReserveCount("incubator");
				V.reservedChildrenNursery = FetusGlobalReserveCount("nursery");
				slave.pregType = 0, slave.pregSource = 0, slave.pregKnown = 0, slave.pregWeek = -2;
				WombFlush(slave);
			} else if (rule.abortion === "male") {
				if (slave.preg < 4) {
					let WL = slave.womb.length;
					for (let index = 0; index < WL; index++) {
						if (slave.womb[index].genetics.gender === "XY") {
							WombRemoveFetus(slave, index);
							index--;
							WL--;
						}
					}
					if (WL === 0) {
						slave.pregType = 0, slave.pregSource = 0, slave.pregKnown = 0, slave.pregWeek = -2;
						WombFlush(slave);
					}
					r += `<br>${slave.slaveName}'s male fetuses have been terminated.`;
				}
			} else if (rule.abortion === "female") {
				if (slave.preg < 4) {
					let WL = slave.womb.length;
					for (let index = 0; index < WL; index++) {
						if (slave.womb[index].genetics.gender === "XX") {
							WombRemoveFetus(slave, index);
							index--;
							WL--;
						}
					}
					if (WL === 0) {
						slave.pregType = 0, slave.pregSource = 0, slave.pregKnown = 0, slave.pregWeek = -2;
						WombFlush(slave);
					}
					r += `<br>${slave.slaveName}'s female fetuses have been terminated.`;
				}
			}
			SetBellySize(slave);
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessAssetGrowthDrugs(slave, rule) {
		// Asset Growth
		const growthDrugs = new Set(["breast injections", "breast redistributors", "butt injections", "butt redistributors", "hyper breast injections", "hyper butt injections", "hyper penis enhancement", "hyper testicle enhancement", "intensive breast injections", "intensive butt injections", "intensive penis enhancement", "intensive testicle enhancement", "lip atrophiers", "lip injections", "penis atrophiers", "penis enhancement", "testicle atrophiers", "testicle enhancement"]);
		if ((slave.drugs === "super fertility drugs" || slave.drugs === "fertility drugs") && isFertile(slave)) {
			r += `<br>${slave.slaveName} is on ${slave.drugs} and will not be considered for drug enhancement until that regime is complete.`;
			return;
		} else if ((rule.growth_boobs === "no default setting" && rule.growth_butt === "no default setting" && rule.growth_lips === "no default setting" && rule.growth_dick === "no default setting" && rule.growth_dick === "no default setting" && rule.growth_balls === "no default setting")) {
			return;
		}
		if (rule.hyper_drugs !== 1) { // More resource intensive version with prioritizing.
			let _priorities = [];
			if (rule.growth_boobs !== "no default setting") {
				let _priority;
				if (slave.boobs < rule.growth_boobs) {
					_priority = {drug: "breast injections", weight: (rule.growth_boobs - slave.boobs) / rule.growth_boobs};
					_priorities.push(_priority);
				} else if ((slave.boobs > parseInt(rule.growth_boobs) + 200) && slave.weight < 100 && (V.arcologies[0].FSSlimnessEnthusiastResearch === 1)) {
					_priority = {drug: "breast redistributors", weight: (1 + ((slave.boobs - slave.boobsImplant - slave.boobsMilk - rule.growth_boobs) / rule.growth_boobs))};
					_priorities.push(_priority);
				}
			}
			if (rule.growth_butt !== "no default setting") {
				let _priority;
				if (slave.butt < rule.growth_butt) {
					_priority = {drug: "butt injections", weight: (rule.growth_butt - slave.butt) / rule.growth_butt};
					_priorities.push(_priority);
				} else if ((Math.trunc(slave.butt) > rule.growth_butt) && slave.weight < 100 && (V.arcologies[0].FSSlimnessEnthusiastResearch === 1)) {
					_priority = {drug: "butt redistributors", weight: (1 + ((slave.butt - slave.buttImplant - rule.growth_butt) / rule.growth_butt))};
					_priorities.push(_priority);
				}
			}
			if (rule.growth_lips !== "no default setting") {
				let _priority;
				if (slave.lips < rule.growth_lips) {
					_priority = {drug: "lip injections", weight: (rule.growth_lips - slave.lips) / rule.growth_lips};
					_priorities.push(_priority);
				} else if ((slave.lips > rule.growth_lips) && (V.arcologies[0].FSSlimnessEnthusiastResearch === 1)) {
					_priority = {drug: "lip atrophiers", weight: (1 + ((slave.lips - slave.lipsImplant - rule.growth_lips) / rule.growth_lips))};
					_priorities.push(_priority);
				}
			}
			if (rule.growth_dick !== "no default setting" && slave.dick) {
				let _priority;
				if (slave.dick < rule.growth_dick) {
					_priority = {drug: "penis enhancement", weight: (rule.growth_dick - slave.dick) / rule.growth_dick};
					_priorities.push(_priority);
				} else if ((slave.dick > rule.growth_dick) && (V.arcologies[0].FSSlimnessEnthusiastResearch === 1)) {
					_priority = {drug: "penis atrophiers", weight: (1 + ((slave.dick - rule.growth_dick) / rule.growth_dick))};
					_priorities.push(_priority);
				}
			}
			if (rule.growth_balls !== "no default setting" && slave.balls) {
				let _priority;
				if (slave.balls < rule.growth_balls) {
					_priority = {drug: "testicle enhancement", weight: (rule.growth_balls - slave.balls) / rule.growth_balls};
					_priorities.push(_priority);
				} else if ((slave.balls > rule.growth_balls) && (V.arcologies[0].FSSlimnessEnthusiastResearch === 1)) {
					_priority = {drug: "testicle atrophiers", weight: (1 + ((slave.balls - rule.growth_balls) / rule.growth_balls))};
					_priorities.push(_priority);
				}
			}
			if (_priorities.length > 1) {
				_priorities = _priorities.sort(function(a, b) {
					if (a.weight > b.weight) {
						return -1;
					}
					if (a.weight < b.weight) {
						return 1;
					}
					return 0;
				});
				if (slave.drugs !== _priorities[0].drug) {
					slave.drugs = _priorities[0].drug;
					r += `<br>${slave.slaveName} has been put on `;
					if (rule.growth_intensity && slave.drugs !== "lip injections" && slave.health > 0) {
						slave.drugs = `intensive ${slave.drugs}`;
						r += `${slave.drugs}, since ${he}'s healthy enough to take them, and `;
					} else {
						r += `${slave.drugs}, since `;
					}
					r += `that part of ${his} body is `;
					if (!isNaN(_priorities[0].weight)) {
						r += `${Math.trunc(_priorities[0].weight*100)}% `;
					}
					if (_priorities[0].weight < 1) {
						r += "below ";
					} else {
						r += "above ";
					}
					r += "the targeted size.";
				}
			} else if (_priorities.length > 0) {
				if (slave.drugs !== _priorities[0].drug) {
					slave.drugs = _priorities[0].drug;
					r += `<br>${slave.slaveName} has been put on `;
					if (rule.growth_intensity && slave.drugs !== "lip injections" && slave.health > 0) {
						slave.drugs = `intensive ${slave.drugs}`;
						r += `${slave.drugs}, since ${he}'s healthy enough to take them, and `;
					} else {
						r += `${slave.drugs}, since `;
					}
					r += `that is the only part of ${his} body that does not meet the targeted size.`;
				}
			} else if (growthDrugs.has(slave.drugs)) {
				slave.drugs = "no drugs";
				r += `<br>${slave.slaveName}'s body has met all relevant growth targets, so ${his} pharmaceutical regime has been ended.`;
			}
		} else {
			if (rule.growth_boobs !== "no default setting") {
				if (slave.boobs < rule.growth_boobs) {
					if (slave.drugs !== "hyper breast injections") {
						slave.drugs = "hyper breast injections";
						r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
					}
					return;
				}
			}
			if (rule.growth_butt !== "no default setting") {
				if (slave.butt < rule.growth_butt) {
					if (slave.drugs !== "hyper butt injections") {
						slave.drugs = "hyper butt injections";
						r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
					}
					return;
				}
			}
			if (rule.growth_lips !== "no default setting") {
				if (slave.lips < rule.growth_lips) {
					if (slave.drugs !== "lip injections") {
						slave.drugs = "lip injections";
						r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
					}
					return;
				}
			}
			if (rule.growth_dick !== "no default setting" && slave.dick) {
				if (slave.dick < rule.growth_dick) {
					if (slave.drugs !== "hyper penis enhancement") {
						slave.drugs = "hyper penis enhancement";
						r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
					}
					return;
				}
			}
			if (rule.growth_balls !== "no default setting" && slave.balls) {
				if (slave.balls < rule.growth_balls) {
					if (slave.drugs !== "hyper testicle enhancement") {
						slave.drugs = "hyper testicle enhancement";
						r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
					}
					return;
				}
			}
			if (V.arcologies[0].FSSlimnessEnthusiastResearch === 1) {
				if (rule.growth_boobs !== "no default setting") {
					if (slave.boobs - slave.boobsImplant - slave.boobsMilk > parseInt(rule.growth_boobs) + 200 && slave.weight < 100) {
						if (slave.drugs !== "breast redistributors") {
							slave.drugs = "breast redistributors";
							r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
						}
						return;
					}
				}
				if (rule.growth_butt !== "no default setting") {
					if (Math.trunc(slave.butt - slave.buttImplant) > rule.growth_butt && slave.weight < 100) {
						if (slave.drugs !== "butt redistributors") {
							slave.drugs = "butt redistributors";
							r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
						}
						return;
					}
				}
				if (rule.growth_lips !== "no default setting") {
					if (slave.lips - slave.lipsImplant > rule.growth_lips) {
						if (slave.drugs !== "lip atrophiers") {
							slave.drugs = "lip atrophiers";
							r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
						}
						return;
					}
				}
				if (rule.growth_dick !== "no default setting" && slave.dick) {
					if (slave.dick > rule.growth_dick) {
						if (slave.drugs !== "penis atrophiers") {
							slave.drugs = "penis atrophiers";
							r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
						}
						return;
					}
				}
				if (rule.growth_balls !== "no default setting" && slave.balls) {
					if (slave.balls > rule.growth_balls) {
						if (slave.drugs !== "testicle atrophiers") {
							slave.drugs = "testicle atrophiers";
							r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
						}
						return;
					}
				}
			}
			if (growthDrugs.has(slave.drugs)) {
				slave.drugs = "no drugs";
				r += `<br>${slave.slaveName} has met all relevant growth targets, so ${his} pharmaceutical regime has been ended.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessOtherDrugs(slave, rule) {
		// Other Drugs
		if (slave.indentureRestrictions < 2 && rule.drug !== "no default setting" && slave.drugs !== rule.drug) {
			let flag = true;
			switch (rule.drug) {
				case "anti-aging cream":
					if (slave.visualAge < 18) {
						flag = false;
					}
					break;

				case "growth stimulants":
					if (!(slave.height < 274 && slave.height < Math.clamp((Height.mean(slave) * 1.25), 0, 274))) {
						flag = false;
					}
					break;

				case "sag-B-gone":
					if (!(slave.boobs > 250 && slave.boobShape !== "saggy")) {
						flag = false;
					}
					break;

				case "female hormone injections":
					if (!((slave.breedingMark !== 1 || V.propOutcome === 0) && (slave.ovaries === 1 || slave.mpreg === 1) && slave.pubertyXX === 0)) {
						flag = false;
					}
					break;

				case "male hormone injections":
					if (!((slave.breedingMark !== 1 || V.propOutcome === 0) && slave.balls > 0 && slave.pubertyXY === 0)) {
						flag = false;
					}
					break;

				case "psychosuppressants":
					if (!(slave.intelligence > -100 && slave.indentureRestrictions < 1)) {
						flag = false;
					}
					break;

				case "breast injections":
					if (!(slave.boobs < 48000)) {
						flag = false;
					}
					break;

				case "hyper breast injections":
					if (!(slave.boobs < 48000)) {
						flag = false;
					}
					break;

				case "breast redistributors":
					if (!(slave.boobs - slave.boobsImplant > 100)) {
						flag = false;
					}
					break;

				case "butt injections":
					if (!(slave.butt < 9)) {
						flag = false;
					}
					break;

				case "hyper butt injections":
					if (!(slave.butt < 20)) {
						flag = false;
					}
					break;

				case "nipple atrophiers":
					if (!(["cute", "huge", "puffy"].includes(slave.nipples))) {
						flag = false;
					}
					break;

				case "butt redistributors":
					if (!(slave.buttImplant > 0)) {
						flag = false;
					}
					break;

				case "lip injections":
					if (!(slave.lips <= 95 || (slave.lips <= 85 && V.seeExtreme !== 1))) {
						flag = false;
					}
					break;

				case "lip atrophiers":
					if (!(slave.lips - slave.lipsImplant > 0)) {
						flag = false;
					}
					break;

				case "super fertility drugs":
					if (!(slave.indentureRestrictions < 1 && (slave.breedingMark !== 1 || V.propOutcome === 0))) {
						flag = false;
					}
					break;

				case "penis enhancement":
					if (!((slave.dick > 0 && slave.dick < 10) || slave.clit < 5)) {
						flag = false;
					}
					break;

				case "hyper penis enhancement":
					if (!((slave.dick > 0 && slave.dick < 31) || slave.clit < 5)) {
						flag = false;
					}
					break;

				case "penis atrophiers":
					if (!(slave.dick > 1)) {
						flag = false;
					}
					break;

				case "testicle enhancement":
					if (!(slave.balls > 0)) {
						flag = false;
					}
					break;

				case "hyper testicle enhancement":
					if (!(slave.balls > 0)) {
						flag = false;
					}
					break;

				case "testicle atrophiers":
					if (!(slave.balls > 1)) {
						flag = false;
					}
					break;

				case "clitoris atrophiers":
					if (!(slave.clit > 0)) {
						flag = false;
					}
					break;

				case "labia atrophiers":
					if (!(slave.labia > 0)) {
						flag = false;
					}
					break;

				case "appetite suppressors":
					if (!(slave.weight <= -95)) {
						flag = false;
					}
					break;

				case "priapism agents":
					if (slave.dick === 0 || slave.dick > 10 || slave.chastityPenis === 1 || (canAchieveErection(slave) && slave.drugs !== "priapism agents")) {
						flag = false;
					}
					break;
			}
			if (flag) {
				slave.drugs = rule.drug;
				r += `<br>${slave.slaveName} has been put on ${slave.drugs}.`;
			} else {
				slave.drugs = "no drugs";
				r += `<br>${slave.slaveName} cannot benefit from ${his} assigned drug and has been defaulted to ${slave.drugs}`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessEnema(slave, rule) {
		if ((rule.inflationType !== undefined) && (rule.inflationType !== "no default setting")) {
			if (slave.inflationType !== rule.inflationType) {
				if ((slave.inflationType === "curative" && slave.health > 90) || (slave.inflationType === "tightener" && slave.anus <= 1 && slave.vagina <= 1)) {
					r += `<br>${slave.slaveName} cannot benefit from ${his} assigned enema and has been defaulted to none.`;
					slave.inflation = 0;
					slave.inflationType = "none";
					slave.inflationMethod = 0;
					slave.milkSource = 0;
					slave.cumSource = 0;
					SetBellySize(slave);
				} else if ((rule.inflationType === "curative" && slave.health > 90) || (rule.inflationType === "tightener" && slave.anus <= 1 && slave.vagina <= 1)) {
					// empty block
				} else {
					r += `<br>${slave.slaveName}'s current enema regimen has been set to ${rule.inflationType}.`;
					slave.inflation = 1;
					slave.inflationType = rule.inflationType;
					slave.inflationMethod = 2;
					slave.milkSource = 0;
					slave.cumSource = 0;
					SetBellySize(slave);
				}
			}
			if (slave.inflationType !== "none" && slave.inflation > 1 && slave.health < -50) {
				r += `<br>${slave.slaveName}'s current enema regimen risks death, so it has been reduced to a less threatening level.`;
				slave.inflation = 1;
				SetBellySize(slave);
			} else if (slave.inflation > 1 && (slave.bellyPreg >= 1500 || slave.bellyImplant >= 1500)) {
				r += `<br>${slave.slaveName}'s current enema is too much for ${his} body, so it has been reduced.`;
				slave.inflation = 1;
				SetBellySize(slave);
			} else if (slave.inflationType === "none") {
				slave.inflation = 0;
				slave.inflationMethod = 0;
				slave.milkSource = 0;
				slave.cumSource = 0;
				SetBellySize(slave);
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessDiet(slave, rule) {
		// Diet Setting
		if (rule.diet !== undefined && rule.diet !== "no default setting") {
			/*
			if ((slave.boobs >= 1600) && (slave.muscles <= 5) && (slave.amp !== 1) && ((rule.muscles == "no default setting") || (rule.muscles === 0))) {
				if ((slave.diet !== "muscle building")) {
					slave.diet = "muscle building"
					r += `<br>${slave.slaveName} has big tits and no back muscles, so ${he}'s been assigned to gain some.`
				}
			} else if ((slave.boobs >= 1600) && (slave.muscles > 5) && (slave.diet == "muscle building") && ((rule.muscles == "no default setting") || (rule.muscles === 0))) {
			*/
			if (rule.diet === "healthy" && slave.diet !== "healthy") {
				slave.diet = "healthy";
				r += `<br>${slave.slaveName} has been assigned to a healthy diet.`;
			} else if ((slave.boobs >= 1600) && (slave.muscles > 5) && (slave.diet === "muscle building") && ((rule.muscles === "no default setting") || (rule.muscles === 0))) {
				slave.diet = "healthy";
				r += `<br>${slave.slaveName} has huge boobs, but ${he} already has the back muscles to bear them, so ${he}'s been assigned to stop working out so hard.`;
			} else if ((rule.dietGrowthSupport === 1) && ((slave.drugs === "breast injections") || (slave.drugs === "butt injections")) && (slave.weight <= 95)) {
				if (slave.diet !== "fattening") {
					slave.diet = "fattening";
					r += `<br>${slave.slaveName} is on drugs designed to expand major body parts, so ${he}'s been put on a fattening diet to provide ${his} body as much fuel for growth as possible.`;
				}
			} else {
				if (!(isNaN(rule.diet))) {
					if ((slave.weight - rule.diet) > 5) {
						if ((slave.diet !== "restricted")) {
							slave.diet = "restricted";
							r += `<br>${slave.slaveName} is too fat so ${his} diet has been set to restricted.`;
						}
					} else if ((slave.weight - rule.diet) < -5) {
						if ((slave.diet !== "fattening")) {
							slave.diet = "fattening";
							r += `<br>${slave.slaveName} is too skinny so ${his} diet has been set to fattening.`;
						}
					} else if ((rule.muscles !== undefined) && (rule.muscles !== "no default setting") && (slave.amp !== 1)) {
						if ((slave.muscles >= rule.muscles + 8)) {
							if ((slave.diet !== "slimming")) {
								slave.diet = "slimming";
								r += `<br>${slave.slaveName} has been put on a slimming exercise regime.`;
							}
						} else if ((slave.muscles <= rule.muscles - 2)) {
							if ((slave.diet !== "muscle building")) {
								slave.diet = "muscle building";
								r += `<br>${slave.slaveName} has been put on a muscle building exercise regime.`;
							}
						} else {
							if ((slave.diet !== "healthy")) {
								slave.diet = "healthy";
								r += `<br>${slave.slaveName} is at the target weight, so ${his} diet has been normalized.`;
							}
						}
					} else {
						if ((slave.diet !== "healthy")) {
							slave.diet = "healthy";
							r += `<br>${slave.slaveName} is at the target weight, so ${his} diet has been normalized.`;
						}
					}
				} else if ((rule.diet === "attractive")) {
					if (((slave.weight > 95) || ((slave.weight > 30) && (slave.hips < 2)))) {
						if ((slave.diet !== "restricted")) {
							slave.diet = "restricted";
							r += `<br>${slave.slaveName} is too fat so ${his} diet has been set to restricted.`;
						}
					} else if (((slave.weight < -95) || ((slave.weight < -30) && (slave.hips > -2)))) {
						if ((slave.diet !== "fattening")) {
							slave.diet = "fattening";
							r += `<br>${slave.slaveName} is too skinny so ${his} diet has been set to fattening.`;
						}
					} else if ((rule.muscles !== undefined) && (rule.muscles !== "no default setting") && (slave.amp !== 1)) {
						if ((slave.muscles >= rule.muscles + 8)) {
							if ((slave.diet !== "slimming")) {
								slave.diet = "slimming";
								r += `<br>${slave.slaveName} has been put on a slimming exercise regime.`;
							}
						} else if ((slave.muscles <= rule.muscles - 2)) {
							if ((slave.diet !== "muscle building")) {
								slave.diet = "muscle building";
								r += `<br>${slave.slaveName} has been put on a muscle building exercise regime.`;
							}
						} else {
							if ((slave.diet !== "healthy")) {
								slave.diet = "healthy";
								r += `<br>${slave.slaveName} is at the target weight, so ${his} diet has been normalized.`;
							}
						}
					} else {
						if ((slave.diet !== "healthy")) {
							slave.diet = "healthy";
							r += `<br>${slave.slaveName} is at the target weight, so ${his} diet has been normalized.`;
						}
					}
				} else if ((rule.diet === "XX")) {
					if ((slave.diet !== "XX")) {
						slave.diet = "XX";
						r += `<br>${slave.slaveName} has been put on a diet that favors feminine development.`;
					}
				} else if ((rule.diet === "XY")) {
					if ((slave.diet !== "XY")) {
						slave.diet = "XY";
						r += `<br>${slave.slaveName} has been put on a diet that favors masculine development.`;
					}
				} else if ((rule.diet === "XXY")) {
					if (slave.balls > 0 && (slave.ovaries === 1 || slave.mpreg === 1)) {
						if ((slave.diet !== "XXY")) {
							slave.diet = "XXY";
							r += `<br>${slave.slaveName} has been put on a diet that enhances a herm's unique sexuality.`;
						}
					} else {
						if ((slave.diet !== "healthy")) {
							slave.diet = "healthy";
							r += `<br>${slave.slaveName} has been put on a standard diet since ${he} is not a hermaphrodite.`;
						}
					}
				} else if ((rule.diet === "cleansing")) {
					if ((slave.diet !== "cleansing") && (slave.health < 90 || slave.chem >= 10)) {
						slave.diet = "cleansing";
						r += `<br>${slave.slaveName} has been put on a diet of cleansers.`;
					}
				} else if ((rule.diet === "fertility")) {
					if (isFertile(slave) && slave.preg === 0) {
						if ((slave.diet !== "fertility")) {
							slave.diet = "fertility";
							r += `<br>${slave.slaveName} has been put on a diet to enhance fertility.`;
						}
					} else {
						if ((slave.diet !== "healthy")) {
							slave.diet = "healthy";
							if (slave.pregKnown === 0 && slave.preg > 0) {
								r += `<br>${slave.slaveName} has been put on a standard diet since tests reveal ${he} has become pregnant.`;
								slave.pregKnown = 1;
							} else {
								r += `<br>${slave.slaveName} has been put on a standard diet since ${he} is currently unable to become pregnant.`;
							}
						}
					}
				} else if ((rule.diet === "cum production")) {
					if ((slave.balls > 0)) {
						if ((slave.diet !== "cum production")) {
							slave.diet = "cum production";
							r += `<br>${slave.slaveName} has been put on a diet to promote cum production.`;
						}
					} else {
						if ((slave.diet !== "healthy")) {
							slave.diet = "healthy";
							r += `<br>${slave.slaveName} has been put on a standard diet since ${he} is no longer able to produce cum.`;
						}
					}
				}
			}
		} else if ((rule.muscles !== undefined) && (rule.muscles !== "no default setting") && (slave.amp !== 1)) { // no diet rule, muscles only
			if ((slave.muscles >= rule.muscles + 8)) {
				if ((slave.diet !== "slimming")) {
					slave.diet = "slimming";
					r += `<br>${slave.slaveName} has been put on a slimming exercise regime.`;
				}
			} else if ((slave.muscles <= rule.muscles - 2)) {
				if ((slave.diet !== "muscle building")) {
					slave.diet = "muscle building";
					r += `<br>${slave.slaveName} has been put on a muscle building exercise regime.`;
				}
			} else {
				if ((slave.diet !== "healthy")) {
					slave.diet = "healthy";
					r += `<br>${slave.slaveName} has achieved the target musculature, so ${his} exercise regime has been normalized.`;
				}
			}
		}

		if (slave.drugs === "appetite suppressors" && slave.diet !== "restricted") {
			slave.drugs = "no drugs";
			r += `<br>${slave.slaveName} no longer needs to lose weight, so ${he}'s no longer being given appetite suppressors.`;
		} else if (slave.diet === "restricted" && V.arcologies[0].FSSlimnessEnthusiastResearch === 1 && (slave.drugs === "no drugs" || slave.drugs === "none")) {
			slave.drugs = "appetite suppressors";
			r += `<br>${slave.slaveName} needs to lose weight so ${he} will be given weight loss pills.`;
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessCuratives(slave, rule) {
		if ((rule.curatives !== undefined) && (rule.curatives !== "no default setting")) {
			if (slave.curatives !== rule.curatives) {
				if (rule.curatives === 2) {
					if (slave.health > 100) {
						if ((slave.curatives !== 1)) {
							r += `<br>${slave.slaveName} has been put on preventatives, since curatives cannot improve ${his} health further.`;
							slave.curatives = 1;
						}
					} else {
						r += `<br>${slave.slaveName} has been put on curatives.`;
						slave.curatives = rule.curatives;
					}
				} else {
					r += `<br>${slave.slaveName} has been ${rule.curatives > 0 ? "put on preventatives" : "taken off health drugs"}`;
					slave.curatives = rule.curatives;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessAphrodisiacs(slave, rule) {
		if ((rule.aphrodisiacs !== undefined) && (rule.aphrodisiacs !== "no default setting")) {
			if (slave.aphrodisiacs !== rule.aphrodisiacs) {
				r += `<br>${slave.slaveName} has been ${rule.aphrodisiacs > 0 ? "put on the proper" : "taken off"} aphrodisiacs.`;
				slave.aphrodisiacs = rule.aphrodisiacs;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessPenisHormones(slave, rule) {
		if ((slave.dick > 0)) {
			if ((slave.balls === 0)) {
				if ((rule.gelding !== undefined) && (rule.gelding !== "no default setting")) {
					if ((slave.hormones !== rule.gelding)) {
						const _oldHormones = slave.hormones;
						slave.hormones = rule.gelding;
						if (slave.indentureRestrictions >= 2) {
							slave.hormones = Math.clamp(slave.hormones, -1, 1);
						}
						if (slave.hormones !== _oldHormones) {
							r += `<br>${slave.slaveName} is a gelding, so ${he} has been put on the appropriate hormonal regime.`;
						}
					}
				}
			} else if ((slave.balls > 0)) {
				if ((rule.XY !== undefined) && (rule.XY !== "no default setting")) {
					if ((slave.hormones !== rule.XY)) {
						if ((slave.assignment !== "recruit girls")) {
							if ((slave.assignment !== "be the Wardeness")) {
								if ((slave.assignment !== "be the Madam")) {
									const _oldHormones = slave.hormones;
									slave.hormones = rule.XY;
									if (slave.indentureRestrictions >= 2) {
										slave.hormones = Math.clamp(slave.hormones, -1, 1);
									}
									if (slave.hormones !== _oldHormones) {
										r += `<br>${slave.slaveName} is a shemale, so ${he} has been put on the appropriate hormonal regime.`;
									}
								}
							}
						}
					}
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessFemaleHormones(slave, rule) {
		if ((slave.vagina > -1) && (slave.dick === 0) && (rule.XX !== undefined) && (rule.XX !== "no default setting")) {
			if ((slave.hormones !== rule.XX)) {
				const _oldHormones = slave.hormones;
				slave.hormones = rule.XX;
				if (slave.indentureRestrictions >= 2) {
					slave.hormones = Math.clamp(slave.hormones, -1, 1);
				}
				if (slave.hormones !== _oldHormones) {
					r += `<br>${slave.slaveName} is a female, so ${he} has been put on the appropriate hormonal regime.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessPregnancyDrugs(slave, rule) {
		if (slave.pregKnown === 1 && rule.pregSpeed !== "no default setting" && (slave.breedingMark !== 1 || V.propOutcome === 0) && slave.indentureRestrictions < 1 && slave.broodmother === 0) {
			if (rule.pregSpeed === "slow" && slave.preg < slave.pregData.minLiveBirth) {
				slave.pregControl = "slow gestation";
				r += `<br>${slave.slaveName} is pregnant, so ${he} has been put on the gestation slowing agents.`;
			} else if (rule.pregSpeed === "fast" && slave.preg < slave.pregData.minLiveBirth && slave.health > -50) {
				slave.pregControl = "speed up";
				r += `<br>${slave.slaveName} is pregnant, so ${he} has been put on rapid gestation agents. CAUTION! Can be dangerous. Clinic supervision is recommended.`;
			} else if (rule.pregSpeed === "suppress" && slave.preg >= slave.pregData.minLiveBirth && slave.health > -50) {
				slave.pregControl = "labor suppressors";
				r += `<br>${slave.slaveName} is ready to birth, so ${he} has been put on labor suppressing agents.`;
			} else if (rule.pregSpeed === "stimulate" && slave.preg > slave.pregData.minLiveBirth && slave.health > -50) {
				slave.labor = 1;
				slave.induce = 1;
				V.birthee = 1;
				r += `<br>${slave.slaveName} is ready to birth, so ${his} labor has been stimulated.`;
			} else if (rule.pregSpeed === "fast" && slave.pregControl === "speed up" && slave.health <= -50) {
				slave.pregControl = "none";
				r += `<br>${slave.slaveName} is on rapid gestation agents and dangerously unhealthy, so ${his} agent regimen has been stopped.`;
			} else if (rule.pregSpeed === "suppress" && slave.pregControl === "labor suppressors" && slave.health <= -50) {
				slave.pregControl = "none";
				r += `<br>${slave.slaveName} is on labor suppression agents and unhealthy, so ${his} agent regimen has been stopped.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessLivingStandard(slave, rule) {
		if ((rule.livingRules !== undefined) && (rule.livingRules !== "no default setting")) {
			if (setup.facilityCareers.includes(slave.assignment)) {
				r += ""; // `<br>${slave.slaveName}'s living standards are controlled by ${his} assignment.`;
			} else if (((slave.assignment === "be your Head Girl") && (V.HGSuite === 1)) || ((slave.assignment === "guard you") && (V.dojo > 1))) {
				r += `<br>${slave.slaveName} has a private room.`;
			} else if ((slave.fetish === "mindbroken")) {
				if ((slave.livingRules !== "spare")) {
					slave.livingRules = "spare";
					r += `<br>Since ${slave.slaveName} is mindbroken, ${his} living standard has been set to spare.`;
				}
			} else if (slave.livingRules !== rule.livingRules) {
				if (rule.livingRules !== "luxurious") {
					if (V.roomsPopulation <= V.rooms - 0.5) {
						slave.livingRules = rule.livingRules;
						r += `<br>${slave.slaveName}'s living standard has been set to ${rule.livingRules}.`;
						if (slave.relationship >= 4) {
							V.roomsPopulation += 0.5;
						} else {
							V.roomsPopulation += 1;
						}
					} else {
						slave.livingRules = "normal";
						r += `<br>${slave.slaveName}'s living standard has been set to normal, since there is no room for ${him} to occupy.`;
					}
				} else {
					slave.livingRules = rule.livingRules;
					r += `<br>${slave.slaveName}'s living standard has been set to ${rule.livingRules}.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessSpeech(slave, rule) {
		if ((rule.speechRules !== undefined) && (rule.speechRules !== "no default setting") && (slave.speechRules !== rule.speechRules)) {
			if (slave.fetish === "mindbroken") {
				if ((slave.speechRules !== "restrictive")) {
					slave.speechRules = "restrictive";
					r += `<br>Since ${slave.slaveName} is mindbroken, ${his} speech rules have been set to restrictive.`;
				}
			} else if (slave.accent === 4) {
				if (rule.speechRules === "accent elimination" && slave.speechRules !== "language lessons") {
					slave.speechRules = "language lessons";
					r += `<br>Since ${slave.slaveName} does not know how to talk, ${his} speech rules have been set to language learning.`;
				} else {
					slave.speechRules = "restrictive";
					r += `<br>Since ${slave.slaveName} does not know how to talk, ${his} speech rules have been set to restrictive.`;
				}
			} else if (rule.speechRules === "accent elimination") {
				if (slave.accent > 0) {
					slave.speechRules = "accent elimination";
					r += `<br>${slave.slaveName}'s speech rules have been set to ${rule.speechRules}.`;
				} else {
					slave.speechRules = "restrictive";
					r += `<br>Since ${slave.slaveName} has no accent, ${his} speech rules have been set to restrictive.`;
				}
			} else if (slave.speechRules !== rule.speechRules) {
				slave.speechRules = rule.speechRules;
				r += `<br>${slave.slaveName}'s speech rules have been set to ${rule.speechRules}.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessRelationship(slave, rule) {
		if ((slave.fetish !== "mindbroken")) {
			if ((rule.relationshipRules !== undefined) && (rule.relationshipRules !== "no default setting")) {
				if ((slave.relationshipRules !== rule.relationshipRules)) {
					slave.relationshipRules = rule.relationshipRules;
					r += `<br>${slave.slaveName}'s relationship rules have been set to ${rule.relationshipRules}.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessRelease(slave, rule) {
		if ((rule.releaseRules !== undefined) && (rule.releaseRules !== "no default setting")) {
			let _release = 0;
			if (rule.releaseRules === "restrictive" &&
				!(["be a subordinate slave", "be confined in the arcade", "be your Head Girl", "get milked", "please you", "serve in the club", "serve in the master suite", "serve the public", "whore", "work a glory hole", "work as a farmhand", "work in the brothel", "work in the dairy"].contains(slave.assignment))) {
				_release = 1;
			} else {
				_release = 1;
			}
			if ((slave.fetish === "mindbroken") && (slave.releaseRules !== "permissive")) {
				slave.releaseRules = "permissive";
				r += `<br>Since ${slave.slaveName} is mindbroken, ${his} masturbation rules have been set to permissive.`;
			} else if ((slave.amp === 1 || slave.fuckdoll > 0) && (slave.releaseRules === "masturbation")) {
				slave.releaseRules = "restrictive";
				r += `<br>Since ${slave.slaveName} is unable to masturbate, ${his} masturbation rules have been set to restrictive.`;
			} else if ((_release !== 0) && (slave.releaseRules !== rule.releaseRules)) {
				slave.releaseRules = rule.releaseRules;
				r += `<br>${slave.slaveName}'s masturbation rules have been set to ${rule.releaseRules}.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessPunishment(slave, rule) {
		if ((rule.standardPunishment !== undefined) && (rule.standardPunishment !== "no default setting")) {
			if ((slave.standardPunishment !== rule.standardPunishment)) {
				slave.standardPunishment = rule.standardPunishment;
				r += `<br>${slave.slaveName}'s typical punishment has been updated to ${rule.standardPunishment}.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessReward(slave, rule) {
		if ((rule.standardReward !== undefined) && (rule.standardReward !== "no default setting")) {
			if ((slave.standardReward !== rule.standardReward)) {
				slave.standardReward = rule.standardReward;
				r += `<br>${slave.slaveName}'s typical reward has been updated to ${rule.standardReward}.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessToyHole(slave, rule) {
		if ((rule.toyHole !== undefined) && (rule.toyHole !== "no default setting")) {
			if (rule.toyHole === "pussy") {
				if (slave.vagina > 0 && canDoVaginal(slave)) {
					slave.toyHole = rule.toyHole;
					r += `<br>${slave.slaveName} has been instructed to use ${his} ${rule.toyHole} to please you.`;
				} else if (slave.toyHole !== "all her holes") {
					slave.toyHole = "all her holes";
					r += `<br>${slave.slaveName}'s hole preference has defaulted to all ${his} holes.`;
				}
			} else if (rule.toyHole === "ass") {
				if (slave.anus > 0 && canDoAnal(slave)) {
					slave.toyHole = rule.toyHole;
					r += `<br>${slave.slaveName} has been instructed to use ${his} ${rule.toyHole} to please you.`;
				} else if (slave.toyHole !== "all her holes") {
					slave.toyHole = "all her holes";
					r += `<br>${slave.slaveName}'s hole preference has defaulted to all ${his} holes.`;
				}
			} else if (rule.toyHole === "dick") {
				if (slave.dick > 0 && canPenetrate(slave)) {
					slave.toyHole = rule.toyHole;
					r += `<br>${slave.slaveName} has been instructed to use ${his} ${rule.toyHole} to please you.`;
				} else if (slave.toyHole !== "all her holes") {
					slave.toyHole = "all her holes";
					r += `<br>${slave.slaveName}'s hole preference has defaulted to all ${his} holes.`;
				}
			} else if ((slave.toyHole !== rule.toyHole)) {
				slave.toyHole = rule.toyHole;
				r += `<br>${slave.slaveName} has been instructed to use ${his} ${rule.toyHole} to please you.`;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessDietCum(slave, rule) {
		if ((rule.dietCum !== undefined) && (rule.dietCum !== "no default setting")) {
			if (slave.dietCum !== rule.dietCum) {
				slave.dietCum = rule.dietCum;
				if (slave.dietCum === 2) {
					r += `<br>${slave.slaveName} has been put on a diet based on cum.`;
					slave.dietMilk = 0;
				} else if (slave.dietCum === 1) {
					r += `<br>${slave.slaveName} has had cum added to ${his} diet.`;
				} else {
					r += `<br>${slave.slaveName} has had cum removed from ${his} diet.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessDietMilk(slave, rule) {
		if ((rule.dietMilk !== undefined) && (rule.dietMilk !== "no default setting")) {
			if (slave.dietMilk !== rule.dietMilk) {
				slave.dietMilk = rule.dietMilk;
				if (slave.dietMilk === 2) {
					r += `<br>${slave.slaveName} has been put on a diet based on human milk.`;
					slave.dietCum = 0;
				} else if (slave.dietMilk === 1) {
					r += `<br>${slave.slaveName} has had human milk added to ${his} diet.`;
				} else {
					r += `<br>${slave.slaveName} has had human milk removed from ${his} diet.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessSolidFood(slave, rule) {
		if ((rule.onDiet !== undefined) && (rule.onDiet !== "no default setting")) {
			if ((slave.onDiet !== rule.onDiet)) {
				slave.onDiet = rule.onDiet;
				if (slave.onDiet === 1) {
					r += `<br>${slave.slaveName} is not permitted to eat the solid slave food.`;
				} else {
					r += `<br>${slave.slaveName} is permitted to eat the solid slave food.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessTeeth(slave, rule) {
		if ((rule.teeth !== undefined) && (rule.teeth !== "no default setting")) {
			if ((rule.teeth === "universal")) {
				if ((slave.teeth === "crooked")) {
					slave.teeth = "straightening braces";
					cashX(forceNeg(V.modCost), "slaveSurgery", slave);
					r += `<br>${slave.slaveName} has been given braces for ${his} crooked teeth.`;
				} else if (slave.teeth === "gapped") {
					slave.teeth = "straightening braces";
					cashX(forceNeg(V.modCost), "slaveSurgery", slave);
					r += `<br>${slave.slaveName} has been given braces to close the gap in ${his} teeth.`;
				} else if ((slave.teeth === "normal")) {
					slave.teeth = "cosmetic braces";
					cashX(forceNeg(V.modCost), "slaveSurgery", slave);
					r += `<br>${slave.slaveName} has been given cosmetic braces.`;
				}
			} else if ((rule.teeth === "straighten")) {
				if ((slave.teeth === "crooked")) {
					slave.teeth = "straightening braces";
					cashX(forceNeg(V.modCost), "slaveSurgery", slave);
					r += `<br>${slave.slaveName} has been given braces for ${his} crooked teeth.`;
				} else if (slave.teeth === "gapped") {
					slave.teeth = "straightening braces";
					cashX(forceNeg(V.modCost), "slaveSurgery", slave);
					r += `<br>${slave.slaveName} has been given braces to close the gap in ${his} teeth.`;
				} else if ((slave.teeth === "cosmetic braces")) {
					slave.teeth = "normal";
					r += `<br>${slave.slaveName} has had ${his} braces removed, since ${his} teeth are straight.`;
				}
			} else if ((rule.teeth === "none")) {
				if ((slave.teeth === "straightening braces")) {
					slave.teeth = "crooked";
					r += `<br>${slave.slaveName} has had ${his} braces removed.`;
				} else if ((slave.teeth === "cosmetic braces")) {
					slave.teeth = "normal";
					r += `<br>${slave.slaveName} has had ${his} braces removed.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessStyle(slave, rule) {
		if (rule.eyeColor !== undefined && (rule.eyeColor !== "no default setting")) {
			if ((slave.eyeColor !== rule.eyeColor)) {
				slave.eyeColor = rule.eyeColor;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName} has been given ${slave.eyeColor} contact lenses.`;
			}
		}

		if (rule.makeup !== undefined && (rule.makeup !== "no default setting")) {
			if ((slave.makeup !== rule.makeup)) {
				slave.makeup = rule.makeup;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName} has been assigned the standard makeup.`;
			}
		}

		if ((slave.amp !== 1)) {
			if (rule.nails !== undefined && (rule.nails !== "no default setting")) {
				if ((slave.nails !== rule.nails)) {
					slave.nails = rule.nails;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName} has been assigned the standard nails.`;
				}
			}
		}

		if (rule.hColor !== undefined && (rule.hColor !== "no default setting")) {
			if (slave.bald !== 1) {
				if ((slave.hColor !== rule.hColor)) {
					slave.hColor = rule.hColor;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s hair has been dyed ${rule.hColor}.`;
				}
			}
		}

		if (rule.hStyle !== undefined && (rule.hStyle !== "no default setting")) {
			if (slave.bald !== 1) {
				if ((slave.hStyle !== rule.hStyle)) {
					slave.hStyle = rule.hStyle;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					if ((rule.hStyle === "shaved")) {
						slave.hLength = 0;
						r += `<br>${slave.slaveName}'s hair has been shaved.`;
					} else {
						r += `<br>${slave.slaveName}'s hair has been restyled.`;
					}
				}
			}
		}

		if (rule.hLength !== undefined && (rule.hLength !== "no default setting")) {
			if (slave.bald !== 1) {
				if ((slave.hLength !== rule.hLength)) {
					if ((slave.hLength > rule.hLength)) {
						cashX(forceNeg(V.modCost), "slaveMod", slave);
						r += `<br>${slave.slaveName}'s hair has been cut; it `;
					} else {
						cashX(forceNeg(V.modCost * Math.trunc((rule.hLength - slave.hLength) / 10)), "slaveMod", slave);
						r += `<br>${slave.slaveName} has been given extensions; ${his} hair `;
					}
					r += `is now ${lengthToEitherUnit(rule.hLength)} long.`;
					slave.hLength = rule.hLength;
				}
			}
		}

		if (rule.haircuts !== undefined && (rule.haircuts !== "no default setting")) {
			if (slave.bald !== 1) {
				if (rule.haircuts === 1 && slave.haircuts !== 1) {
					r += `<br>${slave.slaveName}'s hair will now be maintained at ${lengthToEitherUnit(slave.hLength)} long.`;
					slave.haircuts = 1;
				} else if (rule.haircuts === 0 && slave.haircuts !== 0) {
					r += `<br>${slave.slaveName}'s hair length will no longer be maintained.`;
					slave.haircuts = 0;
				}
			}
		}

		if (rule.eyebrowHColor !== undefined && (rule.eyebrowHColor !== "no default setting")) {
			if (slave.eyebrowHStyle !== "bald" && slave.eyebrowHStyle !== "hairless") {
				if ((slave.eyebrowHColor !== rule.eyebrowHColor)) {
					slave.eyebrowHColor = rule.eyebrowHColor;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrow hair, if present, has been dyed ${rule.eyebrowHColor}.`;
				}
			}
		}

		if (rule.eyebrowHStyle !== undefined && (rule.eyebrowHStyle !== "no default setting")) {
			if (slave.eyebrowHStyle !== "bald" && slave.eyebrowHStyle !== "hairless") {
				if ((slave.eyebrowHStyle !== rule.eyebrowHStyle)) {
					slave.eyebrowHStyle = rule.eyebrowHStyle;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrow hair has been restyled; they are now ${rule.eyebrowHStyle}.`;
				}
			}
		}

		if (rule.eyebrowFullness !== undefined && (rule.eyebrowFullness !== "no default setting")) {
			if (slave.eyebrowHStyle !== "bald" && slave.eyebrowHStyle !== "hairless") {
				if ((slave.eyebrowFullness !== rule.eyebrowFullness)) {
					slave.eyebrowFullness = rule.eyebrowFullness;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrow hair thickness has been adjusted; they are now ${rule.eyebrowFullness}.`;
				}
			}
		}

		if (rule.pubicHColor !== undefined && (rule.pubicHColor !== "no default setting")) {
			if (slave.pubicHStyle !== "bald" && slave.pubicHStyle !== "hairless") {
				if ((slave.pubicHColor !== rule.pubicHColor)) {
					slave.pubicHColor = rule.pubicHColor;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s pubic hair, if present, has been dyed ${rule.pubicHColor}.`;
				}
			}
		}

		if (rule.pubicHStyle !== undefined && (rule.pubicHStyle !== "no default setting")) {
			if (slave.pubicHStyle !== "bald" && slave.pubicHStyle !== "hairless") {
				if ((slave.pubicHStyle !== rule.pubicHStyle)) {
					slave.pubicHStyle = rule.pubicHStyle;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s pubic hair has been restyled; it is now ${rule.pubicHStyle}.`;
				}
			}
		}

		if (rule.underArmHColor !== undefined && (rule.underArmHColor !== "no default setting")) {
			if (slave.underArmHStyle !== "bald" && slave.underArmHStyle !== "hairless") {
				if ((slave.underArmHColor !== rule.underArmHColor)) {
					slave.underArmHColor = rule.underArmHColor;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s underarm hair, if present, has been dyed ${rule.underArmHColor}.`;
				}
			}
		}

		if (rule.underArmHStyle !== undefined && (rule.underArmHStyle !== "no default setting")) {
			if (slave.underArmHStyle !== "bald" && slave.underArmHStyle !== "hairless") {
				if ((slave.underArmHStyle !== rule.underArmHStyle)) {
					slave.underArmHStyle = rule.underArmHStyle;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s underarm hair has been restyled; it is now ${rule.underArmHStyle}.`;
				}
			}
		}

		if (rule.eyebrowHColor !== undefined && (rule.eyebrowHColor !== "no default setting")) {
			if (slave.eyebrowHStyle !== "bald") {
				if ((slave.eyebrowHColor !== rule.eyebrowHColor)) {
					slave.eyebrowHColor = rule.eyebrowHColor;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrow hair, if present, has been dyed ${rule.eyebrowHColor}.`;
				}
			}
		}

		if (rule.eyebrowHStyle !== undefined && (rule.eyebrowHStyle !== "no default setting")) {
			if (slave.eyebrowHStyle !== "bald") {
				if ((slave.eyebrowHStyle !== rule.eyebrowHStyle)) {
					slave.eyebrowHStyle = rule.eyebrowHStyle;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrow hair has been restyled; it is now ${rule.eyebrowHStyle}.`;
				}
			}
		}

		if (rule.eyebrowFullness !== undefined && (rule.eyebrowFullness !== "no default setting")) {
			if (slave.eyebrowHStyle !== "bald") {
				if ((slave.eyebrowFullness !== rule.eyebrowFullness)) {
					slave.eyebrowFullness = rule.eyebrowFullness;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrow hair has been reshaped; it is now ${rule.eyebrowFullness}.`;
				}
			}
		}

		if (rule.markings !== undefined && (rule.markings !== "no default setting")) {
			if (slave.markings === "beauty mark" && (rule.markings === "remove beauty marks" || rule.markings === "remove both")) {
				r += `<br>${slave.slaveName}'s beauty mark has been removed.`;
				slave.markings = "none";
				cashX(forceNeg(V.modCost), "slaveMod", slave);
			}
			if (slave.markings === "birthmark" && (rule.markings === "remove birthmarks" || rule.markings === "remove both")) {
				r += `<br>${slave.slaveName}'s birthmark has been bleached away.`;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				slave.markings = "none";
			}
		}

		if (rule.skinColor !== undefined && rule.skinColor !== "no default setting" && rule.skinColor !== slave.skin) {
			if (rule.skinColor === "natural") {
				slave.skin = slave.origSkin;
				r += `<br>${slave.slaveName}'s skin color has been returned to ${slave.origSkin}.`;
			} else {
				slave.skin = rule.skinColor;
				r += `<br>${slave.slaveName}'s skin color has been set to ${rule.skinColor}.`;
			}
		}
	}

	function ProcessPiercings(slave, rule) {
		if (rule.nipplesPiercing !== undefined && (rule.nipplesPiercing !== "no default setting")) {
			if ((slave.nipplesPiercing !== rule.nipplesPiercing)) {
				if ((rule.nipplesPiercing === 0)) {
					slave.nipplesPiercing = 0;
					r += `<br>${slave.slaveName}'s nipple piercings have been removed.`;
				} else if (slave.nipples !== "fuckable") {
					slave.nipplesPiercing = rule.nipplesPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s nipples have been pierced.`;
				} else {
					r += `<br>${slave.slaveName}'s nipples are inverted and cannot be pierced.`;
				}
			}
		}

		if (rule.areolaePiercing !== undefined && (rule.areolaePiercing !== "no default setting")) {
			if ((slave.areolaePiercing !== rule.areolaePiercing)) {
				if ((rule.areolaePiercing === 0)) {
					slave.areolaePiercing = 0;
					r += `<br>${slave.slaveName}'s areolae piercings have been removed.`;
				} else {
					slave.areolaePiercing = rule.areolaePiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s areolae have been given stud piercings.`;
				}
			}
		}

		if (rule.clitPiercing !== undefined && (rule.clitPiercing !== "no default setting")) {
			if ((slave.clitPiercing !== rule.clitPiercing)) {
				if ((rule.clitPiercing === 0)) {
					slave.clitPiercing = 0;
					if (slave.dick > 0) {
						r += `<br>${slave.slaveName}'s frenulum piercing has been removed.`;
					} else {
						r += `<br>${slave.slaveName}'s clit piercing has been removed.`;
					}
				} else if ((slave.vagina !== -1) || (slave.dick !== 0)) {
					slave.clitPiercing = rule.clitPiercing;
					if (slave.dick > 0) {
						r += `<br>${slave.slaveName}'s frenulum has been pierced.`;
					} else {
						r += `<br>${slave.slaveName}'s clit has been pierced.`;
					}

					if (rule.clitPiercing === 3) {
						cashX(forceNeg(V.SPcost), "slaveMod", slave);
					} else {
						cashX(forceNeg(V.modCost), "slaveMod", slave);
					}
				}
			}
		}

		if ((slave.vagina !== -1)) {
			if (rule.vaginaPiercing !== undefined && (rule.vaginaPiercing !== "no default setting")) {
				if ((slave.vaginaPiercing !== rule.vaginaPiercing)) {
					if ((rule.vaginaPiercing === 0)) {
						slave.vaginaPiercing = 0;
						r += `<br>${slave.slaveName}'s labia piercings have been removed.`;
					} else {
						slave.vaginaPiercing = rule.vaginaPiercing;
						cashX(forceNeg(V.modCost), "slaveMod", slave);
						r += `<br>${slave.slaveName}'s pussylips have been pierced.`;
					}
				}
			}
		}

		if ((slave.dick > 0)) {
			if (rule.dickPiercing !== undefined && (rule.dickPiercing !== "no default setting")) {
				if ((slave.dickPiercing !== rule.dickPiercing)) {
					if ((rule.dickPiercing === 0)) {
						slave.dickPiercing = 0;
						r += `<br>${slave.slaveName}'s shaft piercings have been removed.`;
					} else {
						slave.dickPiercing = rule.dickPiercing;
						cashX(forceNeg(V.modCost), "slaveMod", slave);
						r += `<br>${slave.slaveName}'s shaft has been pierced.`;
					}
				}
			}
		}

		if (rule.anusPiercing !== undefined && (rule.anusPiercing !== "no default setting")) {
			if ((slave.anusPiercing !== rule.anusPiercing)) {
				if ((rule.anusPiercing === 0)) {
					slave.anusPiercing = 0;
					r += `<br>${slave.slaveName}'s asshole piercings have been removed.`;
				} else {
					slave.anusPiercing = rule.anusPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s asshole has been pierced.`;
				}
			}
		}

		if (rule.lipsPiercing !== undefined && (rule.lipsPiercing !== "no default setting")) {
			if ((slave.lipsPiercing !== rule.lipsPiercing)) {
				if ((rule.lipsPiercing === 0)) {
					slave.lipsPiercing = 0;
					r += `<br>${slave.slaveName}'s lip piercings have been removed.`;
				} else {
					slave.lipsPiercing = rule.lipsPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s lips have been pierced.`;
				}
			}
		}

		if (rule.tonguePiercing !== undefined && (rule.tonguePiercing !== "no default setting")) {
			if ((slave.tonguePiercing !== rule.tonguePiercing)) {
				if ((rule.tonguePiercing === 0)) {
					slave.tonguePiercing = 0;
					r += `<br>${slave.slaveName}'s tongue piercings have been removed.`;
				} else {
					slave.tonguePiercing = rule.tonguePiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s tongue has been pierced.`;
				}
			}
		}

		if (rule.earPiercing !== undefined && (rule.earPiercing !== "no default setting")) {
			if ((slave.earPiercing !== rule.earPiercing)) {
				if ((rule.earPiercing === 0)) {
					slave.earPiercing = 0;
					r += `<br>${slave.slaveName}'s ear piercings have been removed.`;
				} else {
					slave.earPiercing = rule.earPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s ears have been pierced.`;
				}
			}
		}

		if (rule.nosePiercing !== undefined && (rule.nosePiercing !== "no default setting")) {
			if ((slave.nosePiercing !== rule.nosePiercing)) {
				if ((rule.nosePiercing === 0)) {
					slave.nosePiercing = 0;
					r += `<br>${slave.slaveName}'s nose piercing has been removed.`;
				} else {
					slave.nosePiercing = rule.nosePiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s nose has been pierced.`;
				}
			}
		}

		if (rule.eyebrowPiercing !== undefined && (rule.eyebrowPiercing !== "no default setting")) {
			if ((slave.eyebrowPiercing !== rule.eyebrowPiercing)) {
				if ((rule.eyebrowPiercing === 0)) {
					slave.eyebrowPiercing = 0;
					r += `<br>${slave.slaveName}'s eyebrow piercings have been removed.`;
				} else {
					slave.eyebrowPiercing = rule.eyebrowPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s eyebrows have been pierced.`;
				}
			}
		}

		if (rule.navelPiercing !== undefined && (rule.navelPiercing !== "no default setting")) {
			if ((slave.navelPiercing !== rule.navelPiercing)) {
				if ((rule.navelPiercing === 0)) {
					slave.navelPiercing = 0;
					r += `<br>${slave.slaveName}'s navel piercing have been removed.`;
				} else {
					slave.navelPiercing = rule.navelPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s navel has been pierced.`;
				}
			}
		}

		if (rule.corsetPiercing !== undefined && (rule.corsetPiercing !== "no default setting")) {
			if ((slave.corsetPiercing !== rule.corsetPiercing)) {
				if ((rule.corsetPiercing === 0)) {
					slave.corsetPiercing = 0;
					r += `<br>${slave.slaveName}'s corset piercings have been removed.`;
				} else {
					slave.corsetPiercing = rule.corsetPiercing;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName} has been given a set of corset piercings.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessSmartPiercings(slave, rule) {
		if ((slave.clitPiercing === 3)) {
			let _used = 0;
			if (rule.clitSetting !== undefined && (rule.clitSetting !== "no default setting")) {
				if (slave.clitSetting !== rule.clitSetting) {
					slave.clitSetting = rule.clitSetting;
					_used = 1;
					r += `<br>${slave.slaveName}'s smart piercing has been set to ${slave.clitSetting}.`;
				} else if (slave.fetishStrength < 100) {
					_used = 1;
				}
			}
			if (_used === 0) {
				if (rule.clitSettingEnergy !== undefined && (rule.clitSettingEnergy !== "no default setting")) {
					if (slave.energy < rule.clitSettingEnergy) {
						if (slave.clitSetting !== "all") {
							r += `<br>${slave.slaveName}'s smart piercing has been set to enhance libido.`;
						}
						slave.clitSetting = "all";
						_used = 1;
					} else if (slave.energy >= rule.clitSettingEnergy + 10) {
						if (slave.clitSetting !== "none") {
							r += `<br>${slave.slaveName}'s smart piercing has been set to suppress libido.`;
						}
						slave.clitSetting = "none";
						_used = 1;
					}
				}
			}
			if (_used === 0) {
				if (rule.clitSettingXY !== undefined && (rule.clitSettingXY !== "no default setting")) {
					if (slave.attrXY < rule.clitSettingXY) {
						if (slave.clitSetting !== "men") {
							r += `<br>${slave.slaveName}'s smart piercing has been set to encourage attraction to men.`;
						}
						slave.clitSetting = "men";
						_used = 1;
					} else if (slave.attrXY >= rule.clitSettingXY + 10) {
						if (slave.clitSetting !== "anti-men") {
							r += `<br>${slave.slaveName}'s smart piercing has been set to discourage attraction to men.`;
						}
						slave.clitSetting = "anti-men";
						_used = 1;
					}
				}
			}
			if (_used === 0) {
				if (rule.clitSettingXX !== undefined && (rule.clitSettingXX !== "no default setting")) {
					if (slave.attrXX < rule.clitSettingXX) {
						if (slave.clitSetting !== "women") {
							r += `<br>${slave.slaveName}'s smart piercing has been set to encourage attraction to women.`;
						}
						slave.clitSetting = "women";
						_used = 1;
					} else if (slave.attrXX >= rule.clitSettingXX + 10) {
						if (slave.clitSetting !== "anti-women") {
							r += `<br>${slave.slaveName}'s smart piercing has been set to discourage attraction to women.`;
						}
						slave.clitSetting = "anti-women";
						_used = 1;
					}
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessTattoos(slave, rule) {
		if (rule.boobsTat !== undefined && (rule.boobsTat !== "no default setting")) {
			if ((slave.boobsTat !== rule.boobsTat)) {
				slave.boobsTat = rule.boobsTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s chest has been tattooed.`;
			}
		}

		if (rule.buttTat !== undefined && (rule.buttTat !== "no default setting")) {
			if ((slave.buttTat !== rule.buttTat)) {
				slave.buttTat = rule.buttTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s butt has been tattooed.`;
			}
		}

		if (rule.vaginaTat !== undefined && (rule.vaginaTat !== "no default setting")) {
			if ((slave.vaginaTat !== rule.vaginaTat)) {
				slave.vaginaTat = rule.vaginaTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s abdomen has been tattooed.`;
			}
		}

		if ((slave.dick > 0)) {
			if (rule.dickTat !== undefined && (rule.dickTat !== "no default setting")) {
				if ((slave.dickTat !== rule.dickTat)) {
					slave.dickTat = rule.dickTat;
					cashX(forceNeg(V.modCost), "slaveMod", slave);
					r += `<br>${slave.slaveName}'s dick has been tattooed.`;
				}
			}
		}

		if (rule.lipsTat !== undefined && (rule.lipsTat !== "no default setting")) {
			if ((slave.lipsTat !== rule.lipsTat)) {
				slave.lipsTat = rule.lipsTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s face has been tattooed.`;
			}
		}

		if (rule.anusTat !== undefined && (rule.anusTat !== "no default setting")) {
			if ((slave.anusTat !== rule.anusTat)) {
				slave.anusTat = rule.anusTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s asshole has been modded.`;
			}
		}

		if (rule.backTat !== undefined && (rule.backTat !== "no default setting")) {
			if ((slave.backTat !== rule.backTat)) {
				slave.backTat = rule.backTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s back has been tattooed.`;
			}
		}

		if (rule.shouldersTat !== undefined && (rule.shouldersTat !== "no default setting")) {
			if ((slave.shouldersTat !== rule.shouldersTat)) {
				slave.shouldersTat = rule.shouldersTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s shoulders have been tattooed.`;
			}
		}

		if (rule.armsTat !== undefined && (rule.armsTat !== "no default setting")) {
			if ((slave.armsTat !== rule.armsTat)) {
				slave.armsTat = rule.armsTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s arms have been tattooed.`;
			}
		}

		if (rule.legsTat !== undefined && (rule.legsTat !== "no default setting")) {
			if ((slave.legsTat !== rule.legsTat)) {
				slave.legsTat = rule.legsTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s legs have been tattooed.`;
			}
		}

		if (rule.stampTat !== undefined && (rule.stampTat !== "no default setting")) {
			if ((slave.stampTat !== rule.stampTat)) {
				slave.stampTat = rule.stampTat;
				cashX(forceNeg(V.modCost), "slaveMod", slave);
				r += `<br>${slave.slaveName}'s lower back has been tattooed.`;
			}
		}
		if ((rule.autoBrand === 1)) {
			if ((slave.brand === 0)) {
				if ((slave.health > -20)) {
					slave.brand = V.brandDesign.RA;
					slave.brandLocation = V.brandTarget.RA;
					if ((slave.devotion < 18)) {
						slave.devotion -= 5;
					}
					slave.trust -= 5;
					slave.health -= 10;
					r += `<br>${slave.slaveName} has been branded, with <span class="gold">fear</span>${slave.devotion < 18 ? `, <span class="mediumorchid">regard,</span>` : ``} and <span class="red">health</span> consequences.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessPornFeedEnabled(slave, rule) {
		if (rule.pornFeed === undefined || rule.pornFeed === "no default setting") {
			return;
		}
		if (rule.pornFeed === slave.pornFeed) {
			return;
		}
		slave.pornFeed = rule.pornFeed;
		let yesno = slave.pornFeed ? "are now" : "are no longer";
		if (slave.pornFeed === 0) {
			slave.pornFameSpending = 0;
		}
		r += `<br>Highlights of ${slave.slaveName}'s sex life ${yesno} being released.`;
	}

	function ProcessPorn(slave, rule) {
		if ((rule.pornFameSpending !== undefined) && (rule.pornFameSpending !== "no default setting")) {
			if ((slave.pornPrestige < 3)) {
				if ((slave.pornFameSpending !== rule.pornFameSpending)) {
					slave.pornFameSpending = rule.pornFameSpending;
					r += `<br>${slave.slaveName}'s porn publicity has been corrected.`;
				}
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @param {object} rule
	 */
	function ProcessLabel(slave, rule) {
		if (rule.label !== "no default setting" && !slave.custom.label.includes(`[${rule.label}]`)) {
			slave.custom.label = `${slave.custom.label}[${rule.label}]`;
			r += `<br>${slave.slaveName} has been tagged as ${rule.label}`;
		}

		if (rule.removeLabel !== "no default setting" && slave.custom.label.includes(`[${rule.removeLabel}]`)) {
			slave.custom.label = slave.custom.label.replace(`[${rule.removeLabel}]`, "");
			r += `<br>${slave.slaveName}'s tag [${rule.removeLabel}] is removed.`;
		}
	}

	return DefaultRules;
})();