code:
:: rules autosurgery js [script]

window.rulesAutosurgery = (function() {
	"use strict";
	let V;
	let r;
	return rulesAutoSurgery;

	function rulesAutoSurgery(slave) {
		V = State.variables;
		r = "";
		const surgeries = [];
		const thisSurgery = ProcessHGTastes(slave);
		if (slave.health > 20)
			CommitSurgery(slave, thisSurgery, surgeries);
		if (surgeries.length > 0)
			PrintResult(slave, thisSurgery, surgeries);
		return r;
	}

	function autoSurgerySelector(slave, ruleset) {
		const surgery = {};
		ruleset.forEach(rule => {
			Object.keys(rule)
				.filter(key => key.startsWith("surgery_") && rule[key] !== "no default setting")
				.forEach(key => {
					surgery[key] = rule[key];
				});
		});
		return surgery;
	}

	function ProcessHGTastes(slave) {
		let thisSurgery;
		switch (V.HGTastes) {
		case 1:
			thisSurgery = {
				surgery_lactation: 0,
				surgery_cosmetic: 1,
				surgery_faceShape: "cute",
				surgery_lips: 10,
				surgery_hips: 0,
				surgery_hipsImplant: 0,
				surgery_butt: 0,
				surgery_accent: 0,
				surgery_shoulders: 0,
				surgery_shouldersImplant: 0,
				surgery_boobs: 0,
				surgery_holes: 0
			};
			break ;
		case 2:
			thisSurgery = {
				surgery_lactation: 0,
				surgery_cosmetic: 1,
				surgery_faceShape: "cute",
				surgery_lips: 60,
				surgery_hips: 0,
				surgery_hipsImplant: 0,
				surgery_butt: 4,
				surgery_accent: 0,
				surgery_shoulders: 0,
				surgery_shouldersImplant: 0,
				surgery_boobs: 1200,
				surgery_holes: 0
			};
			break;
		case 3:
			thisSurgery = {
				surgery_lactation: 0,
				surgery_cosmetic: 1,
				surgery_faceShape: "cute",
				surgery_lips: 95,
				surgery_hips: 0,
				surgery_hipsImplant: 0,
				surgery_butt: 8,
				surgery_accent: 0,
				surgery_shoulders: 0,
				surgery_shouldersImplant: 0,
				surgery_boobs: 10000,
				surgery_holes: 2
			};
			break;
		case 4:
			thisSurgery = {
				surgery_lactation: 1,
				surgery_cosmetic: 1,
				surgery_faceShape: "cute",
				surgery_lips: 10,
				surgery_hips: 3,
				surgery_hipsImplant: 0,
				surgery_butt: 0,
				surgery_accent: 0,
				surgery_shoulders: 0,
				surgery_shouldersImplant: 0,
				surgery_boobs: 0,
				surgery_holes: 0
			};
			break;
		default:
			thisSurgery = autoSurgerySelector(
				slave,
				V.defaultRules
					.filter(x => ruleApplied(slave, x) && x.set.autoSurgery === 1)
					.map(x => x.set));
			if ((thisSurgery.surgery_hips !== "no default setting") && (thisSurgery.surgery_butt !== "no default setting")) {
				if (slave.hips < -1) {
					if (thisSurgery.surgery_butt > 2)
						thisSurgery.surgery_butt = 2;
				} else if (slave.hips < 0) {
					if (thisSurgery.surgery_butt > 4)
						thisSurgery.surgery_butt = 4;
				} else if (slave.hips > 0) {
					if (thisSurgery.surgery_butt > 8)
						thisSurgery.surgery_butt = 8;
				} else if (slave.hips > 1) {
					true;
				} else {
					if (thisSurgery.surgery_butt > 6)
						thisSurgery.surgery_butt = 6;
				}
			}
			break;
		}
		return thisSurgery;
	}

	function CommitSurgery(slave, thisSurgery, surgeries) {
		if ((slave.eyes == -1) && (thisSurgery.surgery_eyes == 1)) {
			surgeries.push("surgery to correct her vision");
			slave.eyes = 1;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.eyes == 1) && (thisSurgery.surgery_eyes == -1)) {
			surgeries.push("surgery to blur her vision");
			slave.eyes = -1;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.hears == -1) && (thisSurgery.surgery_hears == 1)) {
			surgeries.push("surgery to correct her hearing");
			slave.hears = 0;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.hears == 0) && (thisSurgery.surgery_hears == -1)) {
			surgeries.push("surgery to muffle her hearing");
			slave.hears = -1;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.lactation == 2) && (thisSurgery.surgery_lactation == 0)) {
			surgeries.push("surgery to remove her lactation implants");
			slave.lactation = 0;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if (slave.lactation != 2 && (thisSurgery.surgery_lactation == 1)) {
			surgeries.push("lactation inducing implanted drugs");
			slave.lactation = 2;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.prostate == 2) && (thisSurgery.surgery_prostate == 0)) {
			surgeries.push("surgery to remove her prostate implant");
			slave.prostate = 0;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if (slave.prostate == 1 && (thisSurgery.surgery_prostate == 1)) {
			surgeries.push("a precum production enhancing drug implant");
			slave.prostate = 2;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.anus > 3) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("a restored anus");
			slave.anus = 3;
			if (slave.analSkill > 10)
				slave.analSkill -= 10;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.vagina > 3) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("a restored pussy");
			slave.vagina = 3;
			if (slave.vaginalSkill > 10)
				slave.vaginalSkill -= 10;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.faceImplant <= 15) && (slave.face <= 95) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("a nicer face");
			if (slave.faceShape == "masculine") slave.faceShape = "androgynous";
			slave.faceImplant += 25-5*Math.trunc(V.PC.medicine/50)-5*V.surgeryUpgrade;
			slave.face = Math.clamp(slave.face+20,-100,100);
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.faceImplant <= 15) && (slave.ageImplant != 1) && (slave.visualAge >= 25) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("an age lift");
			slave.ageImplant = 1;
			slave.faceImplant += 25-5*Math.trunc(V.PC.medicine/50)-5*V.surgeryUpgrade;
			if (slave.visualAge > 80) slave.visualAge -= 40;
			else if (slave.visualAge >= 70) slave.visualAge -= 30;
			else if (slave.visualAge > 50) slave.visualAge -= 20;
			else if (slave.visualAge > 36) slave.visualAge -= 10;
			else slave.visualAge -= 5;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if (((slave.underArmHStyle != "bald" && slave.underArmHStyle != "hairless") || (slave.pubicHStyle != "bald" && slave.pubicHStyle != "hairless")) && (thisSurgery.surgery_bodyhair == 2)) {
			surgeries.push("body hair removal");
			if (slave.underArmHStyle != "hairless") slave.underArmHStyle = "bald";
			if (slave.pubicHStyle != "hairless") slave.pubicHStyle = "bald";
			V.cash -= V.surgeryCost;

		} else if ((slave.bald == 0 || slave.hStyle != "bald" || slave.eyebrowHStyle != "bald") && (thisSurgery.surgery_hair == 2)) {
			surgeries.push("hair removal");
			slave.eyebrowHStyle = "bald";
			slave.hStyle = "bald";
			slave.bald = 1;
			V.cash -= V.surgeryCost;

		} else if ((slave.weight >= 10) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("liposuction");
			slave.weight -= 50;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.voice == 1) && (slave.voiceImplant == 0) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("a feminine voice");
			slave.voice += 1;
			slave.voiceImplant += 1;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.waist >= -10) && (thisSurgery.surgery_cosmetic > 0)) {
			surgeries.push("a narrower waist");
			slave.waist -= 20;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if (((slave.boobShape == "saggy") || (slave.boobShape == "downward-facing")) && (thisSurgery.surgery_cosmetic > 0) && (slave.breastMesh != 1)) {
			surgeries.push("a breast lift");
			slave.boobShape = "normal";
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if (((slave.boobShape == "normal") || (slave.boobShape == "wide-set")) && (thisSurgery.surgery_cosmetic > 0) && (slave.breastMesh != 1)) {
			if (slave.boobs > 800)
				slave.boobShape = "torpedo-shaped";
			else
				slave.boobShape = "perky";
			surgeries.push("more interestingly shaped breasts");
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((thisSurgery.surgery_lips == 0) && (slave.lipsImplant > 0)) {
			surgeries.push("surgery to remove her lip implants");
			slave.lips -= slave.lipsImplant;
			slave.lipsImplant = 0;
			if (slave.oralSkill > 10)
				slave.oralSkill -= 10;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.lips <= 95) && (slave.lips < thisSurgery.surgery_lips)) {
			if (thisSurgery.surgery_lips !== "no default setting") {
				surgeries.push("bigger lips");
				slave.lipsImplant += 10;
				slave.lips += 10;
				if (slave.oralSkill > 10)
					slave.oralSkill -= 10;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}

		} else if ((slave.faceImplant <= 45) && (slave.face <= 95) && (thisSurgery.surgery_cosmetic == 2)) {
			surgeries.push("a nicer face");
			if (slave.faceShape == "masculine") slave.faceShape = "androgynous";
			slave.faceImplant += 25-5*Math.trunc(V.PC.medicine/50)-5*V.surgeryUpgrade;
			slave.face = Math.clamp(slave.face+20,-100,100);
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.hips < 1) && (slave.hips < thisSurgery.surgery_hips) && (V.surgeryUpgrade == 1)) {
			surgeries.push("wider hips");
			slave.hips++;
			slave.hipsImplant++;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.faceImplant <= 45) && (slave.ageImplant != 1) && (slave.visualAge >= 25) && (thisSurgery.surgery_cosmetic == 2)) {
			surgeries.push("an age lift");
			slave.ageImplant = 1;
			if (slave.visualAge > 80) {
				slave.visualAge -= 40;
			} else if (slave.visualAge >= 70) {
				slave.visualAge -= 30;
			} else if (slave.visualAge > 50) {
				slave.visualAge -= 20;
			} else if (slave.visualAge > 36) {
				slave.visualAge -= 10;
			} else {
				slave.visualAge -= 5;
			}
			slave.faceImplant += 25-5*Math.trunc(V.PC.medicine/50)-5*V.surgeryUpgrade;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.waist >= -95) && (thisSurgery.surgery_cosmetic == 2) && (V.seeExtreme == 1)) {
			surgeries.push("a narrower waist");
			slave.waist = Math.clamp(slave.waist-20,-100,100);
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.voice < 3) && (slave.voiceImplant == 0) && (thisSurgery.surgery_cosmetic == 2)) {
			surgeries.push("a bimbo's voice");
			slave.voice += 1;
			slave.voiceImplant += 1;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((thisSurgery.surgery_butt == 0) && (slave.buttImplant > 0)) {
			surgeries.push("surgery to remove her butt implants");
			slave.butt -= slave.buttImplant;
			slave.buttImplant = 0;
			slave.buttImplantType = 0;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((thisSurgery.surgery_boobs == 0) && (slave.boobsImplant > 0)) {
			surgeries.push("surgery to remove her boob implants");
			slave.boobs -= slave.boobsImplant;
			slave.boobsImplant = 0;
			slave.boobsImplantType = 0;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;
		} else if ((slave.butt <= 3) && (slave.butt < thisSurgery.surgery_butt)) {
			if (thisSurgery.surgery_butt !== "no default setting") {
				surgeries.push("a bigger butt");
				slave.buttImplant = 1;
				slave.butt += 1;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}
		} else if ((slave.boobs <= 600) && (slave.lactation < 2) && (slave.boobs+400 <= thisSurgery.surgery_boobs)) {
			if (thisSurgery.surgery_boobs !== "no default setting") {
				surgeries.push("bigger boobs");
				slave.boobsImplant += 400;
				slave.boobs += 400;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}
		} else if ((slave.boobs <= 600) && (slave.lactation < 2) && (slave.boobs+200 <= thisSurgery.surgery_boobs)) {
			if (thisSurgery.surgery_boobs !== "no default setting") {
				surgeries.push("modestly bigger boobs");
				slave.boobsImplant += 200;
				slave.boobs += 200;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}

		} else if ((slave.butt <= 5) && (slave.butt < thisSurgery.surgery_butt)) {
			if (thisSurgery.surgery_butt !== "no default setting") {
				surgeries.push("a bigger butt");
				slave.buttImplant = 1;
				slave.butt += 1;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}

		} else if ((slave.boobs <= 2000) && (slave.lactation < 2) && (slave.boobs+400 < thisSurgery.surgery_boobs)) {
			if (thisSurgery.surgery_boobs !== "no default setting") {
				surgeries.push("bigger boobs");
				slave.boobsImplant += 400;
				slave.boobs += 400;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}

		} else if ((slave.anus > 0) && (V.surgeryUpgrade == 1) && (thisSurgery.surgery_holes == 2)) {
			surgeries.push("a virgin anus");
			slave.anus = 0;
			if (slave.analSkill > 10) {
				slave.analSkill -= 10;
			}
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.vagina > 0) && (V.surgeryUpgrade == 1) && (thisSurgery.surgery_holes == 2)) {
			surgeries.push("a virgin pussy");
			slave.vagina = 0;
			if (slave.vaginalSkill > 10)
				slave.vaginalSkill -= 10;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.hips < 2) && (slave.hips < thisSurgery.surgery_hips) && (V.surgeryUpgrade == 1)) {
			surgeries.push("wider hips");
			slave.hips++;
			slave.hipsImplant++;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.anus > 1) && (thisSurgery.surgery_holes == 1)) {
			surgeries.push("a tighter anus");
			slave.anus = 1;
			if (slave.analSkill > 10) {
				slave.analSkill -= 10;
			}
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.vagina > 1) && (thisSurgery.surgery_holes == 1)) {
			surgeries.push("a tighter pussy");
			slave.vagina = 1;
			if (slave.vaginalSkill > 10) {
				slave.vaginalSkill -= 10;
			}
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if ((slave.butt <= 8) && (slave.butt < thisSurgery.surgery_butt)) {
			if (thisSurgery.surgery_butt !== "no default setting") {
				surgeries.push("a bigger butt");
				slave.buttImplant = 1;
				slave.butt += 1;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}

		} else if ((slave.boobs <= 9000) && (slave.lactation < 2) && (slave.boobs < thisSurgery.surgery_boobs)) {
			if (thisSurgery.surgery_boobs !== "no default setting") {
				surgeries.push("bigger boobs");
				slave.boobsImplant += 200;
				slave.boobs += 200;
				V.cash -= V.surgeryCost;
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			}

		} else if ((slave.hips < 3) && (slave.hips < thisSurgery.surgery_hips) && (V.surgeryUpgrade == 1)) {
			surgeries.push("wider hips");
			slave.hips++;
			slave.hipsImplant++;
			V.cash -= V.surgeryCost;
			if (V.PC.medicine >= 100) slave.health -= 5;
			else slave.health -= 10;

		} else if (slave.bellyImplant < 0 && V.bellyImplants > 0 && thisSurgery.surgery_bellyImplant == "install" && slave.womb.length == 0 && slave.broodmother == 0) {
			slave.bellyImplant = 100;
			slave.preg = -2;
			V.cash -= V.surgeryCost;
			if (slave.ovaries == 1 || slave.mpreg == 1) {
				surgeries.push("belly implant");
				V.surgeryType = "bellyIn";
				if (V.PC.medicine >= 100) slave.health -= 5;
				else slave.health -= 10;
			} else {
				surgeries.push("male belly implant");
				V.surgeryType = "bellyInMale";
				if (V.PC.medicine >= 100) slave.health -= 25;
				else slave.health -= 50;
			}
			bellyIn(slave);

		} else if (slave.bellyImplant >= 0 && thisSurgery.surgery_bellyImplant == "remove") {
			surgeries.push("belly implant removal");
			V.surgeryType = "bellyOut";
			if (V.PC.medicine >= 100)
				slave.health -= 5;
			else
				slave.health -= 10;
			slave.preg = 0;
			slave.bellyImplant = -1;
			V.cash -= V.surgeryCost;
		} else if (slave.balls > 0 && slave.vasectomy === 0 && thisSurgery.surgery_vasectomy === true) {
			surgeries.push("vasectomy");
			V.surgeryType = "vasectomy";
			if (V.PC.medicine >= 100)
				slave.health -= 5;
			else
				slave.health -= 10;
			slave.vasectomy = 1;
			V.cash -= V.surgeryCost;
		} else if (slave.balls > 0 && slave.vasectomy === 1 && thisSurgery.surgery_vasectomy === false) {
			surgeries.push("undo vasectomy");
			V.surgeryType = "vasectomy undo";
			if (V.PC.medicine >= 100)
				slave.health -=5;
			else
				slave.health -= 10;
			slave.vasectomy = 0;
			V.cash -= V.surgeryCost;
		}
	}

	function PrintResult(slave, thisSurgery, surgeries) {
		let surgeriesDisplay = "";
		if (surgeries.length === 1)
			surgeriesDisplay = surgeries[0];
		else {
			surgeriesDisplay = surgeries.slice(0, surgeries.length - 1).join(", ");
			surgeriesDisplay += ", and" + surgeries[surgeries.length - 1];
		}
		r += `${V.assistantName === "your personal assistant" ? "Your personal assistant" : V.assistantName}, ordered to apply surgery, gives ${slave.slaveName} <span class="lime">${surgeriesDisplay}.</span>`;
	}

	function bellyIn(slave) {
		// less hacky version of calling surgery degradation silently
		if (slave.devotion > 50)
			slave.devotion += 4;
		else if (slave.devotion >= -20)
			slave.trust -= 5;
		else {
			slave.trust -= 5;
			slave.devotion -= 5;
		}
	}
})();

repo_name: nook/fc


code:
:: sexActJS [script]

/*
 times is how many times to increment the anal counts.
 if left undefined it will assume it to be 1.
*/
window.AnalVCheck = function AnalVCheck(times) {
	const V = State.variables;
	const slave = V.activeSlave;
	let r = ``;
	if (canDoAnal(slave) && slave.anus === 0) {
		r += `@@.lime;This breaks in ${slave.slaveName}'s virgin ass.@@ `;
		if (slave.devotion > 50 || slave.career == "a slave since birth") {
			r += `Since it's her first time, you gently ease yourself into her butthole and gradually increase the intensity of your thrusts. Before long she's moaning loudly as you continue working away at her butthole. `;
			if (slave.tankBaby == 2) {
				r += `She thinks of losing her anal virginity to her ${WrittenMaster(slave)} a @@.hotpink;necessity.@@ She expects her asshole to be seeing a lot more attention now.`;
			}
			else {
				r += `She thinks of losing her anal virginity to you as a @@.hotpink;connection@@ with her beloved ${WrittenMaster(slave)}. `;
				if ((slave.fetishKnown && slave.fetish == "buttslut") || (slave.energy > 95) || (slave.attrXX >= 85 && V.PC.dick === 0)) {
					r += `She can't wait to be fucked in the ass by you again.`;
				}
				else {
					r += `She looks forward to having her asshole fucked by you again.`;
				}
			}
			slave.devotion += 4;
		}
		else if (slave.devotion > 20) {
			r += `Since it's her first time, you gently ease yourself into her butthole and gradually increase the intensity of your thrusts. Her moans become louder and louder as you continue working away at her butthole. She accepts the pain and humiliation of anal sex as part of her sexual servitude, though she hopes that her next time will be less painful.`;
		}
		else if (slave.devotion >= -20) {
			r += `You force yourself into her butthole. She sobs and cries with disgust while you continue thrusting into her ass. She @@.gold;fears@@ her next anal sex, remembering the pain of losing her anal virginity. She dreads having her ass violated by you again.`;
			slave.trust -= 5;
		}
		else {
			r += `You force yourself into her butthole. She sobs and cries with disgust while you continue thrusting into her ass. She @@.mediumorchid;hates@@ and @@.gold;fears@@ you for violating her virgin butt. She dreads having her ass fucked by you again.`;
			slave.trust -= 5;
			slave.devotion -= 5;
		}
		slave.anus = 1;
	}
	if (canDoAnal(slave)) {
		if (canImpreg(slave, V.PC)) {
			r += knockMeUp(slave, 10, 1, -1, 1);
		}
		if (!times) {
			V.analTotal += 1;
			slave.analCount += 1;
		}
		else {
			V.analTotal += times;
			slave.analCount += times;
		}
	}
	return r;
}

/*
 times is how many times to increment the vaginal counts.
 if left undefined it will assume it to be 1.
*/
window.VaginalVCheck = function VaginalVCheck(times) {
	const V = State.variables;
	const slave = V.activeSlave;
	let r = ``;
	if (canDoVaginal(slave) && slave.vagina === 0) {
		r += `@@.lime;This breaks in ${slave.slaveName}'s virgin pussy.@@ `;
		if (slave.devotion > 50 || slave.career == "a slave since birth") {
			r += `You ease yourself into her pussy, since it's her first time, then gradually speed up your thrusts while she slowly learns to move her hips along with you. She moans loudly. `;
			if (slave.tankBaby == 2) {
				r += `She thinks of losing her virginity to her ${WrittenMaster(slave)} a @@.hotpink;necessity to be happy.@@ She expects her pussy to be seeing a lot more attention in the future.`;
			}
			else {
				r += `@@.hotpink;She enjoys losing her cherry to you.@@ `;
				if ((slave.fetishKnown && slave.fetish == "pregnancy") || (slave.energy > 95) || (slave.attrXY >= 85 && V.PC.dick === 1)) {
					r += `She can't wait to have her pussy fucked by you again.`;
				}
				else {
					r += `She looks forward to having her pussy fucked by you again.`;
				}
			}
			slave.devotion += 4;
		}
		else if (slave.devotion > 20) {
			r += `You ease yourself into her pussy, since it's her first time, then gradually speed up your thrusts while she slowly learns to move her hips along with you. She accepts losing her virginity to her owner and she looks forward to having her pussy fucked by you again.`;
		}
		else if (slave.devotion >= -20) {
			r += `You force yourself into her pussy. She sobs and cries with disgust while you continue thrusting into her fuck hole. She @@.mediumorchid;hates@@ losing her virginity this way and @@.gold;fears@@ the next time you'll conquer her. She dreads getting violated by you again.`;
			slave.trust -= 5;
			slave.devotion -= 5;
		}
		else {
			r += `You force yourself into her pussy. She sobs and cries with disgust while you continue working her fuck hole. She tries to struggle, but you only pound harder. She @@.mediumorchid;hates@@ and @@.gold;fears@@ you for robbing her of her virginity. She dreads getting fucked by you again.`;
			slave.trust -= 10;
			slave.devotion -= 15;
		}
		slave.vagina = 1;
	}
	if (canDoVaginal(slave)) {
		if (canImpreg(slave, V.PC)) {
			r += knockMeUp(slave, 10, 0, -1, 1);
		}
		if (!times) {
			V.vaginalTotal += 1;
			slave.vaginalCount += 1;
		}
		else {
			V.vaginalTotal += times;
			slave.vaginalCount += times;
		}
	}

	return r;
}

/*
 analTimes is how many times to increment the anal counts, if there is no vagina available.
 bothTimes is how many times to increment both holes counts (usually it is half of analTimes).
 In both cases if left undefined it will assume it to be 1.
*/
window.BothVCheck = function BothVCheck(analTimes, bothTimes) {
	const V = State.variables;
	const slave = V.activeSlave;
	let r = ``;
	if (canDoVaginal(slave)) {
		if (slave.vagina === 0) {
			if (canDoAnal(slave) && slave.anus == 0) {
				r += `@@.lime;This breaks in ${slave.slaveName}'s virgin holes.@@ `;
				if (slave.devotion > 50 || slave.career == "a slave since birth") {
					r += `As it's her first time, you ease yourself into her pussy before gradually working your way into her ass and alternate between the two holes while she moans. `;
					if (slave.tankBaby == 2) {
						r += `She believes you taking her virgin holes @@.hotpink;will keep her from suffering.@@ She expects you to require her holes as tribute again soon.`;
					}
					else {
						r += `@@.hotpink;She's so devoted she enjoys being fucked in both holes for the first time.@@ She looks forward to having her holes fucked by you again.`;
					}
					slave.devotion += 4;
				}
				else if (slave.devotion <= 20) {
					r += `You force yourself into her pussy before working your way into her ass. She sobs and cries with disgust while you alternate between the two holes. She @@.mediumorchid;hates@@ losing her virginity and anal virginity in one @@.gold;brutal@@ incident. She dreads having her holes violated by you again.`;
					slave.trust -= 5;
					slave.devotion -= 5;
				}
				else {
					r += `As it's her first time, you ease yourself into her pussy before gradually working your way into her ass and alternate between the two holes while she moans. She accepts being fucked in both holes for the first time. She looks forward to having her holes fucked by you again.`;
				}
				slave.anus = 1;
			}
			else {
				r += `@@.lime;This breaks in ${slave.slaveName}'s virgin pussy.@@ `;
				if (slave.devotion > 50 || slave.career == "a slave since birth") {
					r += `As it's her first time, you ease yourself into her pussy and gradually speed up your thrusts while she slowly learns to move her hips along with you. She moans loudly. `;
					if (slave.tankBaby == 2) {
						r += `She thinks of losing her virginity to her ${WrittenMaster(slave)} a @@.hotpink;necessity to be happy.@@ She expects her pussy to be seeing a lot more attention in the future.`;
					}
					else {
						r += `@@.hotpink;She enjoys losing her cherry to you.@@ She looks forward to having her pussy fucked by you again.`;
					}
					slave.devotion += 4;
				}
				else if (slave.devotion <= 20) {
					r += `You force yourself into her pussy. She sobs and cries with disgust while you continue working her fuck hole. She @@.mediumorchid;hates@@ and @@.gold;fears@@ you for taking her virginity. She dreads having her pussy violated by you again.`;
					slave.trust -= 5;
					slave.devotion -= 5;
				}
				else {
					r += `As it's her first time, you ease yourself into her pussy before gradually increasing the intensity of your thrusts while she softly moans. She accepts losing her virginity to her owner and she looks forward to having her pussy fucked by you again.`;
				}
			}
			slave.vagina = 1;
		}
		else if (canDoAnal(slave) && slave.anus == 0) {
			r += `@@.lime;This breaks in ${slave.slaveName}'s virgin ass.@@ `;
			if (slave.devotion > 50 || slave.career == "a slave since birth") {
				r += `As it's her first time, you ease yourself into her butthole and gradually speed up your thrusts while she slowly learns to move her hips along with you. She moans loudly. `;
				if (slave.tankBaby == 2) {
					r += `She thinks of losing her anal virginity to her ${WrittenMaster(slave)} a @@.hotpink;necessity.@@ She expects her asshole to be seeing a lot more attention now.`;
				}
				else {
					r += `She thinks of losing her anal virginity to you as a @@.hotpink;connection@@ with her beloved ${WrittenMaster(slave)}. She looks forward to having her asshole fucked by you again.`
				}
				slave.devotion += 4;
			}
			else if (slave.devotion > 20){
				r += `As it's her first time, you ease yourself into her butthole and gradually increase the intensity of your thrusts. She accepts the pain and humiliation of anal sex as part of her sexual servitude, though she hopes that her next time will be less painful.`;
			}
			else if (slave.devotion >= -20) {
				r += `You force yourself into her butthole. She sobs and cries with disgust while you continue thrusting into her ass. She @@.gold;fears@@ her next anal sex, remembering the pain of losing her anal virginity. She dreads having her ass violated by you again.`;
				slave.trust -= 5;
			}
			else {
				r += `You force yourself into her butthole. She sobs and cries with disgust while you continue thrusting into her ass. She @@.mediumorchid;hates@@ and @@.gold;fears@@ you for violating her virgin butt. She dreads having her ass fucked by you again.`;
				slave.trust -= 5;
				slave.devotion -= 5;
			}
			slave.anus = 1;
		}
		if (canDoAnal(slave)) {
			if (!bothTimes) {
				V.vaginalTotal += 1;
				V.analTotal += 1;
				slave.vaginalCount += 1;
				slave.analCount += 1;
			}
			else {
				V.vaginalTotal += bothTimes;
				V.analTotal += bothTimes;
				slave.vaginalCount += bothTimes;
				slave.analCount += bothTimes;
			}
			if (canImpreg(slave, V.PC)) {
				r += knockMeUp(slave, 10, 2, -1, 1);
			}
		}
		else {
			if (!bothTimes) {
				V.vaginalTotal += 1;
				slave.vaginalCount += 1;
			}
			else {
				V.vaginalTotal += bothTimes;
				slave.vaginalCount += bothTimes;
			}
			if (canImpreg(slave, V.PC)) {
				r += knockMeUp(slave, 10, 0, -1, 1);
			}
		}
	}
	else if (canDoAnal(slave)) {
		if (slave.anus == 0) {
			r += `@@.lime;This breaks in ${slave.slaveName}'s virgin ass.@@ `;
			if (slave.devotion > 50 || slave.career == "a slave since birth") {
				r += `As it's her first time, you ease yourself into her butthole and gradually speed up your thrusts while she slowly learns to move her hips along with you. She moans loudly. `;
				if (slave.tankBaby == 2) {
					r += `She thinks of losing her anal virginity to her ${WrittenMaster(slave)} a @@.hotpink;necessity.@@ She expects her asshole to be seeing a lot more attention now.`;
				}
				else {
					r += `She thinks of losing her anal virginity to you as a @@.hotpink;connection@@ with her beloved ${WrittenMaster(slave)}. She looks forward to having her asshole fucked by you again.`;
				}
				slave.devotion += 4;
			}
			else if (slave.devotion > 20) {
				r += `As it's her first time, you ease yourself into her butthole and gradually increase the intensity of your thrusts. She accepts the pain and humiliation of anal sex as part of her sexual servitude, though she hopes that her next time will be less painful.`;
			}
			else if (slave.devotion >= -20) {
				r += `You force yourself into her butthole. She sobs and cries with disgust while you continue thrusting into her ass. She @@.gold;fears@@ her next anal sex, remembering the pain of losing her anal virginity. She dreads having her ass violated by you again.`;
				slave.trust -= 5;
			}
			else {
				r += `You force yourself into her butthole. She sobs and cries with disgust while you continue thrusting into her ass. She @@.mediumorchid;hates@@ and @@.gold;fears@@ you for violating her virgin butt. She dreads having her ass fucked by you again.`
				slave.trust -= 5;
				slave.devotion -= 5;
			}
			slave.anus = 1;
		}
		if (!analTimes) {
			V.analTotal += 1;
			slave.analCount += 1;
		}
		else {
			V.analTotal += analTimes;
			slave.analCount += analTimes;
		}
		if (canImpreg(slave, V.PC)) {
			r += knockMeUp(slave, 10, 1, -1, 1);
		}
	}
	return r;
}

/*
 times is how many times to increment either the Vaginal or the Anal counts, if there is no Vagina available.
 If left undefined it will assume it to be 1.
*/
window.SimpleVCheck = function SimpleVCheck(times) {
	let r = ``;
	if (canDoVaginal(State.variables.activeSlave)) {
		r += VaginalVCheck(times);
	}
	else if (canDoAnal(State.variables.activeSlave)) {
		r += AnalVCheck(times);
	}
	return r;
}

/*
 Before using this function, set $partner to the index of the partner in the $slaves array
 analTimes is how many times to increment the Anal counts, if there is no Vagina available.
 bothTimes is how many times to increment both holes counts (usually it is half of Anal).
 In both cases if left undefined it will assume it to be 1.
 This also checks for a valid Vagina/Accessory, though most code I've seen does this already, you
 never know when someone might use the routine and forget to do such.
*/
window.PartnerVCheck = function PartnerVCheck(analTimes, bothTimes) {
	const V = State.variables;
	const partner = V.slaves[V.partner];
	let r = ``;

	if (V.partner < 0 || V.partner >= V.slaves.length) {
		r += `@@.red;PartnerVCheck called with invalid partner '$partner' from passage ${passage()}.@@`;
	}
	else if (canDoVaginal(partner)) {
		if (partner.vagina === 0) {
			if (canDoAnal(partner) && partner.anus === 0) {
				r += `Since it's ${partner.slaveName}'s first time, you take your time and gently ease yourself into her pussy before gradually working your way into her butthole, alternating between her holes. @@.lime;This breaks in ${partner.slaveName}'s virgin holes.@@ `;
				partner.vagina = 1;
				partner.anus = 1;
			}
			else {
				r += `Since it's ${partner.slaveName}'s first time, you take your time and gently ease yourself into her pussy before gradually increasing the intensity of your thrusts. @@.lime;This breaks in ${partner.slaveName}'s virgin pussy.@@ `;
				partner.vagina = 1;
			}
		}
		else if (canDoAnal(partner) && partner.anus == 0) {
			r += `Since it's ${partner.slaveName}'s first time, you take your time and gently ease yourself into her butthole before gradually increasing the intensity of your thrusts into her ass. @@.lime;This breaks in ${partner.slaveName}'s virgin ass.@@ `;
			partner.anus = 1;
		}

		if (canDoAnal(partner)) {
			if (!bothTimes) {
				V.vaginalTotal += 1;
				V.analTotal += 1;
				partner.vaginalCount += 1;
				partner.analCount += 1;
			}
			else {
				V.vaginalTotal += bothTimes;
				V.analTotal += bothTimes;
				partner.vaginalCount += bothTimes;
				partner.analCount += bothTimes;
			}
			if (canImpreg(partner, V.PC)) {
				r += knockMeUp(partner, 10, 2, -1);
			}
		}
		else {
			if (!bothTimes) {
				V.vaginalTotal += 1;
				partner.vaginalCount += 1;
			}
			else {
				V.vaginalTotal += bothTimes;
				partner.vaginalCount += bothTimes;
			}
			if (canImpreg(partner, V.PC)) {
				r += knockMeUp(partner, 10, 0, -1);
			}
		}
	}
	else if (canDoAnal(partner)) {
		if (partner.anus === 0) {
			r += `Since it's ${partner.slaveName}'s first time, you take your time and gently ease yourself into her butthole before gradually increasing the intensity of your thrusts into her ass. @@.lime;This breaks in ${partner.slaveName}'s virgin ass.@@ `;
			partner.anus = 1;
		}
		if (!analTimes) {
			V.analTotal += 1;
			partner.analCount += 1;
		}
		else {
			V.analTotal += analTimes;
			partner.analCount += analTimes;
		}
		if (canImpreg(partner, V.PC)) {
			r += knockMeUp(partner, 10, 1, -1);
		}
	}
	return r;
}

/*
 count is how many times to increment either the Vaginal, Anal, or Oral counts, depending on availability of slave.
 If count is left undefined it will assume it to be 1.
 Intended to be a simple "I want to fuck x and not have to code a bunch of logic for it".
*/
window.SimpleSexAct = function SimpleSexAct(slave, count) {
	const V = State.variables;
	let fuckTarget = 0;
	let fuckCount = 1;
	let r = ``;
	if (count) {
		fuckCount = count;
	}
	for (var i = 0; i < fuckCount; i++) {
		fuckTarget = jsRandom(1,100);
		if (slave.nipples == "fuckable" && V.PC.dick === 1 && fuckTarget > 80) {
			V.mammaryTotal += 1;
			slave.mammaryCount += 1;
		}
		else if (canDoVaginal(slave) && slave.vagina > 0 && fuckTarget > 33) {
			V.vaginalTotal += 1;
			slave.vaginalCount += 1;
			if (canImpreg(slave, V.PC)) {
				r += knockMeUp(slave, 10, 0, -1, 1);
			}
		}
		else if (canDoAnal(slave) && slave.anus > 0 && fuckTarget > 10) {
			V.analTotal += 1;
			slave.analCount += 1;
			if (canImpreg(slave, V.PC)) {
				r += knockMeUp(slave, 10, 1, -1, 1);
			}
		}
		else {
			V.oralTotal += 1;
			slave.oralCount += 1;
		}
	}
	return r;
}

/*
 count is how many times to increment either the Vaginal, Anal, or Oral counts, depending on availability of slave.
 If count is left undefined it will assume it to be 1.
 Intended to be a simple "x got fucked y times and I don't want to keep coding it".
 Pregnancy chance is handled in saLongTermEffects.tw.
*/
window.SimpleSlaveFucking = function SimpleSlaveFucking(slave, count) {
	const V = State.variables;
	let fuckTarget = 0;
	let fuckCount = 1;
	if (count) {
		fuckCount = count;
	}
	for (var i = 0; i < fuckCount; i++) {
		fuckTarget = jsRandom(1,100);
		if (slave.nipples == "fuckable" && fuckTarget > 80) {
			V.mammaryTotal += 1;
			slave.mammaryCount += 1;
		}
		else if (canDoVaginal(slave) && slave.vagina > 0 && fuckTarget > 33) {
			V.vaginalTotal += 1;
			slave.vaginalCount += 1;
		}
		else if (canDoAnal(slave) && slave.anus > 0 && fuckTarget > 10) {
			V.analTotal += 1;
			slave.analCount += 1;
		}
		else {
			V.oralTotal += 1;
			slave.oralCount += 1;
		}
	}
	return;
}

/*
 count is how many times to increment either the Vaginal, Anal, or Oral counts, depending on availability of slave.
 If count is left undefined it will assume it to be 1.
 Intended to be a simple "x got fucked y times by z and I don't want to keep coding it".
*/
window.SimpleSlaveSlaveFucking = function SimpleSlaveSlaveFucking(subslave, domslave, count) {
	const V = State.variables;
	let fuckTarget = 0;
	let fuckCount = 1;
	let r = ``;
	if (count) {
		fuckCount = count;
	}
	for (var j = 0; j < fuckCount; j++) {
		//there is a reason randomization happens inside cycle - to spread fuck around, otherwise cycle isn't even needed
		fuckTarget = jsRandom(1,100);
		if (subslave.nipples === "fuckable" && canPenetrate(domslave) && fuckTarget > 80) {
			if (passage() === "SA serve your other slaves") {
				if (subslave.ID == V.slaves[V.i].ID) {
					V.slaves[V.i].mammaryCount++;
					V.mammaryTotal++;
					domslave.penetrativeCount++;
					V.penetrativeTotal++;
				}
				else {
					subslave.mammaryCount++;
					V.mammaryTotal++;
					V.slaves[V.i].penetrativeCount++;
					V.penetrativeTotal++;
				}
			}
			else {
				V.mammaryTotal++;
				V.penetrativeTotal++;
				subslave.mammaryCount++;
				domslave.penetrativeCount++;
			}
		}
		else if (canDoVaginal(subslave) && subslave.vagina > 0 && canPenetrate(domslave) && fuckTarget > 33) {
			if (passage() === "SA serve your other slaves") {
				if (subslave.ID == V.slaves[V.i].ID) {
					V.slaves[V.i].vaginalCount++;
					V.vaginalTotal++;
					V.penetrativeTotal++;
					domslave.penetrativeCount++;
				}
				else {
					V.slaves[V.i].penetrativeCount++;
					V.penetrativeTotal++;
					subslave.vaginalCount++;
					V.vaginalTotal++;
				}
			}
			else {
				V.vaginalTotal++;
				subslave.vaginalCount++;
				V.penetrativeTotal++;
				domslave.penetrativeCount++;
			}
			if (canImpreg(subslave, domslave)) {
				r += knockMeUp(subslave, 3, 0, domslave.ID, 1);
			}
		}
		else if (canDoAnal(subslave) && subslave.anus > 0 && canPenetrate(domslave) && fuckTarget > 10) {
			//i think would impregnate from anal here even without .mpreg? same in original widget too
			if (canImpreg(subslave, domslave) && subslave.mpreg == 1) {
				r += knockMeUp(subslave, 3, 1, domslave.ID, 1);
			}
			if (passage() === "SA serve your other slaves") {
				if (subslave.ID == V.slaves[V.i].ID) {
					V.slaves[V.i].analCount++;
					V.analTotal++;
					V.penetrativeTotal++;
					domslave.penetrativeCount++;
				}
				else {
					V.slaves[V.i].penetrativeCount++;
					V.penetrativeTotal++;
					V.analTotal++;
					subslave.analCount++;
				}
			}
			else {
				V.analTotal++;
				subslave.analCount++;
				V.penetrativeTotal++;
				domslave.penetrativeCount++;
			}
		}
		else {
			V.oralTotal++;
			subslave.oralCount++;
		}
	}
	return r;
}

window.SimpleVaginaFuck = function SimpleVaginaFuck(slave, count) {
	if (count) {
		State.variables.vaginalTotal += count;
		slave.vaginalCount += count;
	}
	else {
		State.variables.vaginalTotal++;
		slave.vaginalCount++;
	}
}

window.SimpleAssFuck = function SimpleAssFuck(slave, count) {
	if (count) {
		State.variables.analTotal += count;
		slave.analCount += count;
	}
	else {
		State.variables.analTotal++;
		slave.analCount++;
	}
}


code:
:: Slave Cost JS [script]

window.Beauty = (function() {
	"use strict";
	let V, arcology, beauty;

	function Beauty(slave) {
		V = State.variables;
		arcology = V.arcologies[0];
		modScore(slave);

		beauty = 120;
		calcInitBeauty(slave);
		if (slave.fuckdoll === 0) {
			beauty += 30;
			calcFaceBeauty(slave);
			calcTeethBeauty(slave);
			calcModBeauty(slave);
			calcCosmeticsBeauty(slave);
			calcFSNotFuckdollBeauty(slave);
			calcMiscNotFuckdollBeauty(slave);
		}
		if (slave.dick > 0) {
			calcDickBeauty(slave);
		}
		if (slave.balls > 0) {
			calcBallsBeauty(slave);
		}
		calcButtBeauty(slave);
		calcHipsBeauty(slave);
		calcBoobsBeauty(slave);
		calcWeightBeauty(slave);
		calcMusclesBeauty(slave);
		calcBodyHairBeauty(slave);
		calcImplantBeauty(slave);
		if (arcology.FSRepopulationFocus > 40) {
			calcRepopulationPregBeauty(slave);
		} else if (arcology.FSRestart > 40) {
			calcRestartPregBeauty(slave);
		}
		if (arcology.FSGenderRadicalistLawFuta !== 0) {
			calcFutaLawBeauty(slave);
		}
		calcBodyProportionBeauty(slave);
		calcVoiceBeauty(slave);
		if (slave.amp !== 0) {
			calcLimbsBeauty(slave);
		}
		calcPubertyBeauty(slave);
		calcFSMiscBeauty(slave);

		calcPurityBeauty(slave);
		calcPhysiqueBeauty(slave);
		if (arcology.FSSlimnessEnthusiastLaw === 1) {
			calcSlimBeauty(slave);
		}
		if (arcology.FSGenderFundamentalistLawBeauty + arcology.FSGenderRadicalistLawBeauty > 0) {
			calcGenderLawBeauty(slave);
		}

		calcMultipliersBeauty(slave);
		beauty = Math.max(1, Math.trunc(0.5*beauty));

		return beauty;
	};

	function calcInitBeauty(slave) {
		beauty -= slave.waist/20;
		beauty -= slave.muscles/30;
		beauty += slave.lips/10;
		beauty += slave.clit;
		beauty += (slave.height-160)/10;
		beauty += 2*slave.hips;
		if (slave.anus > 3) {
			beauty -= 10 + (slave.anus*2); /*-20*/
		}
		if (slave.vagina > 3) {
			beauty -= 10 + (slave.vagina*2); /*-20*/
		}

	};

	function calcFaceBeauty(slave) {
		beauty += slave.face/5;
		switch (slave.faceShape) {
			case "masculine":
				if (arcology.FSGenderRadicalist !== "unset") {
					beauty -= (2 - (arcology.FSGenderRadicalist/25))*(slave.face/30);
				} else if (arcology.FSGenderFundamentalist !== "unset") {
					beauty -= (2 + (arcology.FSGenderFundamentalist/25))*(slave.face/30);
				} else {
					beauty -= 2*(slave.face/30);
				}
				break;
			case "androgynous":
				if (arcology.FSGenderRadicalist !== "unset") {
					beauty += 2 - ((1 - (arcology.FSGenderRadicalist/25))*(slave.face/30));
				} else if (arcology.FSGenderFundamentalist !== "unset") {
					beauty += 2 - ((1 + (arcology.FSGenderFundamentalist/25))*(slave.face/30));
				} else {
					beauty += 2 - (slave.face/30);
				}
				break;
			case "exotic":
				beauty += 2*(slave.face/30);
				break;
			case "sensual":
				beauty += 2 + (slave.face/30);
				break;
			case "cute":
				beauty += 8/3;
				break;
		}
	};

	function calcTeethBeauty(slave) {
		switch (slave.teeth) {
			case "crooked":
				beauty -= 3;
				break;
			case "gapped":
				if (slave.faceShape == "cute") {
					beauty += 1;
				} else {
					beauty -= 1;
				}
				break;
			case "braces":
			case "cosmetic braces":
				if (slave.visualAge > 14 && slave.visualAge < 18) {
					beauty += 1;
				}
				break;
			case "removable":
			case "pointy":
			case "baby":
			case "mixed":
				beauty -= 1;
				break;
		}
	};

	function calcModBeauty(slave) {
		if (arcology.FSTransformationFetishist > 20 || arcology.FSDegradationist > 20) {
			if (V.modScore > 15 || (V.piercingScore > 8 && V.tatScore > 5)) {
				beauty += 8 + (V.modScore*0.25);
			} else if (V.modScore > 7) {
				beauty += V.modScore - 7;
			}
		} else if (arcology.FSBodyPurist > 20 || arcology.FSPaternalist > 20) {
			if (V.modScore <= 7) {
				beauty += 10;
			} else {
				beauty += 15 - V.modScore;
			}
		} else {
			if (V.modScore <= 7) {
				beauty += V.modScore;
			} else if (V.modScore > 15 || (V.piercingScore > 8 && V.tatScore > 5)) {
				beauty += 11;
			} else {
				beauty += 7 + (0.5*(V.modScore - 7));
			}
		}
	};

	function calcCosmeticsBeauty(slave) {
		if (slave.brand !== 0) {
			if (V.rep > 10000) {
				beauty += 1;
			} else if (V.rep < 5000) {
				beauty -= 1;
			}
		}
		if (slave.minorInjury !== 0) {
			beauty -= 2;
		}
		if (slave.cSec === 1) {
			beauty -= 2;
		}
		if (slave.nails > 0) {
			beauty += 1;
		}
		if (slave.makeup > 0) {
			beauty += 1;
		}
		switch (slave.markings) {
			case "beauty mark":
				if (slave.face > 40) {
					beauty += 6;
				} else if (slave.face < -10) {
					beauty -= 6;
				}
				break;
			case "birthmark":
				if (slave.prestige > 0 || slave.pornPrestige > 1) {
					beauty += 4;
				} else {
					beauty -= 4;
				}
				break;
			case "freckles":
			case "heavily freckled":
				if (slave.skin === "pale" || slave.skin === "fair") {
					beauty += 2;
					if (slave.hColor === "red") {
						beauty += 2;
					}
				}
				break;
		}
	};

	function calcFSNotFuckdollBeauty(slave) {
		if (arcology.FSSupremacist !== "unset") {
			if (slave.race === arcology.FSSupremacistRace) {
				beauty += (arcology.FSSupremacist/3) + (arcology.FSSupremacistLawME*10);
			}
		}
		if (arcology.FSSubjugationist !== "unset") {
			if (slave.race === arcology.FSSubjugationistRace) {
				beauty -= (arcology.FSSubjugationist/2) - (arcology.FSSubjugationistLawME*10);
			}
		}
		if (arcology.FSDegradationist !== "unset") {
			beauty -= (arcology.FSDegradationist/10)*((slave.intelligence + slave.intelligenceImplant)/20);
		}
		if (arcology.FSGenderFundamentalistLawBimbo === 1) {
			beauty -= (slave.intelligence + slave.intelligenceImplant)/2;
		}
		if (arcology.FSYouthPreferentialist !== "unset") {
			beauty += (30 - slave.visualAge)/(30 - V.minimumSlaveAge)*((arcology.FSYouthPreferentialist/2) + (arcology.FSYouthPreferentialistLaw*10)); /*max 60*/
		} else if (arcology.FSMaturityPreferentialist !== "unset") {
			if (V.retirementAge > 30) {
				beauty += (30 - slave.visualAge)/(30 - V.retirementAge)*((arcology.FSMaturityPreferentialist/2) + (arcology.FSMaturityPreferentialistLaw*10)); /*max 60, problems if retirementAge is 30 or under*/
			}
		}
		if (arcology.FSBodyPurist > 20) { /*bonus for virgin slaves*/
			if (slave.vagina === 0 && slave.vaginalCount === 0) {
				beauty += 30*(arcology.FSBodyPurist/100);
			}
			if (slave.anus === 0 && slave.analCount === 0) {
				beauty += 30*(arcology.FSBodyPurist/100);
			}
		}
		if (arcology.FSEdoRevivalist !== "unset") {
			if (slave.nationality === "Japanese" || slave.nationality === "Edo Revivalist") {
				beauty += arcology.FSEdoRevivalist/2;
			} else if (slave.race === "asian") {
				beauty += arcology.FSEdoRevivalist/5;
			} else {
				beauty -= arcology.FSEdoRevivalist/4;
			}
			if (V.language === "Japanese" && canTalk(slave)) {
				if (slave.accent > 1) {
					beauty -= arcology.FSEdoRevivalist/2;
				} else if (slave.accent > 0) {
					beauty -= arcology.FSEdoRevivalist/5;
				} else {
					beauty += arcology.FSEdoRevivalist/10;
				}
			}
		} else if (arcology.FSChineseRevivalist !== "unset") {
			if (slave.nationality === "Chinese" || slave.nationality === "Ancient Chinese Revivalist") {
				beauty += arcology.FSChineseRevivalist/2;
			} else if (slave.race === "asian") {
				beauty += arcology.FSChineseRevivalist/5;
			} else {
				beauty -= arcology.FSChineseRevivalist/4;
			}
			if (V.language === "Chinese" && canTalk(slave)) {
				if (slave.accent > 1) {
					beauty -= arcology.FSChineseRevivalist/2;
				} else if (slave.accent > 0) {
					beauty -= arcology.FSChineseRevivalist/5;
				} else {
					beauty += arcology.FSChineseRevivalist/10;
				}
			}
		}
	};

	function calcMiscNotFuckdollBeauty(slave) {
		beauty += Math.min(slave.health, 100)/5;
		beauty += slave.voice;
		beauty += (slave.intelligence + slave.intelligenceImplant)/10;
		beauty += slave.entertainSkill/10;
		beauty += slave.whoreSkill/10;
		beauty -= 3*slave.visualAge;
		if (setup.entertainmentCareers.includes(slave.career)) {
			beauty += 20;
		} else if (V.week - slave.weekAcquired >= 20 && slave.entertainSkill >= 100) {
			beauty += 10;
		}
		if (slave.race === "white" && slave.origRace === "white") {
			beauty += 4;
		} else if (slave.race === "white") {
			beauty += 2;
		}
	};

	function calcDickBeauty(slave) {
		if (arcology.FSAssetExpansionist > 20 && arcology.FSGenderFundamentalist === "unset") {
			if (slave.dick >= 20) {
				beauty += 17 + (slave.dick*(arcology.FSAssetExpansionist/500)); /*23*/
			} else if (slave.dick >= 10) {
				beauty += 10 + (slave.dick*(arcology.FSAssetExpansionist/300)); /*16.3*/
			} else if (slave.dick > 6) {
				beauty += slave.dick*(1 + (arcology.FSAssetExpansionist/100)); /*10*/
			}
		} else if (arcology.FSGenderFundamentalist !== "unset") {
			if (slave.dick > 0) {
				beauty += 3 - slave.dick;
			}
		} else if (arcology.FSGenderRadicalist !== "unset") {
			if (slave.dick > 20) {
				beauty += 20 + (slave.dick*(arcology.FSGenderRadicalist/400)); /*27.5*/
			} else if (slave.dick >= 10) {
				beauty += 10 + (slave.dick*(arcology.FSGenderRadicalist/200)); /*20*/
			} else if (slave.dick > 0) {
				beauty += slave.dick*(1 + (arcology.FSGenderRadicalist/100)); /*10*/
			}
		} else {
			beauty -= 2*slave.dick;
		}
	};

	function calcBallsBeauty(slave) {
		if (arcology.FSAssetExpansionist > 20 && arcology.FSGenderFundamentalist === "unset") {
			if (slave.balls > 100) {
				beauty += 41 + (slave.balls*(arcology.FSAssetExpansionist/500)); /*66*/
			} else if (slave.balls > 80) {
				beauty += 16 + (slave.balls*(arcology.FSAssetExpansionist/400)); /*41*/
			} else if (slave.balls > 60) {
				beauty += 6 + (slave.balls*(arcology.FSAssetExpansionist/800)); /*16*/
			} else if (slave.balls > 10) {
				beauty += slave.balls*((arcology.FSAssetExpansionist/1000)); /*6*/
			}
		} else if (arcology.FSGenderFundamentalist !== "unset") {
			if (slave.scrotum > 0) {
				beauty -= slave.balls*(1 + (arcology.FSGenderFundamentalist/200));
			}
		} else if (arcology.FSGenderRadicalist !== "unset") {
			if (slave.scrotum > 0) {
				if (slave.balls > 100) {
					beauty += 40 + (slave.balls*(arcology.FSGenderRadicalist/2000)); /*46.25*/
				} else if (slave.balls > 60) {
					beauty += 30 + (slave.balls*(arcology.FSGenderRadicalist/1000)); /*40*/
				} else if (slave.balls > 10) {
					beauty += 15 + (slave.balls*(arcology.FSGenderRadicalist/400)); /*30*/
				} else {
					beauty += slave.balls*(1 + (arcology.FSGenderRadicalist/200)); /*15*/
				}
			}
		} else {
			if (slave.scrotum > 0) {
				beauty -= slave.balls;
			}
		}
		if (arcology.FSRestart !== "unset") { /* Eugenics does not like slaves having working balls */
			if (slave.ballType === "human") {
				beauty -= slave.balls*(1 + (arcology.FSRestart/100));
			}
		}
	};

	function calcButtBeauty(slave) {
		if (slave.butt <= 10) {
			beauty += 1.5*slave.butt; /*max 15*/
		} else {
			beauty += 15 + (slave.butt/4); /*max 20*/
		}
		if ((arcology.FSTransformationFetishist > 20 && arcology.FSSlimnessEnthusiast === "unset") || arcology.FSAssetExpansionist > 20) {
			if (slave.butt <= 2) {
				beauty += 2*(slave.butt - 1); /*2*/
			} else if (slave.butt <= 4) {
				beauty += 2 + 1.5*(slave.butt - 2); /*5*/
			} else if (slave.butt <= 10) {
				beauty += 5 + 1*(slave.butt - 4); /*11*/
			} else {
				beauty += 7 + 0.5*(slave.butt - 5); /*14.5*/
			} /* maybe buff butts? */
		} else if (arcology.FSSlimnessEnthusiast > 20) {
			if (slave.butt <= 3) {
				beauty += 12 + 3*(slave.butt - 1); /*18 buff if asses get buffed*/
			} else if (slave.butt <= 5) {
				beauty += 9;
			} else {
				beauty -= 10 + 3*slave.butt; /*-70*/
			}
		} else {
			if (slave.butt <= 2) {
				beauty += 2*(slave.butt-1); /*2*/
			} else if (slave.butt <= 4) {
				beauty += 2 + (1.5*(slave.butt - 2)); /*5*/
			} else if (slave.butt <= 8) {
				beauty += 2 + (1.5*(slave.butt - 2)); /*11*/
			} else {
				beauty += 9;
			}
		}
		if (arcology.FSTransformationFetishist > 20) { /* the cost of using AE's values */
			if (arcology.FSSlimnessEnthusiast !== "unset") {
				if (slave.butt >= 3) {
					if (slave.buttImplant/slave.butt < 0.25) {
						beauty -= 2*(slave.butt - 1) + 10;
					}
				}
			} else {
				if (slave.butt >= 6) {
					if (slave.buttImplant/slave.butt < 0.50) {
						beauty -= (1.5*slave.butt) + 6; /* will get nasty at huge sizes */
					}
				}
			}
		}
	};

	function calcHipsBeauty(slave) { /* butts in general may need buffs */
		switch (slave.hips) {
			case -2:
				if (slave.butt > 2) {
					if (arcology.FSTransformationFetishist === "unset" && arcology.FSHedonisticDecadence === "unset") {
						beauty += 2 - slave.butt;
					} else {
						beauty += 1;
					}
				} else {
					beauty += 1;
				}
				break;
			case -1:
				if (slave.butt > 4) {
					if (arcology.FSTransformationFetishist === "unset" && arcology.FSHedonisticDecadence === "unset") {
						beauty += 4 - slave.butt;
					} else {
						beauty += 1;
					}
				} else {
					beauty += 1;
				}
				break;
			case 0:
				if (slave.butt > 6) {
					if (arcology.FSTransformationFetishist === "unset" && arcology.FSHedonisticDecadence === "unset") {
						beauty += 6 - slave.butt;
					} else {
						beauty += 1;
					}
				} else if (slave.butt <= 1) {
					beauty += slave.butt - 2;
				} else {
					beauty += 1;
				}
				break;
			case 1:
				if (slave.butt > 8) {
					if (arcology.FSTransformationFetishist === "unset" && arcology.FSHedonisticDecadence === "unset") {
						beauty += 8 - slave.butt;
					} else {
						beauty += 1;
					}
				} else if (slave.butt <= 2) {
					beauty += slave.butt - 3;
				} else {
					beauty += 1;
				}
				break;
			case 2:
				if (slave.butt <= 3) {
					beauty += slave.butt - 4;
				} else {
					beauty += 1;
				}
				break;
			case 3:
				if (slave.butt <= 8) {
					beauty += slave.butt - 8;
				} else {
					beauty += 1;
				}
				break;
		}
	};

	function calcBoobsBeauty(slave) {
		if ((arcology.FSTransformationFetishist > 20 && arcology.FSSlimnessEnthusiast === "unset") || arcology.FSAssetExpansionist > 20) {
			if (slave.boobs <= 500) {
				beauty += 0.02*(slave.boobs - 250); /*5*/
			} else if (slave.boobs <= 1500) {
				beauty += 5 + 0.015*(slave.boobs - 500); /*20*/
			} else if (slave.boobs <= 3000) {
				beauty += 20 + 0.01*(slave.boobs - 1500); /*42.5*/
			} else if (slave.boobs <= 25000) {
				beauty += 50 + 0.005*(slave.boobs - 3000); /*160 - this might need to be lowered. Maybe drop the 50? Otherwise break it down more.*/
			} else {
				beauty += 145 + 0.001*(slave.boobs - 10000); /* 185 */
			}
		} else if (arcology.FSSlimnessEnthusiast > 20) {
			if (slave.boobs <= 500) {
				beauty += 0.08*(slave.boobs); /*40 - buff me to be in line with higher end asset exp*/
			} else if (slave.boobs <= 1000) {
				beauty += 10;
			} else if (slave.boobs <= 3000) {
				beauty += 5;
			} else {
				beauty -= 5 + 0.005*(slave.boobs - 3000); /*-110*/
			}
		} else {
			if (slave.boobs <= 1200) {
				beauty += 0.02*(slave.boobs - 200); /*20*/
			} else if (slave.boobs <= 2400) {
				beauty += 20 + (0.01*(slave.boobs - 1200)); /*32*/
			} else if (slave.boobs <= 3600) {
				beauty += 32 + (0.005*(slave.boobs - 2400)); /*38*/
			} else if (slave.boobs <= 10000) {
				beauty += 38;
			} else if (slave.boobs <= 25000) {
				beauty += 30;
			} else {
				beauty += 20;
			}
		}
		if (arcology.FSTransformationFetishist > 20) { /* the cost of using AE's values */
			if (arcology.FSSlimnessEnthusiast !== "unset") {
				if (slave.boobs >= 400) {
					if (slave.boobs >= 10000) {
						if (slave.boobsImplant/slave.boobs < 0.75) {
							beauty -= (0.05*slave.boobs) + 10;
						}
					} else if (slave.boobs >= 2000) {
						if (slave.boobsImplant/slave.boobs < 0.50) {
							beauty -= (0.05*slave.boobs) + 10;
						}
					} else if (slave.boobs >= 1000) {
						if (slave.boobsImplant/slave.boobs < 0.25) {
							beauty -= (0.05*slave.boobs) + 10;
						}
					} else {
						if (slave.boobsImplant/slave.boobs < 0.10) {
							beauty -= (0.05*slave.boobs) + 10;
						}
					}
				}
			} else {
				if (slave.boobs >= 600) {
					if (slave.boobs >= 10000) {
						if (slave.boobsImplant/slave.boobs < 0.75) {
							beauty -= 30 + (0.005*slave.boobs); /* will get nasty at huge sizes */
						}
					} else if (slave.boobs >= 2000) {
						if (slave.boobsImplant/slave.boobs < 0.50) {
							beauty -= 30 + (0.005*slave.boobs); /* will get nasty at huge sizes */
						}
					} else if (slave.boobs >= 1000) {
						if (slave.boobsImplant/slave.boobs < 0.25) {
							beauty -= 30 + (0.005*slave.boobs); /* will get nasty at huge sizes */
						}
					} else {
						if (slave.boobsImplant/slave.boobs < 0.10) {
							beauty -= 30 + (0.005*slave.boobs); /* will get nasty at huge sizes */
						}
					}
				}
			}
		}
		if (slave.boobs > 250) {
			if (slave.boobShape === "perky") {
				beauty += 6;
			} else if (slave.boobShape === "torpedo-shaped") {
				beauty += 6;
			} else if (slave.boobShape === "downward-facing") {
				beauty -= 4;
			} else if (slave.boobShape === "saggy") {
				beauty -= 4;
			}
		}
		if (slave.nipples === "huge") {
			beauty += 4;
		} else if (slave.nipples === "inverted") {
			beauty += 2;
		} else if (slave.nipples === "puffy") {
			beauty += 2;
		} else if (slave.nipples === "tiny") {
			beauty -= 2;
		} else if (slave.nipples === "fuckable") {
			if (arcology.FSTransformationFetishist !== "unset") {
				beauty += arcology.FSTransformationFetishist/10;
			}
		}
	};

	function calcWeightBeauty(slave) {
		if (arcology.FSHedonisticDecadence > 20) {
			if (slave.weight < -95) {
				beauty += -70 + (slave.weight/10); /*-80*/
			} else if (slave.weight < -30) {
				beauty += -30 + (slave.weight/3); /*-61*/
			} else if (slave.weight < -10) {
				beauty += (slave.weight); /*-30*/
			} else if (slave.weight <= 10) {
				/* no effect */
			} else if (slave.weight <= 30) {
				beauty += (slave.weight/2); /*15*/
			} else if (slave.weight <= 95) {
				beauty += 15 + (slave.weight/7); /*28.5*/
			} else if (slave.weight <= 130) {
				beauty += 28 + (slave.weight/10); /*41*/
			} else if (slave.weight <= 160) {
				beauty += 42 + (slave.weight/20); /*50*/
			} else if (slave.weight <= 190) {
				beauty += 50 - (slave.weight/25); /*42.5*/
			} else {
				beauty += 40 - (slave.weight/20); /*30*/
			}
		} else {
			if (slave.weight > 130) {
				beauty -= Math.abs(slave.weight)/5;
			} else if (slave.hips === 3) {
				if (slave.weight < -10) {
					beauty -= Math.abs(slave.weight)/10;
				}
			} else if (slave.hips === 2) {
				if (slave.weight > 95) {
					beauty -= Math.abs(slave.weight)/15;
				} else if (slave.weight < -30) {
					beauty -= Math.abs(slave.weight)/10;
				}
			} else if (slave.hips === -2) {
				if (slave.weight < -95 || slave.weight > 30) {
					beauty -= Math.abs(slave.weight)/10;
				}
			} else {
				if (Math.abs(slave.weight) > 30) {
					beauty -= Math.abs(slave.weight)/10;
				}
			}
		}
		if (arcology.FSPhysicalIdealist !== "unset") {
			if (arcology.FSPhysicalIdealistStrongFat === 1) {
				if (slave.weight > 10 && slave.weight <= 130) {
					beauty += slave.weight*(arcology.FSPhysicalIdealist/200); /*65*/
				} else {
					beauty -= Math.abs(slave.weight)/2;
				}
			}
		}
	};

	function calcMusclesBeauty(slave) {
		if (arcology.FSPhysicalIdealist !== "unset") {
			if (arcology.FSPhysicalIdealistLaw === 1) {
				if (Math.abs(slave.weight) <= 30 && slave.health >= 20 && slave.muscles >= 20 && slave.muscles <= 50) {
					beauty += (slave.muscles + (Math.min(slave.health,300)/5))*(arcology.FSPhysicalIdealist/100);
				} else {
					beauty -= 30;
				}
			} else {
				if (slave.muscles > 30 || slave.muscles <= -5) {
					beauty += slave.muscles*(arcology.FSPhysicalIdealist/120); /*+-83*/
				}
			}
		} else if (arcology.FSHedonisticDecadence !== "unset") {
			if (slave.muscles < -10) {
				beauty += Math.abs(slave.muscles)*(arcology.FSHedonisticDecadence/160); /*62.5*/
			} else if (slave.muscles > 5) {
				if (arcology.FSHedonisticDecadenceStrongFat === 1) {
					beauty += slave.muscles*(arcology.FSHedonisticDecadence/200); /*50*/
				} else {
					beauty -= slave.muscles*(arcology.FSHedonisticDecadence/200); /*-50*/
				}
			}
		}
	};

	function calcBodyHairBeauty(slave) {
		if (slave.physicalAge < 11) {
			beauty += 4;
		} else if (slave.physicalAge >= 13) {
			switch (slave.underArmHStyle) {
				case "hairless":
				case "bald":
				case "waxed":
				case "shaved":
					beauty += 2;
					break;
				case "bushy":
					if (arcology.FSBodyPurist > 0) {
						beauty += 4;
					} else {
						beauty -= 2;
					}
					break;
			}
			switch (slave.pubicHStyle) {
				case "hairless":
				case "bald":
				case "waxed":
					beauty += 2;
					break;
				case "bushy":
					if (arcology.FSBodyPurist > 0) {
						beauty += 2;
					} else {
						beauty -= 4;
					}
					break;
				case "bushy in the front and neat in the rear":
					if (arcology.FSBodyPurist > 0) {
						beauty += 4;
					} else {
						beauty -= 2;
					}
					break;
				case "very bushy":
					if (arcology.FSBodyPurist > 0) {
						beauty += 2;
					} else {
						beauty -= 6;
					}
					break;
			}
		}
	};

	function calcImplantBeauty(slave) {
		if (arcology.FSTransformationFetishist !== "unset") {
			if (Math.abs(slave.shouldersImplant) > 1) {
				beauty += (arcology.FSTransformationFetishist/20) + Math.abs(slave.shouldersImplant);
			}
			if (Math.abs(slave.hipsImplant) > 1) {
				beauty += (arcology.FSTransformationFetishist/20) + Math.abs(slave.hipsImplant);
			}
			if (slave.race !== slave.origRace) {
				beauty += arcology.FSTransformationFetishist/20;
			}
			if (slave.faceImplant > 95 && slave.face > 40) {
				beauty += arcology.FSTransformationFetishist/4;
			}
		} else if (arcology.FSBodyPurist !== "unset") {
			if (slave.faceImplant > 5) {
				beauty -= (arcology.FSBodyPurist/100)*(slave.faceImplant/10);
			}
			if (slave.race === slave.origRace) {
				beauty -= arcology.FSBodyPurist/20;
			}
		} else {
			if (slave.faceImplant > 30) {
				beauty -= (slave.faceImplant - 30)/10;
			}
		}
	};

	function calcRepopulationPregBeauty(slave) {
		if (slave.preg > 30) { /*limited huge boost for full term */
			if (slave.broodmother > 0) {
				beauty += 0.4*(slave.broodmother*arcology.FSRepopulationFocus); /*40-80 limited due to constant presence. Also good breeders, but subpar mothers*/
			} else if (slave.bellyPreg >= 600000) {
				beauty += 1.5*arcology.FSRepopulationFocus; /*150*/
			} else if (slave.bellyPreg >= 300000) {
				beauty += arcology.FSRepopulationFocus; /*100*/
			} else if (slave.bellyPreg >= 120000) {
				beauty += 0.9*arcology.FSRepopulationFocus; /*90*/
			} else {
				beauty += 0.8*arcology.FSRepopulationFocus; /*80*/
			}
		} else if (slave.preg > 20) {
			if (slave.pregType >= 20) {
				beauty += 10*(arcology.FSRepopulationFocus/40); /*25*/
			} else if (slave.pregType >= 10) {
				beauty += 9*(arcology.FSRepopulationFocus/40); /*22.5*/
			} else {
				beauty += 8*(arcology.FSRepopulationFocus/40); /*20*/
			}
		} else if (slave.preg > 10) {
			if (slave.pregType >= 20) {
				beauty += arcology.FSRepopulationFocus/5; /*20*/
			} else if (slave.pregType >= 10) {
				beauty += arcology.FSRepopulationFocus/6.25; /*16*/
			} else {
				beauty += arcology.FSRepopulationFocus/10; /*10*/
			}
		} else if (slave.pregWeek < 0) {
			beauty += arcology.FSRepopulationFocus/10; /*10*/
		} else if (slave.preg > 0 && slave.collar === "preg biometrics") {
			beauty += arcology.FSRepopulationFocus/12; /*8.33*/
		} else {
			beauty -= arcology.FSRepopulationFocus/2.5; /*-40*/
		}
		if (slave.births > 50) {
			beauty += arcology.FSRepopulationFocus/1.5; /*66.6*/
		} else {
			beauty += slave.births*(arcology.FSRepopulationFocus/75);
		}
	};

	function calcRestartPregBeauty(slave) {
		if (slave.breedingMark === 1 && V.propOutcome === 1) {
			if (slave.preg > 5 && slave.pregSource === -1) {
				beauty += arcology.FSRestart; /*100*/
			}
		} else {
			if (slave.preg > 30) {
				if (slave.bellyPreg >= 600000) {
					beauty -= 2.5*arcology.FSRestart; /*-250*/
				} else if (slave.bellyPreg >= 300000) {
					beauty -= 1.25*arcology.FSRestart; /*-125*/
				} else if (slave.bellyPreg >= 120000) {
					beauty -= arcology.FSRestart; /*-100*/
				} else {
					beauty -= 0.75*arcology.FSRestart; /*-75*/
				}
			} else if (slave.preg > 20) {
				if (slave.pregType >= 20) {
					beauty -= arcology.FSRestart/1.5; /*-66.6*/
				} else if (slave.pregType >= 10) {
					beauty -= arcology.FSRestart/2; /*-50*/
				} else {
					beauty -= arcology.FSRestart/3; /*-33.3*/
				}
			} else if (slave.preg > 10) {
				if (slave.pregType >= 20) {
					beauty -= 3*(arcology.FSRestart/8); /*-37.5*/
				} else if (slave.pregType >= 10) {
					beauty -= arcology.FSRestart/4; /*-25*/
				} else {
					beauty -= arcology.FSRestart/8; /*-12.5*/
				}
			} else if (slave.preg === -2) {
				beauty += arcology.FSRestart/7; /*14.2*/
			} else if (slave.preg < 1) {
				beauty += arcology.FSRestart/5; /*20*/
			}
			if (slave.births > 50) {
				beauty -= arcology.FSRestart; /*-100*/
			} else {
				beauty -= slave.births*(arcology.FSRestart/50);
			}
		}
	};

	function calcFutaLawBeauty(slave) {
		switch (arcology.FSGenderRadicalistLawFuta) {
			case 1:
				if (slave.dick > 0 && slave.vagina > -1) { /* herms */
					calcFutaLawTrueFutaBeauty(slave);
				}
				break;
			case 2:
				if (canAchieveErection(slave) && slave.balls > 0 && slave.scrotum > 0) { /* erection! */
					calcFutaLawBigDickBeauty(slave);
				}
				break;
			case 3:
				calcFutaLawBigBootyBeauty(slave);
				break;
			case 4:
				if (slave.dick > 0 && slave.vagina === -1 && slave.faceShape !== "masculine") {
					if (slave.boobs < 500 && slave.dick < 4 && slave.balls < 4) {
						calcFutaLawFemboyBeauty(slave);
					}
				}
				break;
		}
	};

	function calcFutaLawTrueFutaBeauty(slave) {
		if (slave.dick <= 10) {
			beauty += slave.dick;
		} else if (slave.dick > 20) {
			beauty += 2;
		} else {
			beauty += 4;
		}
	};

	function calcFutaLawBigDickBeauty(slave) {
		beauty += slave.dick;
		if (slave.balls > 120) {
			beauty += 14;
		} else if (slave.balls > 100) {
			beauty += 12;
		} else if (slave.balls > 80) {
			beauty += 10;
		} else if (slave.balls > 60) {
			beauty += 8;
		} else if (slave.balls > 40) {
			beauty += 6;
		} else if (slave.balls > 20) {
			beauty += 4;
		} else if (slave.balls > 10) {
			beauty += 2;
		} else {
			beauty += slave.balls;
		}
	};

	function calcFutaLawBigBootyBeauty(slave) {
		if (slave.hips >= 1) {
			beauty += 4*(slave.hips - 1); /*8*/
			if (arcology.FSSlimnessEnthusiast !== "unset") {
				beauty += 4*(slave.hips - 1); /*8*/ /* offsets the malus for big butts */
			}
		}
		if (slave.analSkill > 60 && slave.anus >= 2) {
			beauty += 2*(slave.anus-2); /*6*/
			if (arcology.FSSlimnessEnthusiast != "unset") {
				beauty += 2*(slave.anus-2); /*6*/ /* offsets the malus for big butts */
			}
		}
		if (slave.butt >= 5) {
			beauty += (slave.butt - 5); /*15*/
		}
	};

	function calcFutaLawFemboyBeauty(slave) {
		if (arcology.FSSlimnessEnthusiast === "unset") { /*balance with slimness*/
			beauty += 20;
			if (slave.boobs < 300) {
				beauty += 12;
			} else if (slave.boobs < 400) {
				beauty += 6;
			}
		}
		if (slave.dick === 1) {
			beauty += 12;
		} else if (slave.dick === 2) {
			beauty += 6;
		}
		if (slave.balls <= 2) {
			beauty += 8;
		}
		if (slave.faceShape === "cute" && slave.face > 0) { /*uggos need not apply, maybe a small boost for other faceShapes*/
			beauty += ((arcology.FSGenderRadicalist/25)*(slave.face/30)) - 2; /*gives a slightly better boost than androgynous does with gendrad boost, 15.3*/
		}
		if (slave.nipples === "tiny") {
			beauty += 5;
		} else if (slave.nipples === "cute") {
			beauty += 2;
		} else {
			beauty -= 5;
		}
	};

	function calcBodyProportionBeauty(slave) {
		if (arcology.FSGenderFundamentalist !== "unset") {
			if (slave.shoulders > slave.hips) {
				if (slave.boobs <= 2000*(slave.shoulders - slave.hips)) {
					beauty -= (slave.shoulders - slave.hips)*(1 + (arcology.FSGenderFundamentalist/200));
				}
			}
		} else if (arcology.FSGenderRadicalist === "unset") {
			if (slave.shoulders > slave.hips) {
				if (slave.boobs <= 2000*(slave.shoulders - slave.hips)) {
					beauty -= slave.shoulders - slave.hips;
				}
			}
		}
	};

	function calcVoiceBeauty(slave) {
		if (canTalk(slave)) {
			if (slave.accent >= 3) {
				beauty -= 1;
			} else if (slave.accent === 1) {
				beauty += 1;
			}
		} else {
			beauty -= 2;
		}
	};

	function calcLimbsBeauty(slave) {
		switch (slave.amp) {
			case 1:
				beauty -= 10;
				break;
			case -1:
			case -2:
			case -4:
				beauty -= 2;
				break;
		}
	};

	function calcPubertyBeauty(slave) {
		if (slave.pubertyXX === 1) {
			beauty += 5;
		}
		if (slave.pubertyXY === 0 && slave.physicalAge > V.potencyAge && slave.balls > 0) {
			beauty += 10;
			if (arcology.FSGenderFundamentalist !== "unset") {
				beauty += 5;
			}
		}
	};

	function calcFSMiscBeauty(slave) {
		if (arcology.FSTransformationFetishist > 20) {
			if (slave.lips > 70) {
				if (slave.lipsImplant/slave.lips < 0.5) {
					beauty -= ((slave.lips/10) + (arcology.FSTransformationFetishist/20));
				}
			}
			if (slave.hips === 3) {
				beauty += 10;
			}
		}
		if ((arcology.FSGenderRadicalist > 20 && arcology.FSGenderRadicalistLawFuta !== 3) || arcology.FSSlimnessEnthusiast > 20) {
			if (slave.hips < 0) {
				beauty += Math.abs(slave.hips);
			}
		}
		if (arcology.FSPhysicalIdealist !== "unset") {
			if (slave.height > Height.mean(slave)) {
				beauty += 10;
			}
		}
		if (arcology.FSHedonisticDecadenceLaw2 === 1) {
			if (slave.boobs >= 2000 && slave.butt >= 5 && slave.weight > 95) {
				beauty += 5 + (arcology.FSHedonisticDecadence/20); /*10*/
			} else {
				beauty -= 15 + (arcology.FSHedonisticDecadence/20); /*-20*/
			}
		}
		if (arcology.FSChattelReligionistCreed === 1) {
			if (V.nicaeaAssignment === slave.assignment) {
				beauty += 2*V.nicaeaPower;
			}
		}
	};

	function calcPurityBeauty(slave) {
		if (isPure(slave)) {
			V.pure = V.pure++ || 1;
			if (arcology.FSBodyPurist !== "unset") {
				beauty += arcology.FSBodyPurist/5;
			}
			if (arcology.FSTransformationFetishist === "unset") {
				beauty += 2;
			}
		} else if (arcology.FSTransformationFetishist !== "unset") {
			beauty += arcology.FSTransformationFetishist/40;
		}
	};

	function calcPhysiqueBeauty(slave) {
		let physiquePass = 0;

		if (slave.boobs < 500 && slave.butt < 3) {
			if (slave.muscles <= 30 && arcology.FSPhysicalIdealist === "unset" && slave.weight <= 10 && arcology.FSHedonisticDecadence === "unset") {
				physiquePass = 1;
			} else if (arcology.FSPhysicalIdealist !== "unset") { /* no muscle malus for muscle loving societies */
				if (arcology.FSPhysicalIdealistStrongFat === 1 && slave.weight <= 30) { /* reduced weight malus for fat loving societies */
					physiquePass = 1;
				} else if (slave.weight <= 10) {
					physiquePass = 1;
				}
			} else if (arcology.FSHedonisticDecadence !== "unset" && slave.weight <= 30) { /* reduced weight malus for fat loving societies */
				if (arcology.FSHedonisticDecadenceStrongFat === 1) { /* no muscle malus for muscle loving societies */
					physiquePass = 1;
				} else if (slave.muscles <= 30) {
					physiquePass = 1;
				}
			}
		}
		if (physiquePass === 1) {
			beauty += 40;
			if (arcology.FSSlimnessEnthusiast > 20) {
				beauty += arcology.FSSlimnessEnthusiast/20;
				if (canTalk(slave) && slave.voice === 3) {
					beauty += arcology.FSSlimnessEnthusiast/40;
				}
			}
		} else if (slave.butt > 4 && slave.boobs > 800) {
			if (arcology.FSSlimnessEnthusiast === "unset") {
				beauty += 1;
			}
			if (arcology.FSAssetExpansionist > 20) {
				beauty += arcology.FSAssetExpansionist/20;
				if (canTalk(slave) && slave.voice === 3) {
					beauty += arcology.FSAssetExpansionist/40;
				}
			}
		}
	};

	function calcSlimBeauty(slave) {
		if (slimPass(slave) === 1) {
			beauty += 40 + (arcology.FSSlimnessEnthusiast/20); /*45*/
		} else {
			beauty -= arcology.FSSlimnessEnthusiast/20;
		}
	};

	function calcGenderLawBeauty(slave) {
		V.genderLawPass = 1;

		if (arcology.FSPhysicalIdealist === "unset" && arcology.FSHedonisticDecadenceStrongFat === 0 && slave.muscles > 30) { /*muscle check*/
			V.genderLawPass = 0;
		} else if (arcology.FSHedonisticDecadence !== "unset" || arcology.FSPhysicalIdealistStrongFat === 1) { /*weight check*/
			if (slave.weight > 130 || slave.weight <= -30) {
				V.genderLawPass = 0;
			}
		} else if (Math.abs(slave.weight) > 30) {
			V.genderLawPass = 0;
		} else if (arcology.FSAssetExpansionist !== "unset") {
			if (slave.boobs < 500 || slave.boobs > 1600 || slave.butt < 3 || slave.butt > 6) {
				V.genderLawPass = 0;
			}
		} else if (slave.boobs < 500 || slave.boobs > 800 || slave.butt < 3 || slave.butt > 4) {
			V.genderLawPass = 0;
		}
		if (V.genderLawPass === 1) {
			beauty += 60;
		} else {
			beauty -= 10;
		}
	};

	function calcMultipliersBeauty(slave) {
		calcBellyBeauty(slave);
		if (arcology.FSGenderRadicalist !== "unset") {
			if (slave.bellyPreg >= 500 && arcology.FSRepopulationFocus === "unset" && arcology.FSRestart === "unset") {
				if (slave.mpreg === 1) {
					beauty = 0.9*beauty;
				} else {
					beauty = 0.7*beauty;
				}
			}
		} else if (arcology.FSGenderFundamentalist === "unset") {
			if (slave.preg > 10 && arcology.FSRepopulationFocus === "unset" && arcology.FSRestart === "unset") {
				beauty = 0.8*beauty;
			}
		}
		if (slave.breedingMark === 1) {
			if (V.propOutcome === 1) {
				beauty = 2*beauty;
			} else {
				beauty += 2;
			}
		}
		if (slave.fuckdoll === 0 && V.seeAge === 1) {
			calcAgeBeauty(slave);
		}
		if (slave.prestige + slave.pornPrestige > 0) {
			calcPrestigeBeauty(slave);
		}
	};

	function calcBellyBeauty(slave) {
		if (slave.bellySag > 0) {
			if (slave.belly < 100) {
				if (arcology.FSRepopulationFocus === "unset") {
					beauty -= 20;
				}
			}
		}
		if (slave.bellyImplant >= 1500) {
			if (arcology.FSTransformationFetishist > 20) {
				beauty += Math.min(Math.trunc(slave.bellyImplant/1000), 50); /*50*/
			} else if (arcology.FSRepopulationFocus > 60) {
				if ((slave.ovaries === 0 && slave.mpreg === 0) || slave.preg < -1) {
					beauty += 20;
				}
			} else {
				if (slave.bellyImplant >= 750000) { /* multipliers */
					beauty = 0.2*beauty;
				} else if (slave.bellyImplant >= 450000) {
					beauty = 0.5*beauty;
				} else if (slave.bellyImplant >= 300000) {
					beauty = 0.7*beauty;
				} else if (slave.bellyImplant >= 100000) {
					beauty = 0.8*beauty;
				} else if (slave.bellyImplant >= 50000) {
					beauty = 0.85*beauty;
				} else {
					beauty = 0.9*beauty;
				}
			}
		}
	};

	function calcAgeBeauty(slave) {
		if (slave.physicalAge === V.minimumSlaveAge) {
			beauty += 1;
			if (slave.physicalAge === V.fertilityAge && canGetPregnant(slave) && (arcology.FSRepopulationFocus !== "unset" || arcology.FSGenderFundamentalist !== "unset") && arcology.FSRestart === "unset") {
				if (slave.birthWeek === 0) {
					beauty += 1.6*beauty;
				} else if (slave.birthWeek < 4) {
					beauty += 0.2*beauty;
				}
			} else {
				if (slave.birthWeek === 0) {
					beauty += 0.8*beauty;
				} else if (slave.birthWeek < 4) {
					beauty += 0.1*beauty;
				}
			}
		} else if (slave.physicalAge === V.fertilityAge && canGetPregnant(slave) && (arcology.FSRepopulationFocus !== "unset" || arcology.FSGenderFundamentalist !== "unset") && arcology.FSRestart === "unset") {
			beauty += 1;
			if (slave.birthWeek === 0) {
				beauty += 0.8*beauty;
			} else if (slave.birthWeek < 4) {
				beauty += 0.1*beauty;
			}
		}
	};

	function calcPrestigeBeauty(slave) { /* multipliers */
		if (slave.prestige >= 3) {
			beauty += 2*beauty;
		} else if (slave.prestige === 2) {
			beauty += 0.5*beauty;
		} else if (slave.prestige === 1) {
			beauty += 0.25*beauty;
		}
		if (slave.pornPrestige === 3) {
			beauty += beauty;
		} else if (slave.pornPrestige === 2) {
			beauty += 0.5*beauty;
		} else if (slave.pornPrestige === 1) {
			beauty += 0.1*beauty;
		}
	};

	return Beauty;
})();

// this is a port of the FResult widget
// it has been broken up into several functions, because it grew too long
// it has been wrapped in a closure so as not to pollute the global namespace
// and so that nested functions are only evaluated once

window.FResult = (function() {
	"use strict";
	// we can't initialise our global variables on load, because SugarCube.State isn't initialised
	// instead, declare them and initialise on run time
	let V, result, incest_bonus;
	function FResult(slave) {
		V = State.variables;
		incest_bonus = V.arcologies[0].FSEgyptianRevivalist > 20 || V.arcologies[0].FSEgyptianRevivalistIncestPolicy === 1;

		calcUseWeights(slave);
		if (!slave.fuckdoll)
			calcNotFuckdoll(slave);
		else
			result += slave.fuckdoll/10;

		result += Math.max(0, slave.aphrodisiacs) * 2;

		if (slave.inflationType === "aphrodisiac")
			result += slave.inflation*4;

		if (slave.lactation > 0)
			result += 1;

		if (slave.nipples === "fuckable")
			calcFuckableTits(slave);

		if (V.seeAge === 1)
			calcAge(slave);
		if (slave.fetish === "mindbroken")
			result = Math.trunc(result*0.4);
		else
			result = Math.trunc(result*0.7);

		if (slave.pregWeek < 0)
			result -= Math.trunc(result*slave.pregWeek/10); // reduced the most just after birth

		calcAmputation(slave);

		if (V.arcologies[0].FSHedonisticDecadence > 20)
			calcHedonismWeight(slave);
		if (result < 2) {
			if (supremeRaceP(slave) && V.arcologies[0].FSSupremacist > 20)
				result = 0;
			else
				result = 2;
		}
		return result;
	}

	function calcUseWeights(slave) {
		result = (3 - slave.anus)+(slave.muscles/30);
		if (slave.muscles < -95)
			result -= 5;
		else if (slave.muscles < -30)
			result -= 2;

		const uses = V.oralUseWeight + V.vaginalUseWeight + V.analUseWeight;
		if (uses <= 0) return;

		result += (6+slave.tonguePiercing) * (V.oralUseWeight/uses) * (slave.oralSkill/30);
		if (slave.sexualFlaw === "cum addict")
			result += (V.oralUseWeight/uses) * (slave.oralSkill/30);
		if (canDoVaginal(slave)) {
			result += 6 * (V.vaginalUseWeight/uses) * (slave.vaginalSkill/30);
			result += (3 - slave.vagina);
			result += slave.vaginaLube;
		}
		if (canDoAnal(slave)) {
			result += 6 * (V.analUseWeight/uses) * (slave.analSkill/30);
			if (slave.sexualFlaw === "anal addict")
				result += (V.analUseWeight/uses) * (slave.analSkill/30);
			if (slave.inflationType === "aphrodisiac")
				result += (V.analUseWeight/uses) * (slave.inflation * 3);
		}
	}

	function calcFuckableTits(slave) {
		result += 2;
		if (slave.fetish === "boobs")
			result += Math.trunc(slave.fetishStrength/20);
	}

	function calcWorksWithRelatives(slave) {
		V.slaves.forEach(islave => {
			if (isParentP(slave, islave) && sameAssignmentP(slave, islave)) {
				result += 1;
				if (incest_bonus) result += 1;
			}
			if (areSisters(slave, islave) > 0 && sameAssignmentP(slave, islave)) {
				result += 1;
				if (incest_bonus) result += 1;
			}
		});
	}

	function calcWorksWithRelativesVanilla(slave) {
		const fre = getSlave(slave.relationTarget);
		if (fre !== undefined && sameAssignmentP(slave, fre)) {
			result += 2;
			if (incest_bonus) result += 2;
		}
	}

	function calcWorksWithRelationship(slave) {
		const fre = V.slaves.findIndex(s => {
			return haveRelationshipP(slave, s) && sameAssignmentP(slave, s);
		});
		if (fre !== -1) result += 1;
	}

	function calcWorksWithRival(slave) {
		const en = getSlave(slave.rivalryTarget);
		if (en !== undefined && sameAssignmentP(slave, en)) result -= 1;
	}

	function calcHInjectionsDiet(slave) {
		if (slave.drugs === "male hormone injections" || slave.drugs === "female hormone injections")
			result -= 10;
		if (slave.diet === "XXY")
			result += 2;
		else if (slave.diet === "XY" || slave.diet === "XX")
			result += 1;
		else if (slave.diet === "cum production")
			result += 1;
		else if (slave.diet === "fertility")
			result += 1;
	}
	function calcPreg(slave) {
		if (V.arcologies[0].FSRepopulationFocus > 20) {
			if (slave.preg > 10) result += 2;
			else result -= 2;
		} else if (V.arcologies[0].FSRestart > 20) {
			if (slave.bellyPreg >= 500 && slave.breedingMark === 1 && V.propOutcome === 1)
				result += 1;
			else if (slave.preg > 10)
				result -= 10;
			else
				result += 0;
		}
	}

	function calcRace(slave) {
		if (V.arcologies[0].FSSupremacist !== "unset" && supremeRaceP(slave))
			result -= (V.arcologies[0].FSSupremacist/5) + (V.arcologies[0].FSSupremacistLawME*10);
		if (V.arcologies[0].FSSubjugationist !== "unset" && inferiorRaceP(slave))
			result += (V.arcologies[0].FSSubjugationist/10) + (V.arcologies[0].FSSubjugationistLawME);
	}

	function calcSexAttributes(slave) {
		if (slave.clitPiercing > 2) result += 1;
		if (slave.fetishKnown === 1 && slave.fetishStrength > 60 && slave.fetish != "none")
			result += slave.fetishStrength/5;

		if (slave.attrKnown === 1) {
			result += Math.trunc(slave.attrXX/20);
			result += Math.trunc(slave.attrXY/20);
			if (slave.energy > 95) result += 3;
			else if (slave.energy > 80) result += 2;
			else if (slave.energy > 60) result += 1;
			else if (slave.energy <= 20) result -= 2;
			else if (slave.energy <= 40) result -= 1;
		}
		if (slave.sexualFlaw !== "none") result -= 2;
		if (slave.sexualQuirk !== "none") result += 2;
		if (slave.behavioralFlaw !== "none") result -= 2;
		if (slave.behavioralQuirk !== "none") result += 2;
	}

	function calcCareer(slave) {
		if (setup.whoreCareers.includes(slave.career))
			result += 1;
		else if (slave.oralCount + slave.analCount + slave.vaginalCount + slave.mammaryCount + slave.penetrativeCount > 1000)
			result += 1;
	}

	function calcSight(slave) {
		if (!canSee(slave)) result -= 3;
		else if (slave.eyes <= -1) {
			if (slave.eyewear !== "corrective glasses" && slave.eyewear !== "corrective contacts")
				result -= 1;
		} else if (slave.eyewear === "blurring glasses")
			result -= 1;
		else if (slave.eyewear === "blurring contacts")
			result -= 1;
	}

	function calcHearing(slave) {
		if (!canHear(slave)) result -= 2;
		else if (slave.hears <= -1) {
			if (slave.earwear !== "hearing aids")
				result -= 1;
		} else if (slave.earwear === "muffling ear plugs")
			result -= 1;
	}

	function calcEgyptianBonus(slave) {
		if (V.racialVarieties === undefined) V.racialVarieties = [];
		if (!V.racialVarieties.includes(slave.race))
			V.racialVarieties.push(slave.race);
	}

	function calcYouthBonus(slave) {
		if (slave.visualAge < 30) {
			if (slave.actualAge > 30)
				result += 5; // experienced for her apparent age
			if (slave.physicalAge > 30)
				result -= slave.physicalAge/2; // too old :(
		}
	}

	function calcMatureBonus(slave) {
		if (slave.visualAge >= 30 && slave.actualAge >= 30 && slave.physicalAge < slave.visualAge)
			result += Math.min((slave.physicalAge - slave.visualAge) * 2, 20); // looks and acts mature, but has a body that just won't quit
	}

	function calcNotFuckdoll(slave) {
		if (V.familyTesting === 1 && totalRelatives(slave) > 0)
			calcWorksWithRelatives(slave);
		else if(!V.familyTesting && slave.relation !==0)
			calcWorksWithRelativesVanilla(slave);
		if (slave.relationship > 0) calcWorksWithRelationship(slave);
		if (slave.rivalry !== 0) calcWorksWithRival(slave);
		calcHInjectionsDiet(slave);
		calcPreg(slave);
		calcRace(slave);
		calcSexAttributes(slave);
		calcCareer(slave);
		calcSight(slave);
		calcHearing(slave);
		if (V.arcologies[0].FSEgyptianRevivalist !== "unset")
			calcEgyptianBonus(slave);
		if (V.arcologies[0].FSYouthPreferentialist !== "unset")
			calcYouthBonus(slave);
		else if (V.arcologies[0].FSMaturityPreferentialist !== "unset")
			calcMatureBonus(slave);
	}

	function calcAge(slave) {
		if ((V.arcologies[0].FSRepopulationFocus !== "unset" || V.arcologies[0].FSGenderFundamentalist !== "unset") && slave.physicalAge === V.minimumSlaveAge && slave.physicalAge === V.fertilityAge && canGetPregnant(slave)) {
			result += 1;
			if (slave.birthWeek === 0) result += result;
			else if (slave.birthWeek < 4) result += 0.2*result;
		} else if (slave.physicalAge === V.minimumSlaveAge) {
			result += 1;
			if (slave.birthWeek === 0 ) result += 0.5*result;
			else if (slave.birthWeek < 4) result += 0.1*result;
		} else if (slave.physicalAge === V.fertilityAge && canGetPregnant(slave) && (V.arcologies[0].FSRepopulationFocus !== "unset" || V.arcologies[0].FSGenderFundamentalist !== "unset")) {
			result += 1;
			if (slave.birthWeek === 0)
				result += 0.5*result;
			else if (slave.birthWeek < 4)
				result += 0.1*result;
		}
	}

	function calcAmputation(slave) {
		switch(slave.amp) {
		case 0:
		case -2:
		case -5:
			break;
		case 1:
			result -= 2;
			break;
		default:
			result -= 1;
		}
	}

	function calcHedonismWeight(slave) {
		if (slave.weight < 10)
			result -= 2;
		else if (slave.weight > 190)
			result -= 5; // too fat
	}
	return FResult;
})();

window.slaveCost = (function() {
	"use strict";
	let V, arcology, multiplier, cost;

	function slaveCost(slave, isStartingSlave) {
		V = State.variables;
		arcology = V.arcologies[0];
		multiplier = V.slaveCostFactor;
		cost = Beauty(slave)*FResult(slave);

		calcGenitalsCost(slave);
		calcDevotionTrustCost(slave);
		calcPreferencesCost(slave);
		calcPregCost(slave);
		if (slave.prestige + slave.pornPrestige > 0) {
			calcPrestigeCost(slave);
		}
		calcFSCost(slave);
		if (V.seeAge === 1) {
			calcAgeCost(slave);
		}
		calcCareersCost(slave);
		calcMiscCost(slave);
		calcIndentureCost(slave); /* multipliers */

		calcCost(slave);
		if (isStartingSlave) {
			calcStartingSlaveCost(slave);
		}
		return cost;
	};

	function calcGenitalsCost(slave) {
		if (slave.vagina === 0) {
			multiplier += 0.1;
		}
		if (slave.vagina > -1 && arcology.FSRestartSMR === 1) {
			if (slave.dick > 0) {
				if (slave.ovaries === 0 && slave.balls === 0) {
					multiplier += 0.8;
				}
			}
		} else if (slave.vagina > -1) {
			if (slave.dick > 0) {
				if (V.ui !== "start" || V.PC.dick === 0 || V.PC.vagina === 0) {
					multiplier += 0.2;
					if (slave.ovaries > 0) {
						if (slave.balls > 0) {
							multiplier += 0.8;
						}
					}
				} else {
					multiplier += 0.1;
					if (slave.ovaries > 0) {
						if (slave.balls > 0) {
							multiplier += 0.2;
						}
					}
				}
			}
		}
	};

	function calcDevotionTrustCost(slave) {
		if (V.specialSlavesPriceOverride === 1) {
			if (slave.devotion > 50) {
				multiplier += slave.devotion/200;
			}
			if (slave.trust > 50) {
				multiplier += slave.trust/200;
			}
		} else {
			multiplier += slave.devotion/200;
			if (slave.devotion < -20) {
				if (slave.trust > 0) {
					multiplier -= slave.trust/200;
				}
			} else {
				if (slave.trust > 0) {
					multiplier += slave.trust/200;
				}
			}
		}
	};

	function calcPreferencesCost(slave) {
		if (slave.behavioralFlaw !== "none") {
			multiplier -= 0.1;
		}
		if (slave.behavioralQuirk !== "none") {
			multiplier += 0.1;
		}
		if (slave.sexualFlaw === "breeder" && arcology.FSRepopulationFocus !== "unset") {
			multiplier += 0.3;
		} else if (slave.sexualFlaw !== "none") {
			multiplier -= 0.1;
		}
		if (slave.sexualQuirk !== "none") {
			multiplier += 0.1;
		}
		if (slave.fetishKnown === 1) {
			if (slave.fetish === "mindbroken") {
				multiplier -= 0.3;
			} else if (slave.fetish !== "none") {
				multiplier += slave.fetishStrength/1000;
			}
		} else {
			multiplier -= 0.1;
		}
		if (slave.attrKnown === 1) {
			if (slave.energy > 95) {
				multiplier += 0.2;
			}
		}
	};

	function calcPregCost(slave) {
		if (slave.mpreg === 1) {
			multiplier += 0.2;
		}
		if (arcology.FSRepopulationFocusSMR === 1) {
			if (slave.preg < -1) {
				multiplier -= 0.5;
			} else if (slave.bellyPreg >= 300000) {
				multiplier += 1;
			} else if (slave.bellyPreg >= 120000) {
				multiplier += 0.5;
			} else if (slave.preg > 10) {
				multiplier += 0.1;
			}
		} else if (arcology.FSRestartSMR === 1) {
			if (slave.preg < -1) {
				multiplier += 0.5;
			} else if (slave.bellyPreg >= 300000) {
				multiplier -= 2.5;
			} else if (slave.bellyPreg >= 30000) {
				multiplier -= 1.5;
			} else if (slave.preg > 10) {
				multiplier -= 1.0;
			}
		} else {
			if (slave.preg < -1) {
				multiplier -= 0.1;
			} else if (V.activeSlave.bellyPreg >= 300000) {
				multiplier -= 1.5;
			} else if (V.activeSlave.bellyPreg >= 120000) {
				multiplier -= 0.5;
			} else if (slave.preg > 10) {
				multiplier -= 0.1;
			}
		}
	};

	function calcPrestigeCost(slave) {
		if (slave.prestige > 0) {
			multiplier += 0.7*slave.prestige;
		}
		if (slave.pornPrestige === 3) {
			multiplier += 1.5;
		} else if (slave.pornPrestige === 2) {
			multiplier += 0.7;
		} else if (slave.pornPrestige === 1) {
			multiplier += 0.2;
		}
	};

	function calcFSCost(slave) {
		if (arcology.FSSupremacistLawME !== 0) {
			if (slave.race !== arcology.FSSupremacistRace) {
				multiplier -= 0.1;
			}
		}
		if (arcology.FSSubjugationistLawME !== 0) {
			if (slave.race === arcology.FSSubjugationistRace) {
				multiplier -= 0.2;
			}
		}
		if (arcology.FSRepopulationFocusSMR !== 0) {
			if (slave.preg > 0) {
				multiplier += 0.1;
			}
		} else if (arcology.FSRestartSMR !== 0) {
			if (slave.dick > 0) {
				multiplier -= 0.1;
			}
			if (slave.balls > 0) {
				multiplier -= 0.2;
			}
			if (slave.vagina > 0) {
				multiplier -= 0.1;
			}
			if (slave.ovaries > 0) {
				multiplier -= 0.5;
			}
		}
		if (arcology.FSGenderFundamentalistSMR !== 0) {
			if (slave.dick > 0) {
				multiplier -= 0.1;
			}
			if (slave.balls > 0) {
				multiplier -= 0.1;
			}
		} else if (arcology.FSGenderRadicalist !== "unset") {
			if (slave.dick > 0) {
				multiplier += 0.1;
			}
			if (slave.balls > 0) {
				multiplier -= 0.1;
			}
		}
		if (arcology.FSHedonisticDecadenceSMR !== 0) {
			if (slave.weight > 60 && slave.muscles < 5) {
				multiplier += 0.1;
			}
		}
		if (arcology.FSArabianRevivalist > 50) {
			multiplier += 0.1;
		}
	};

	function calcAgeCost(slave) {
		if (slave.physicalAge === V.minimumSlaveAge && slave.physicalAge === V.fertilityAge && canGetPregnant(slave) && (arcology.FSRepopulationFocus !== "unset" || arcology.FSGenderFundamentalist !== "unset")) {
			if (slave.birthWeek === 0) {
				multiplier -= 0.4;
			} else if (slave.birthWeek < 4) {
				multiplier -= 0.1;
			}
		} else if (slave.physicalAge === V.minimumSlaveAge) {
			if (slave.birthWeek === 0) {
				multiplier -= 0.2;
			} else if (slave.birthWeek < 4) {
				multiplier -= 0.05;
			}
		} else if (slave.physicalAge === V.fertilityAge && canGetPregnant(slave) && (arcology.FSRepopulationFocus !== "unset" || arcology.FSGenderFundamentalist !== "unset")) {
			if (slave.birthWeek === 0) {
				multiplier -= 0.2;
			} else if (slave.birthWeek < 4) {
				multiplier -= 0.05;
			}
		}
	};

	function calcCareersCost(slave) {
		if (slave.career !== 0) {
			if (slave.career === "a slave") {
				multiplier += 0.1;
			} else if (setup.bodyguardCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.wardenessCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.attendantCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.matronCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.schoolteacherCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.stewardessCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.milkmaidCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.farmerCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.madamCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.DJCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.HGCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.recruiterCareers.includes(slave.career)) {
				multiplier += 0.1;
			} else if (setup.entertainmentCareers.includes(slave.career)) {
				multiplier += 0.05;
			} else if (setup.whoreCareers.includes(slave.career)) {
				multiplier += 0.05;
			} else if (setup.gratefulCareers.includes(slave.career)) {
				multiplier += 0.05;
			} else if (setup.menialCareers.includes(slave.career)) {
				multiplier += 0.05;
			} else if (setup.servantCareers.includes(slave.career)) {
				multiplier += 0.05;
			}
		}
		if (V.week-slave.weekAcquired >= 20 && slave.entertainSkill >= 100) {
			if (!setup.entertainmentCareers.includes(slave.career)) {
				multiplier += 0.05;
			}
		}
		if (slave.oralCount + slave.analCount + slave.vaginalCount + slave.mammaryCount + slave.penetrativeCount > 1000) {
			if (!setup.whoreCareers.includes(slave.career)) {
				multiplier += 0.05;
			}
		}
		if (!setup.bodyguardCareers.includes(slave.career) && slave.skillBG >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.wardenessCareers.includes(slave.career) && slave.skillWA >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.attendantCareers.includes(slave.career) && slave.skillAT >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.matronCareers.includes(slave.career) && slave.skillMT >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.schoolteacherCareers.includes(slave.career) && slave.skillTE >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.stewardessCareers.includes(slave.career) && slave.skillST >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.milkmaidCareers.includes(slave.career) && slave.skillMM >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.farmerCareers.includes(slave.career) && slave.skillFA >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.madamCareers.includes(slave.career) && slave.skillMD >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.DJCareers.includes(slave.career) && slave.skillDJ >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.HGCareers.includes(slave.career) && slave.skillHG >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.recruiterCareers.includes(slave.career) && slave.skillRC >= V.masteredXP) {
			multiplier += 0.1;
		}
		if (!setup.servantCareers.includes(slave.career) && slave.skillS >= V.masteredXP) {
			multiplier += 0.05;
		}
		if (!setup.entertainmentCareers.includes(slave.career) && slave.skillE >= V.masteredXP) {
			multiplier += 0.05;
		}
		if (!setup.whoreCareers.includes(slave.career) && slave.skillW >= V.masteredXP) {
			multiplier += 0.05;
		}
	};

	function calcMiscCost(slave) {
		let totalInt = Math.clamp(slave.intelligence + slave.intelligenceImplant,-130,130); /* make absolutely certain we do not use +-131 in the next line */
		multiplier += Math.floor((Math.asin(totalInt/131))*50)/50;
		if (slave.pubertyXY === 0 && slave.physicalAge >= V.potencyAge && slave.genes === "XY" && arcology.FSGenderRadicalist === "unset") {
			multiplier += 0.5;
		}
		if (slave.brand !== 0) {
			if (V.rep > 10000) {
				multiplier += 0.1;
			} else if (V.rep < 5000) {
				multiplier -= 0.1;
			}
		}
		if (slave.amp === 1) {
			multiplier -= 0.2;
		}
		if (slave.eyes === -2) {
			multiplier -= 0.2;
		}
	};

	function calcIndentureCost(slave) {
		if (slave.indenture > -1) {
			multiplier -= 0.1*slave.indentureRestrictions;
			multiplier -= (260-slave.indenture)/260;
		} else if (V.seeAge === 1) {
			if (slave.actualAge >= (V.retirementAge-5) && V.PhysicalRetirementAgePolicy !== 1) {
				multiplier *= (V.retirementAge-slave.actualAge)/5;
			}
			if (slave.physicalAge >= (V.retirementAge-5) && V.PhysicalRetirementAgePolicy === 1) {
				multiplier *= (V.retirementAge-slave.actualAge)/5;
			}
		}
	};

	function calcCost(slave) {
		cost *= multiplier*50;
		cost = Number(cost) || 0;
		if (cost < V.minimumSlaveCost) {
			cost = V.minimumSlaveCost;
		} else if (cost <= 100000) {
			/* do nothing */
		} else if (cost <= 200000) {
			cost -= (cost-100000)*0.1;
		} else if (cost <= 300000) {
			cost -= 10000 + ((cost-200000)*0.2);
		} else if (cost <= 400000) {
			cost -= 30000 + ((cost-300000)*0.3);
		} else if (cost <= 500000) {
			cost -= 60000 + ((cost-400000)*0.4);
		} else {
			cost -= 100000 + ((cost-500000)*0.5);
		}
		if (cost < 1000) {
			cost = 1000;
		}
		cost = 500*Math.trunc(cost/500);
	};

	function calcStartingSlaveCost(slave) {
		let startingSlaveMultiplier = 0;

		if (slave.devotion > 20) {
			startingSlaveMultiplier += (0.000117*(slave.devotion-20)*(slave.devotion-20))+(0.003167*(slave.devotion-20));
		}
		if (slave.whoreSkill) {
			startingSlaveMultiplier += 0.00001*slave.whoreSkill*slave.whoreSkill;
		}
		if (slave.entertainSkill) {
			startingSlaveMultiplier += 0.00001*slave.entertainSkill*slave.entertainSkill;
		}
		if (slave.vaginalSkill) {
			startingSlaveMultiplier += 0.00001*slave.vaginalSkill*slave.vaginalSkill;
		}
		if (slave.analSkill) {
			startingSlaveMultiplier += 0.00001*slave.analSkill*slave.analSkill;
		}
		if (slave.oralSkill) {
			startingSlaveMultiplier += 0.00001*slave.oralSkill*slave.oralSkill;
		}
		if (slave.combatSkill) {
			startingSlaveMultiplier += 0.1;
		}
		if (slave.prestige) {
			startingSlaveMultiplier += slave.prestige;
		}
		if (startingSlaveMultiplier) {
			if (slave.actualAge > 25) {
				startingSlaveMultiplier -= startingSlaveMultiplier*(slave.actualAge-25)*0.05;
			}
		}
		startingSlaveMultiplier = Math.clamp(startingSlaveMultiplier, 0, 10);
		cost += cost*startingSlaveMultiplier;
		cost = 500*Math.trunc(cost/500);
		if (V.PC.career === "slaver") {
			cost = cost/2;
		}
	};

	return slaveCost;
})();

window.startingSlaveCost = function startingSlaveCost(slave) {
	return slaveCost(slave, true);
};