code:
// Generates a child's genetics based off mother and father and returns it as an object to be attached to an ovum

window.generateGenetics = (function() {
	"use strict";
	let genes;
	let mother;
	let activeMother;
	let father;
	let activeFather;
	let V;

	function generateGenetics(actor1, actor2, x) {
		V = State.variables;
		genes = {gender: "XX", name: "blank", surname: 0, mother: 0, motherName: "none", father: 0, fatherName: "none", nationality: "Stateless", race: "white", intelligence: 0, face: 0, faceShape: "cute", eyeColor: "brown", hColor: "black", skin: "white", markings: "none", behavioralFlaw: "none", sexualFlaw: "none", pubicHStyle: "bushy", underArmHStyle: "bushy", clone: 0, cloneID: 0, geneticQuirks: 0};
		if (actor1.ID > 0) {
			mother = V.genePool.find(function(s) { return s.ID === actor1.ID; });
			if (mother === undefined) {
				mother = actor1;
			}
			activeMother = V.slaves[V.slaveIndices[actor1]];
			if (activeMother === undefined) {
				activeMother = actor1;
			}
		} else {
			activeMother = V.PC;
			mother = V.PC;
		}
		if (actor2 > 0) {
			father = V.genePool.find(function(s) { return s.ID === actor2; });
			activeFather = V.slaves[V.slaveIndices[actor2]];
			if (father === undefined) {
				father = V.slaves[V.slaveIndices[actor2]];
				activeFather = V.slaves[V.slaveIndices[actor2]];
			}
			if (father === undefined) {
				if (V.incubator > 0) {
					father = V.tanks.find(function(s) { return s.ID === actor2; });
					activeFather = 0; // activeFather = father?
				}
			}
			if (father === undefined) {
				if (V.nursery > 0) {
					father = V.cribs.find(function(s) { return s.ID === actor2; });
					activeFather = 0; // activeFather = father?
				}
			}
			if (father === undefined) {
				father = 0;
				activeFather = 0;
			}
		} else if (actor2 === -1) {
			father = V.PC;
			activeFather = V.PC;
		} else {
			father = 0;
			activeFather = 0;
		}

		genes.gender = setGender(father, mother);
		genes.name = setName(x);
		genes.mother = setMotherID(actor1.ID);
		genes.motherName = setMotherName(activeMother);
		genes.father = setFatherID(actor2);
		genes.fatherName = setFatherName(father, activeFather, actor2);
		genes.nationality = setNationality(father, mother);
		genes.geneticQuirks = setGeneticQuirks(father, mother, genes.gender);
		genes.skin = setSkin(father, mother, actor2);
		genes.race = setRace(father, mother, actor2);
		genes.intelligence = setIntelligence(father, mother, activeMother, actor2);
		genes.face = setFace(father, mother, activeMother, actor2, genes.geneticQuirks);
		genes.faceShape = setFaceShape(father, mother);
		genes.eyeColor = setEyeColor(father, mother, actor2);
		if (genes.geneticQuirks.heterochromia === 2) {
			genes.geneticQuirks.heterochromia = setHeterochromaticEyeColor(father, mother, actor2);
		}
		genes.hColor = setHColor(father, mother, actor2);
		genes.underArmHStyle = setUnderArmHStyle(father, mother);
		genes.pubicHStyle = setPubicHStyle(father, mother);
		genes.markings = setMarkings(father, mother);
		genes.sexualFlaw = setSexualFlaw(father, mother);
		genes.behavioralFlaw = setBehavioralFlaw(father, mother);
		genes.fetish = setFetish(father, mother);

		return genes;
	}

	// gender
	function setGender(father, mother) {
		let gender;
		if (mother.geneticQuirks.girlsOnly === 2) {
			gender = "XX";
		} else if (V.seeDicksAffectsPregnancy === 1) {
			gender = Math.floor(Math.random()*100) < V.seeDicks ? "XY" : "XX";
		} else if (V.adamPrinciple === 1) {
			if (father !== 0) {
				if (father.genes === "XX" && mother.genes === "XX") {
					gender = "XX";
				} else if (father.genes !== mother.genes) {
					gender = jsEither(["XX", "XY"]);
				} else {
					gender = jsEither(["XX", "XY", "XY", "YY"]);
				}
			} else {
				gender = jsEither(["XX", "XY"]);
			}
		} else {
			gender = jsEither(["XX", "XY"]);
		}
		return gender;
	}

	// name
	function setName(x) {
		return `ovum${x}`;
	}

	// motherID
	function setMotherID(actor1ID) {
		return actor1ID;
	}

	// motherName
	function setMotherName(activeMother) {
		let motherName;
		if (activeMother.ID === -1) {
			motherName = activeMother.name;
			if (activeMother.surname !== 0 && activeMother.surname !== "") { motherName += ` ${activeMother.surname}`; }
		} else {
			motherName = activeMother.slaveName;
			if (activeMother.slaveSurname !== 0 && activeMother.slaveSurname !== "") { motherName += ` ${activeMother.slaveSurname}`; }
		}
		return motherName;
	}

	// fatherID
	function setFatherID(actor2) {
		return actor2;
	}

	// fatherName
	function setFatherName(father, activeFather, actor2) {
		let fatherName;
		if (father !== 0) {
			if (father.ID === -1) {
				fatherName = activeFather.name;
				if (activeFather.surname !== 0 && activeFather.surname !== "") { fatherName += ` ${activeFather.surname}`; }
			} else {
				fatherName = activeFather.slaveName;
				if (activeFather.slaveSurname !== 0 && activeFather.slaveSurname !== "") { fatherName += ` ${activeFather.slaveSurname}`; }
			}
		} else {
			switch (actor2) {
				case -2:
				case -5:
					fatherName = "Citizen";
					break;
				case -3:
					fatherName = "Your Master";
					break;
				case -4:
					fatherName = "Another arcology owner";
					break;
				case -6:
					fatherName = "The Societal Elite";
					break;
				case -7:
					fatherName = "Lab designed";
					break;
				case -9:
					fatherName = "A Futanari Sister";
					break;
				default:
					fatherName = "Unknown";
			}
		}
		return fatherName;
	}

	// nationality
	function setNationality(father, mother) {
		if (father === 0 || father.nationality !== mother.nationality) {
			return "Stateless";
		} else {
			return mother.nationality;
		}
	}

	// race
	function setRace(father, mother, actor2) {
		let race;
		let fatherRace = 0;
		if (father !== 0) {
			if (mother.origRace === father.origRace) {
				race = mother.origRace;
			} else if (jsRandom(1, 4) === 4) {
				race = jsEither([father.origRace, mother.origRace]);
			} else {
				race = "mixed race";
			}
		} else {
			if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSupremacistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSupremacist !== "unset")) {
				fatherRace = V.arcologies[0].FSSupremacistRace;
			} else if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSubjugationistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSubjugationist !== "unset")) {
				let racesList = setup.filterRacesLowercase.filter(race => race !== V.arcologies[0].FSSubjugationistRace);
				fatherRace = racesList.random();
			}
			if (fatherRace !== 0) {
				if (mother.origRace === fatherRace) {
					race = mother.origRace;
				} else if (jsRandom(1, 4) === 4) {
					race = jsEither([fatherRace, mother.origRace]);
				} else {
					race = "mixed race";
				}
			} else {
				race = mother.origRace;
			}
		}
		return race;
	}

	//skin
	function setSkin(father, mother, actor2) {
		let fatherSkin = 0;
		let dadSkinIndex;
		const skinToMelanin = {
			"pure black": 25,
			"ebony": 24,
			"black": 23,
			"dark brown": 22,
			"brown": 21,
			"light brown": 20,
			"dark beige": 19,
			"beige": 18,
			"light beige": 17,
			"dark": 16,
			"dark olive": 15,
			"bronze": 14,
			"olive": 13,
			"tan": 12,
			"light olive": 11,
			"light": 10,
			"fair": 9,
			"very fair": 8,
			"extremely fair": 7,
			"pale": 6,
			"very pale": 5,
			"extremely pale": 4,
			"white": 3,
			"ivory": 2,
			"pure white": 1
		};
		const momSkinIndex = mother ? (skinToMelanin[mother.origSkin] || 13) : 8;
		if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSupremacistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSupremacist !== "unset")) {
			fatherSkin = randomRaceSkin(V.arcologies[0].FSSupremacistRace);
		} else if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSubjugationistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSubjugationist !== "unset")) {
			let racesList = setup.filterRacesLowercase.filter(race => race !== V.arcologies[0].FSSubjugationistRace);
			fatherSkin = randomRaceSkin(racesList.random());
		}
		if (fatherSkin !== 0) {
			dadSkinIndex = father !== 0 ? (skinToMelanin[fatherSkin] || 13) : 8;
		} else {
			dadSkinIndex = father !== 0 ? (skinToMelanin[father.origSkin] || 13) : 8;
		}
		const skinIndex = Math.round(Math.random() * (dadSkinIndex - momSkinIndex) + momSkinIndex);

		let prop = "";
		for (prop in skinToMelanin) {
			if (!skinToMelanin.hasOwnProperty(prop)) continue;
			if (skinIndex >= skinToMelanin[prop]) return prop;
		}
		return prop; // skinIndex can be zero
	}

	// eyeColor
	function setEyeColor(father, mother, actor2) {
		let eyeColor;
		let fatherEye = 0;
		if (father !== 0) {
			if (mother.origEye === father.origEye) {
				eyeColor = mother.origEye;
			} else if (mother.origEye === "red" || mother.origEye === "pale red" || mother.origEye === "light red" || mother.origEye === "pale gray" || mother.origEye === "milky white") {
				eyeColor = father.origEye;
			} else if (father.origEye === "red" || father.origEye === "pale red" || father.origEye === "light red" || father.origEye === "pale gray" || father.origEye === "milky white") {
				eyeColor = mother.origEye;
			} else if (mother.origEye === "blue") {
				if (jsRandom(1, 4) === 2) {
					eyeColor = mother.origEye;
				} else {
					eyeColor = father.origEye;
				}
			} else if (father.origEye === "blue") {
				if (jsRandom(1, 4) === 2) {
					eyeColor = father.origEye;
				} else {
					eyeColor = mother.origEye;
				}
			} else {
				eyeColor = jsEither([father.origEye, mother.origEye]);
			}
		} else {
			if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSupremacistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSupremacist !== "unset")) {
				fatherEye = randomRaceEye(V.arcologies[0].FSSupremacistRace);
			} else if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSubjugationistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSubjugationist !== "unset")) {
				let racesList = setup.filterRacesLowercase.filter(race => race !== V.arcologies[0].FSSubjugationistRace);
				fatherEye = randomRaceEye(racesList.random());
			}
			if (fatherEye !== 0) {
				if (mother.origEye === fatherEye) {
					eyeColor = mother.origEye;
				} else if (mother.origEye === "red" || mother.origEye === "pale red" || mother.origEye === "light red" || mother.origEye === "pale gray" || mother.origEye === "milky white") {
					eyeColor = fatherEye;
				} else if (fatherEye === "blue") {
					if (jsRandom(1,4) === 2) {
						eyeColor = mother.origEye;
					} else {
						eyeColor = fatherEye;
					}
				} else if (fatherEye === "blue") {
					if (jsRandom(1,4) === 2) {
						eyeColor = fatherEye;
					} else {
						eyeColor = mother.origEye;
					}
				} else {
					eyeColor = jsEither([fatherEye, mother.origEye]);
				}
			} else {
				eyeColor = mother.origEye;
			}
		}
		//just in case something wrong gets through
		switch (eyeColor) {
			case "blind blue":
				eyeColor = "deep blue";
				break;
			case "milky white":
			case "implant":
				eyeColor = jsEither(["blue", "brown", "dark blue", "dark green", "green", "hazel", "light blue", "light green"]);
				break;
		}
		return eyeColor;
	}

	function setHeterochromaticEyeColor(father, mother, actor2) {
		let hEyeColor;
		let fatherHEye = 0;
		let eyeColorArray = [];
		if (father !== 0) {
			eyeColorArray.push(mother.origEye);
			eyeColorArray.push(father.origEye);
			if (father.geneticQuirks.heterochromia !== 0 && father.geneticQuirks.heterochromia !== 1) {
				eyeColorArray.push(father.geneticQuirks.heterochromia);
			}
		} else {
			if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSupremacistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSupremacist !== "unset")) {
				fatherHEye = randomRaceEye(V.arcologies[0].FSSupremacistRace);
			} else if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSubjugationistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSubjugationist !== "unset")) {
				let racesList = setup.filterRacesLowercase.filter(race => race !== V.arcologies[0].FSSubjugationistRace);
				fatherHEye = randomRaceEye(racesList.random());
			}
			if (fatherHEye !== 0) {
				eyeColorArray.push(fatherHEye);
				eyeColorArray.push(mother.origEye);
			} else {
				eyeColorArray.push(mother.origEye);
			}
		}
		if (mother.geneticQuirks.heterochromia !== 0 && mother.geneticQuirks.heterochromia !== 1) {
			eyeColorArray.push(mother.geneticQuirks.heterochromia);
		}
		//just in case something wrong gets through
		switch (hEyeColor) {
			case "blind blue":
				hEyeColor = ["deep blue"];
				break;
			case "milky white":
			case "implant":
				hEyeColor = jsEither(["blue", "green", "brown", "hazel", "light blue", "light green", "dark green", "dark blue"]);
				break;
		}
		return jsEither(eyeColorArray);
	}

	// hColor
	function setHColor(father, mother, actor2) {
		let hairColor;
		let fatherHair = 0;
		if (father !== 0) {
			if (mother.origHColor === father.origHColor) {
				hairColor = mother.origHColor;
			} else if (mother.origHColor === "white") {
				hairColor = jsRandom(1, 100) === 69 ? mother.origHColor : father.origHColor;
			} else if (father.origHColor === "white") {
				hairColor = jsRandom(1, 100) === 69 ? father.origHColor : mother.origHColor;
			} else if (mother.origHColor === "black") {
				hairColor = jsEither([father.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor]);
			} else if (father.origHColor === "black") {
				hairColor = jsEither([father.origHColor, father.origHColor, father.origHColor, father.origHColor, father.origHColor, father.origHColor, father.origHColor, mother.origHColor]);
			} else if (mother.origHColor === "brown") {
				hairColor = jsEither([father.origHColor, mother.origHColor, mother.origHColor, mother.origHColor]);
			} else if (father.origHColor === "brown") {
				hairColor = jsEither([father.origHColor, father.origHColor, father.origHColor, mother.origHColor]);
			} else {
				hairColor = jsEither([father.origHColor, mother.origHColor]);
			}
		} else {
			if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSupremacistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSupremacist !== "unset")) {
				fatherHair = randomRaceHair(V.arcologies[0].FSSupremacistRace);
			} else if (((actor2 === -2 || actor2 === -5) && V.arcologies[0].FSSubjugationistLawME === 1) || (actor2 === -6 && V.arcologies[0].FSSubjugationist !== "unset")) {
				let racesList = setup.filterRacesLowercase.filter(race => race !== V.arcologies[0].FSSubjugationistRace);
				fatherHair = randomRaceHair(racesList.random());
			}
			if (fatherHair !== 0) {
				if (mother.origHColor === fatherHair) {
					hairColor = mother.origHColor;
				} else if (mother.origHColor === "white") {
					hairColor = jsRandom(1,100) === 69 ? mother.origHColor : fatherHair;
				} else if (mother.origHColor === "black") {
					hairColor = jsEither([fatherHair, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor, mother.origHColor]);
				} else if (fatherHair === "black") {
					hairColor = jsEither([fatherHair, fatherHair, fatherHair, fatherHair, fatherHair, fatherHair, fatherHair, mother.origHColor]);
				} else if (mother.origHColor === "brown") {
					hairColor = jsEither([fatherHair, mother.origHColor, mother.origHColor, mother.origHColor]);
				} else if (fatherHair === "brown") {
					hairColor = jsEither([fatherHair, fatherHair, fatherHair, mother.origHColor]);
				} else {
					hairColor = jsEither([fatherHair, mother.origHColor]);
				}
			} else {
				hairColor = mother.origHColor;
			}
		}
		return hairColor;
	}

	// underArmHairStyle
	function setUnderArmHStyle(father, mother) {
		let hair;
		if (father !== 0) {
			if (mother.underArmHStyle === "hairless" && father.underArmHStyle === "hairless") {
				hair = "hairless";
			} else if (mother.underArmHStyle === "hairless" || father.underArmHStyle === "hairless") {
				hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
			} else {
				hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
			}
		} else if (mother.underArmHStyle === "hairless") {
			hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
		} else {
			hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
		}
		return hair;
	}

	// pubicHairStyle
	function setPubicHStyle(father, mother) {
		let hair;
		if (father !== 0) {
			if (mother.pubicHStyle === "hairless" && father.pubicHStyle === "hairless") {
				hair = "hairless";
			} else if (mother.pubicHStyle === "hairless" || father.pubicHStyle === "hairless") {
				hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
			} else {
				hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
			}
		} else if (mother.pubicHStyle === "hairless") {
			hair = (jsRandom(1, 5) === 3) ? "hairless" : jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
		} else {
			hair = jsEither(["bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "bushy", "hairless"]);
		}
		return hair;
	}

	// markings
	function setMarkings(father, mother) {
		let markings;
		if (jsRandom(1, 8) === 1) {
			markings = jsEither(["beauty mark", "birthmark"]);
		} else {
			markings = "none";
		}
		if (markings === "none") {
			if (father !== 0) {
				markings = jsEither(["none", "none", father.markings, mother.markings]);
			} else {
				markings = jsEither(["none", "none", mother.markings, mother.markings]);
			}
		}
		return markings;
	}

	// sexualFlaw
	function setSexualFlaw(father, mother) {
		let flaw;
		if (father !== 0) {
			flaw = jsEither(["none", "none", father.sexualFlaw, mother.sexualFlaw]);
		} else {
			flaw = jsEither(["none", "none", mother.sexualFlaw, mother.sexualFlaw]);
		}
		return flaw;
	}

	// behavioralFlaw
	function setBehavioralFlaw(father, mother) {
		let flaw;
		if (father !== 0) {
			flaw = jsEither(["none", "none", father.behavioralFlaw, mother.behavioralFlaw]);
		} else {
			flaw = jsEither(["none", "none", mother.behavioralFlaw, mother.behavioralFlaw]);
		}
		return flaw;
	}

	// fetish
	function setFetish(father, mother) {
		let fetish;
		if (father !== 0) {
			fetish = jsEither(["none", "none", "none", "none", "none", father.fetish, mother.fetish]);
		} else {
			fetish = jsEither(["none", "none", "none", "none", "none", mother.fetish, mother.fetish]);
		}
		if (fetish === "mindbroken") { fetish = "none"; }
		return fetish;
	}

	//intelligence
	function setIntelligence(father, mother, activeMother, actor2) {
		let smarts;
		if (mother.ID === -1) {
			if (actor2 === -6) {
				smarts = jsRandom(90, 100);
			} else if (father !== 0) {
				if (father.intelligence < mother.intelligence) {
					smarts = jsRandom(father.intelligence, mother.intelligence);
				} else {
					smarts = jsRandom(mother.intelligence, father.intelligence);
				}
				if (smarts <= 50) {
					smarts += 30;
				}
			} else {
				smarts = jsRandom(50, 100);
			}
		} else if (father !== 0) {
			if (father.intelligence < mother.intelligence) {
				smarts = jsRandom(father.intelligence, mother.intelligence);
			} else {
				smarts = jsRandom(mother.intelligence, father.intelligence);
			}
			if (activeMother.breedingMark === 1 && smarts <= 50) {
				smarts = jsRandom(60, 100);
			}
		} else {
			smarts = mother.intelligence;
		}
		if (V.inbreeding === 1) {
			if (mother.ID !== -1) {
				if (father !== 0 && father.ID === -1 && activeMother.breedingMark !== 1) {
					if (smarts >= -95 && jsRandom(1, 100) < 40) {
						smarts -= jsRandom(1, 10);
						if (smarts >= -95 && jsRandom(1, 100) < 20) {
							smarts -= jsRandom(1, 5);
						}
					}
				} else {
					if (smarts >= -95 && jsRandom(1, 100) < 50) {
						smarts -= jsRandom(1, 15);
						if (smarts >= -95 && jsRandom(1, 100) < 30) {
							smarts -= jsRandom(1, 15);
						}
					}
				}
			}
		}
		return Math.clamp(smarts, -100, 100);
	}

	//face
	function setFace(father, mother, activeMother, actor2, genes) {
		let face;
		if (genes.pFace > 0 && genes.uFace > 0) {
			face = 0;
		} else if (genes.pFace > 0) {
			face = 100;
		} else if (genes.uFace > 0) {
			face = -100;
		} else if (mother.ID === -1) {
			if (actor2 === -6) {
				face = jsRandom(90, 100);
			} else if (father !== 0) {
				if (father.face < mother.face) {
					face = jsRandom(father.face, mother.face);
				} else {
					face = jsRandom(mother.face, father.face);
				}
				if (face <= 40) {
					face += jsRandom(5, 20);
				}
			} else {
				face = jsRandom(20, 100);
			}
		} else if (father !== 0) {
			if (father.face < mother.face) {
				face = jsRandom(father.face, mother.face);
			} else {
				face = jsRandom(mother.face, father.face);
			}
			if (activeMother.breedingMark === 1 && face < 60) {
				face = jsRandom(60, 100);
			}
		} else {
			face = mother.face;
		}
		if (V.inbreeding === 1 && genes.pFace === 0 && genes.uFace === 0) {
			if (mother.ID !== -1) {
				if (father !== 0 && father.ID === -1 && activeMother.breedingMark !== 1) {
					if (face > -100 && jsRandom(1, 100) > 60) {
						face -= jsRandom(2, 20);
					}
				} else {
					if (face > -100 && jsRandom(1, 100) < 50) {
						face -= jsRandom(1, 15);
						if (face >= -95 && jsRandom(1, 100) < 30) {
							face -= jsRandom(5, 20);
						}
					}
				}
			}
		}
		return Math.clamp(face, -100, 100);
	}

	// face shape
	function setFaceShape(father, mother) {
		let shape;
		if (father !== 0) {
			if (mother.faceShape === father.faceShape) {
				shape = mother.faceShape;
			} else {
				shape = jsEither(["androgynous", "androgynous", "cute", "cute", "exotic", "normal", "normal", "sensual", mother.faceShape, mother.faceShape]);
			}
		} else {
			shape = jsEither(["androgynous", "androgynous", "cute", "cute", "exotic", "normal", "normal", "sensual", mother.faceShape, mother.faceShape]);
		}
		return shape;
	}

	// genetic quirks
	function setGeneticQuirks(father, mother, sex) {
		let quirks = {macromastia: 0, gigantomastia: 0, fertility: 0, hyperFertility: 0, superfetation: 0, gigantism: 0, dwarfism: 0, pFace: 0, uFace: 0, albinism: 0, heterochromia: 0, rearLipedema: 0, wellHung: 0, wGain: 0, wLoss: 0, androgyny: 0};
		let chance = 0;

		// fertility
		if (mother.geneticQuirks.fertility === 2) {
			if (sex === "XX") {
				quirks.fertility = 2;
			} else {
				quirks.fertility = 1;
			}
		} else if (mother.geneticQuirks.fertility === 1) {
			chance = jsRandom(0, 1000);
			if (father !== 0) {
				if (father.geneticQuirks.fertility >= 1) {
					if (sex === "XX") {
						if (chance > 500) {
							quirks.fertility = 2;
						} else if (chance > 50) {
							quirks.fertility = 1;
						}
					} else {
						if (chance > 500) {
							quirks.fertility = 1;
						}
					}
				}
			} else {
				if (sex === "XX") {
					if (chance > 950) {
						quirks.fertility = 2;
					} else if (chance > 200) {
						quirks.fertility = 1;
					}
				} else {
					if (chance > 500) {
						quirks.fertility = 1;
					}
				}
			}
		}

		// hyper fertility
		if (mother.geneticQuirks.hyperFertility === 2) {
			if (sex === "XX") {
				quirks.hyperFertility = 2;
			} else {
				quirks.hyperFertility = 1;
			}
		} else if (mother.geneticQuirks.hyperFertility === 1) {
			chance = jsRandom(0, 1000);
			if (father !== 0) {
				if (father.geneticQuirks.hyperFertility >= 1) {
					if (sex === "XX") {
						if (chance > 750) {
							quirks.hyperFertility = 2;
						} else if (chance > 500) {
							quirks.hyperFertility = 1;
						}
					} else {
						if (chance > 500) {
							quirks.hyperFertility = 1;
						}
					}
				}
			} else {
				if (sex === "XX") {
					if (chance > 950) {
						quirks.hyperFertility = 2;
					} else if (chance > 700) {
						quirks.hyperFertility = 1;
					}
				} else {
					if (chance > 700) {
						quirks.hyperFertility = 1;
					}
				}
			}
		}

		// superfetation
		if (mother.geneticQuirks.superfetation === 2) {
			if (sex === "XX") {
				quirks.superfetation = 2;
			} else {
				quirks.superfetation = 1;
			}
		} else if (mother.geneticQuirks.superfetation === 1) {
			chance = jsRandom(0, 1000);
			if (father !== 0) {
				if (father.geneticQuirks.superfetation >= 1) {
					if (sex === "XX") {
						if (chance > 750) {
							quirks.superfetation = 2;
						} else if (chance > 700) {
							quirks.superfetation = 1;
						}
					} else {
						if (chance > 700) {
							quirks.superfetation = 1;
						}
					}
				}
			} else {
				if (sex === "XX") {
					if (chance > 950) {
						quirks.superfetation = 2;
					} else if (chance > 900) {
						quirks.superfetation = 1;
					}
				} else {
					if (chance > 900) {
						quirks.superfetation = 1;
					}
				}
			}
		}

		// well hung
		if (father !== 0) {
			if (mother.geneticQuirks.wellHung + father.geneticQuirks.wellHung >= 3) {
				if (sex === "XY") {
					quirks.wellHung = 2;
				} else {
					quirks.wellHung = 1;
				}
			} else if (mother.geneticQuirks.wellHung + father.geneticQuirks.wellHung >= 1) {
				chance = jsRandom(0, 1000);
				if (chance > 750) {
					quirks.wellHung = 1;
				}
			}
		} else if (mother.geneticQuirks.wellHung === 2) {
			chance = jsRandom(0, 1000);
			if (sex === "XY") {
				if (chance > 900) {
					quirks.wellHung = 2;
				} else if (chance > 200) {
					quirks.wellHung = 1;
				}
			} else {
				if (chance > 500) {
					quirks.wellHung = 1;
				}
			}
		}

		//perfect face
		if (father !== 0) {
			if (mother.geneticQuirks.pFace + father.geneticQuirks.pFace >= 4) {
				quirks.pFace = 2;
			} else if (mother.geneticQuirks.pFace === 2 || father.geneticQuirks.pFace === 2) {
				quirks.pFace = 1;
			}
		} else if (mother.geneticQuirks.pFace === 2) {
			quirks.pFace = 1;
		}

		//ugly face
		if (father !== 0) {
			if (mother.geneticQuirks.uFace + father.geneticQuirks.uFace >= 4) {
				quirks.uFace = 2;
			} else if (mother.geneticQuirks.uFace === 2 || father.geneticQuirks.uFace === 2) {
				quirks.uFace = 1;
			}
		} else if (mother.geneticQuirks.uFace === 2) {
			quirks.uFace = 1;
		}

		//albinism
		if (father !== 0) {
			// Add treatment to force albinism
			if (mother.geneticQuirks.albinism === 2 && father.geneticQuirks.albinism === 2) {
				if (jsRandom(1, 4) === 1) {
					quirks.albinism = 2;
				} else {
					quirks.albinism = 1;
				}
			} else if (mother.geneticQuirks.albinism + father.geneticQuirks.albinism >= 3) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.albinism = 2;
				} else if (chance !== 4) {
					quirks.albinism = 1;
				}
			} else if (mother.geneticQuirks.albinism === 1 && father.geneticQuirks.albinism === 1) {
				if (jsRandom(1, 4) === 1) {
					quirks.albinism = 2;
				}
			}
		} else if (mother.geneticQuirks.albinism >= 1) {
			if (jsRandom(0, 40000) >= 39500) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.albinism = 2;
				} else if (chance !== 4) {
					quirks.albinism = 1;
				}
			}
		}

		//heterochromia
		if (father !== 0) {
			if (mother.geneticQuirks.heterochromia === 2 && father.geneticQuirks.heterochromia === 2) {
				if (jsRandom(1, 4) === 1) {
					quirks.heterochromia = 2;
				} else {
					quirks.heterochromia = 1;
				}
			} else if (mother.geneticQuirks.heterochromia + father.geneticQuirks.heterochromia >= 3) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.heterochromia = 2;
				} else if (chance !== 4) {
					quirks.heterochromia = 1;
				}
			} else if (mother.geneticQuirks.heterochromia === 1 && father.geneticQuirks.heterochromia === 1) {
				if (jsRandom(1, 4) === 1) {
					quirks.heterochromia = 2;
				}
			}
		} else if (mother.geneticQuirks.heterochromia >= 1) {
			if (jsRandom(0, 40000) >= 39500) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.heterochromia = 2;
				} else if (chance !== 4) {
					quirks.heterochromia = 1;
				}
			}
		}

		//rear lipedema
		if (father !== 0) {
			if (mother.geneticQuirks.rearLipedema === 2 && father.geneticQuirks.rearLipedema === 2) {
				if (jsRandom(1, 4) >= 3) {
					quirks.rearLipedema = 2;
				} else {
					quirks.rearLipedema = 1;
				}
			} else if (mother.geneticQuirks.rearLipedema === 1 + father.geneticQuirks.rearLipedema >= 3) {
				chance = jsRandom(1, 4);
				if (chance <= 2) {
					quirks.rearLipedema = 2;
				} else if (chance === 4) {
					quirks.rearLipedema = 1;
				}
			} else if (mother.geneticQuirks.rearLipedema === 1 && father.geneticQuirks.rearLipedema === 1) {
				if (jsRandom(1, 4) === 1) {
					quirks.rearLipedema = 2;
				} else if (chance === 4) {
					quirks.rearLipedema = 1;
				}
			}
		} else if (mother.geneticQuirks.rearLipedema >= 1) {
			if (jsRandom(0, 40000) >= 35000) {
				chance = jsRandom(1, 4);
				if (chance <= 2) {
					quirks.rearLipedema = 2;
				} else if (chance === 4) {
					quirks.rearLipedema = 1;
				}
			}
		}

		//gigantomastia
		if (father !== 0) {
			if (mother.geneticQuirks.gigantomastia >= 2 && father.geneticQuirks.gigantomastia >= 2) {
				if (jsRandom(1, 4) === 1) {
					quirks.gigantomastia = 3;
				} else {
					quirks.gigantomastia = 1;
				}
			} else if ((mother.geneticQuirks.gigantomastia >= 2 && father.geneticQuirks.gigantomastia === 1) || (mother.geneticQuirks.gigantomastia === 1 && father.geneticQuirks.gigantomastia >= 2)) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.gigantomastia = 3;
				} else if (chance !== 4) {
					quirks.gigantomastia = 1;
				}
			} else if (mother.geneticQuirks.gigantomastia === 1 && father.geneticQuirks.gigantomastia === 1) {
				if (jsRandom(1, 4) === 1) {
					quirks.gigantomastia = 3;
				}
			}
		} else if (mother.geneticQuirks.gigantomastia >= 1) {
			if (jsRandom(0, 40000) >= 39500) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.gigantomastia = 3;
				} else if (chance !== 4) {
					quirks.gigantomastia = 1;
				}
			}
		}

		//macromastia
		if (father !== 0) {
			if (mother.geneticQuirks.macromastia >= 2 && father.geneticQuirks.macromastia >= 2) {
				if (jsRandom(1, 4) === 1) {
					quirks.macromastia = 3;
				} else {
					quirks.macromastia = 1;
				}
			} else if ((mother.geneticQuirks.macromastia >= 2 && father.geneticQuirks.macromastia === 1) || (mother.geneticQuirks.macromastia === 1 && father.geneticQuirks.macromastia >= 2)) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.macromastia = 3;
				} else if (chance !== 4) {
					quirks.macromastia = 1;
				}
			} else if (mother.geneticQuirks.macromastia === 1 && father.geneticQuirks.macromastia === 1) {
				if (jsRandom(1, 4) === 1) {
					quirks.macromastia = 3;
				}
			}
		} else if (mother.geneticQuirks.macromastia >= 1) {
			if (jsRandom(0, 40000) >= 39500) {
				chance = jsRandom(1, 4);
				if (chance === 1) {
					quirks.macromastia = 3;
				} else if (chance !== 4) {
					quirks.macromastia = 1;
				}
			}
		}

		return clone(quirks);
	}

	return generateGenetics;
})();

window.generateChild = function (mother, ova, destination) {
	let V = State.variables;
	let genes = ova.genetics; //maybe just argument this? We'll see.
	let pregUpgrade = V.pregnancyMonitoringUpgrade;
	let child = {};

	if (!destination) { //does extra work for the incubator if defined, otherwise builds a simple object
		if (genes.gender === "XX") {
			child.genes = "XX";
			child.slaveSurname = genes.surname;
			if (!pregUpgrade) {
				if (genes.mother === -1) {
					if (genes.father <= 0) {
						child.slaveName = `Your daughter`;
					} else {
						child.slaveName = `Your and ${genes.fatherName}'s daughter`;
					}
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveName = `${genes.motherName}'s and your daughter`;
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						child.slaveName = `${genes.motherName} and ${genes.fatherName}'s daughter`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						child.slaveName = `${genes.motherName}'s bastard daughter`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			} else {
				let childName = genes.name;
				if (childName.indexOf("ovum") === 0) {
					if (genes.mother === -1) {
						if (genes.father <= 0) {
							child.slaveName = "Your son";
						} else {
							child.slaveName = `Your and ${genes.fatherName}'s son`;
						}
					} else {
						if (genes.father === -1) {
							child.slaveName = `${genes.motherName}'s and your son`;
						} else if (genes.father > 0) {
							child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`;
						} else {
							child.slaveName = `${genes.motherName}'s bastard son`;
						}
					}
				} else {
					child.slaveName = genes.name;
				}
				if (genes.mother === -1) {
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			}
		} else {
			child.genes = "XY";
			child.slaveSurname = genes.surname;
			if (!pregUpgrade) {
				if (genes.mother === -1) {
					if (genes.father <= 0) {
						child.slaveName = "Your son";
					} else {
						child.slaveName = `Your and ${genes.fatherName}'s son`;
					}
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveName = `${genes.motherName}'s and your son`;
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						child.slaveName = `${genes.motherName}'s bastard son`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			} else {
				let childName = genes.name;
				if (childName.indexOf("ovum") === 0) {
					if (genes.mother === -1) {
						if (genes.father <= 0) {
							child.slaveName = "Your son";
						} else {
							child.slaveName = `Your and ${genes.fatherName}'s son`;
						}
					} else {
						if (genes.father === -1) {
							child.slaveName = `${genes.motherName}'s and your son`;
						} else if (genes.father > 0) {
							child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`;
						} else {
							child.slaveName = `${genes.motherName}'s bastard son`;
						}
					}
				} else {
					child.slaveName = genes.name;
				}
				if (genes.mother === -1) {
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			}
		}

		child.mother = genes.mother;
		child.father = genes.father;
		child.nationality = genes.nationality;
		child.race = genes.race;
		child.intelligence = genes.intelligence;
		if (mother.prematureBirth > 0) {
			if (child.intelligence >= -90) {
				child.intelligence -= jsRandom(0, 10);
			}
			child.premature = 1;
		}
		child.face = genes.face;
		child.underArmHStyle = genes.underArmHStyle;
		child.pubicHStyle = genes.pubicHStyle;
		child.markings = genes.markings;
		child.sexualFlaw = genes.sexualFlaw;
		child.behavioralFlaw = genes.behavioralFlaw;
		child.fetish = genes.fetish;
		child.geneticQuirks = clone(genes.geneticQuirks);
		if (child.geneticQuirks.albinism === 2) {
			child.albinismOverride = {skin: genes.skin, eyeColor: genes.eyeColor, hColor: genes.hColor};
			child.hColor = "white";
			child.pubicHColor = child.hColor;
			child.underArmHColor = child.hColor;
			child.eyebrowHColor = child.hColor;
			child.eyeColor = "red";
			switch (child.race) {
				case "black":
				case "indo-aryan":
				case "malay":
				case "pacific islander":
				case "amerindian":
					child.skin = "very fair";
					break;
				case "latina":
					child.skin = "extremely fair";
					break;
				case "asian":
				case "middle eastern":
				case "semitic":
				case "southern european":
				case "white":
					child.skin = "pure white";
					break;
				default:
					child.skin = "pure white";
			}
		} else {
			child.skin = genes.skin;
			child.eyeColor = genes.eyeColor;
			child.hColor = genes.hColor;
			child.pubicHColor = child.hColor;
			child.underArmHColor = child.hColor;
			child.eyebrowHColor = child.hColor;
		}
		child.birthWeek = 0;
		if (genes.faceShape !== undefined) {
			child.faceShape = genes.faceShape;
		}
		if (mother.addict > 0) {
			child.addict = Math.trunc(mother.addict / 2);
		}
		child.weekAcquired = V.week;
		if (child.nationality === "Stateless") {
			if (V.arcologies[0].FSRomanRevivalist > 90) {
				child.nationality = "Roman Revivalist";
			} else if (V.arcologies[0].FSAztecRevivalist > 90) {
				child.nationality = "Aztec Revivalist";
			} else if (V.arcologies[0].FSEgyptianRevivalist > 90) {
				child.nationality = "Ancient Egyptian Revivalist";
			} else if (V.arcologies[0].FSEdoRevivalist > 90) {
				child.nationality = "Edo Revivalist";
			} else if (V.arcologies[0].FSArabianRevivalist > 90) {
				child.nationality = "Arabian Revivalist";
			} else if (V.arcologies[0].FSChineseRevivalist > 90) {
				child.nationality = "Ancient Chinese Revivalist";
			}
		}
	} else {
		V.activeSlaveOneTimeMinAge = V.targetAge;
		V.activeSlaveOneTimeMaxAge = V.targetAge;
		V.one_time_age_overrides_pedo_mode = 1;
		V.ageAdjustOverride = 1;

		if (genes.gender === "XX") {
			child = GenerateNewSlave("XX");
			child.slaveSurname = genes.surname;
			if (!pregUpgrade) {
				if (genes.mother === -1) {
					if (genes.father <= 0) {
						child.slaveName = `Your daughter`;
					} else {
						child.slaveName = `Yours and ${genes.fatherName}'s daughter`;
					}
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveName = `Yours and ${genes.motherName}'s daughter`;
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						child.slaveName = `${genes.motherName} and ${genes.fatherName}'s daughter`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						child.slaveName = `${genes.motherName}'s bastard daughter`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			} else {
				let childName = genes.name;
				if (childName.indexOf("ovum") === 0) {
					if (genes.mother === -1) {
						if (genes.father <= 0) {
							child.slaveName = `Your daughter`;
						} else {
							child.slaveName = `Yours and ${genes.fatherName}'s daughter`;
						}
					} else {
						if (genes.father === -1) {
							child.slaveName = `Yours and ${genes.motherName}'s daughter`;
						} else if (genes.father > 0) {
							child.slaveName = `${genes.motherName} and ${genes.fatherName}'s daughter`;
						} else {
							child.slaveName = `${genes.motherName}'s bastard daughter`;
						}
					}
				} else {
					child.slaveName = genes.name;
				}
				if (genes.mother === -1) {
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			}
		} else {
			child = GenerateNewSlave("XY");
			child.slaveSurname = genes.surname;
			if (!pregUpgrade) {
				if (genes.mother === -1) {
					if (genes.father <= 0) {
						child.slaveName = "Your son";
					} else {
						child.slaveName = `Your and ${genes.fatherName}'s son`;
					}
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveName = `${genes.motherName} and your son`;
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						child.slaveName = `${genes.motherName}'s bastard son`;
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			} else {
				let childName = genes.name;
				if (childName.indexOf("ovum") === 0) {
					if (genes.mother === -1) {
						if (genes.father <= 0) {
							child.slaveName = "Your son";
						} else {
							child.slaveName = `Your and ${genes.fatherName}'s son`;
						}
					} else {
						if (genes.father === -1) {
							child.slaveName = `${genes.motherName} and your son`;
						} else if (genes.father > 0) {
							child.slaveName = `${genes.motherName} and ${genes.fatherName}'s son`;
						} else {
							child.slaveName = `${genes.motherName}'s bastard son`;
						}
					}
				} else {
					child.slaveName = genes.name;
				}
				if (genes.mother === -1) {
					child.slaveSurname = V.PC.surname;
				} else {
					if (genes.father === -1) {
						child.slaveSurname = V.PC.surname;
					} else if (genes.father > 0) {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						} else {
							let currentFather = getSlave(genes.father);
							if (currentFather !== undefined) {
								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
									child.slaveSurname = currentFather.slaveSurname;
								}
							}
						}
					} else {
						let currentMother = getSlave(genes.mother);
						if (currentMother !== undefined) {
							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
								child.slaveSurname = currentMother.slaveSurname;
							}
						}
					}
				}
			}
		}

		if (genes.clone !== undefined) {
			child.clone = genes.clone;
			child.cloneID = genes.cloneID;
		}

		child.mother = genes.mother;
		child.father = genes.father;
		child.nationality = genes.nationality;
		child.skin = genes.skin;
		child.origSkin = child.skin;
		child.race = genes.race;
		child.origRace = child.race;
		child.intelligence = genes.intelligence;
		if (mother.prematureBirth > 0) {
			if (child.intelligence >= -90) {
				child.intelligence -= jsRandom(0, 10);
			}
			child.premature = 1;
		}
		child.face = genes.face;
		child.eyeColor = genes.eyeColor;
		child.origEye = child.eyeColor;
		child.hColor = genes.hColor;
		child.origHColor = child.HColor;
		child.underArmHStyle = genes.underArmHStyle;
		child.pubicHStyle = genes.pubicHStyle;
		child.markings = genes.markings;
		child.sexualFlaw = genes.sexualFlaw;
		child.behavioralFlaw = genes.behavioralFlaw;
		child.fetish = genes.fetish;
		child.geneticQuirks = clone(genes.geneticQuirks);
		child.pubicHColor = child.hColor;
		child.underArmHColor = child.hColor;
		child.eyebrowHColor = child.hColor;
		child.birthWeek = 0;
		child.energy = 0;
		child.anus = 0;
		if (child.vagina > 0) { child.vagina = 0; }
		if (child.fetish !== "none") { child.fetishStrength = 20; }
		if (child.dick > 0) {
			child.foreskin = 1;
			child.balls = 1;
			child.scrotum = 1;
		}
		if (genes.faceShape !== undefined) {
			child.faceShape = genes.faceShape;
		}
		if (mother.addict > 0) {
			child.addict = Math.trunc(mother.addict / 2);
		}
		child.career = "a slave since birth";
		child.birthName = child.slaveName;
		child.birthSurname = child.slaveSurname;
		child.devotion = 0;
		child.trust = 0;
		child.weekAcquired = V.week;
		if (child.nationality === "Stateless") {
			if (V.arcologies[0].FSRomanRevivalist > 90) {
				child.nationality = "Roman Revivalist";
			} else if (V.arcologies[0].FSAztecRevivalist > 90) {
				child.nationality = "Aztec Revivalist";
			} else if (V.arcologies[0].FSEgyptianRevivalist > 90) {
				child.nationality = "Ancient Egyptian Revivalist";
			} else if (V.arcologies[0].FSEdoRevivalist > 90) {
				child.nationality = "Edo Revivalist";
			} else if (V.arcologies[0].FSArabianRevivalist > 90) {
				child.nationality = "Arabian Revivalist";
			} else if (V.arcologies[0].FSChineseRevivalist > 90) {
				child.nationality = "Ancient Chinese Revivalist";
			}
		}

		child.weight = -100;
		child.muscles = -100;
		child.boobs = 0;
		child.butt = 0;
		child.chem = 990;
		child.areolaePiercing = 0;
		child.corsetPiercing = 0;
		child.boobsImplant = 0;
		child.boobsImplantType = 0;
		child.nipplesPiercing = 0;
		child.areolaePiercing = 0;
		child.lactation = 0;
		child.hipsImplant = 0;
		child.buttImplant = 0;
		child.buttImplantType = 0;
		child.lipsImplant = 0;
		child.lipsPiercing = 0;
		child.tonguePiercing = 0;
		child.vaginaPiercing = 0;
		child.preg = 0;
		child.pregType = 0;
		child.pregKnown = 0;
		child.belly = 0;
		child.bellyPreg = 0;
		child.bellyFluid = 0;
		child.bellyImplant = -1;
		child.cervixImplant = 0;
		child.clitPiercing = 0;
		child.dickPiercing = 0;
		child.makeup = 0;
		child.nails = 0;
		child.earPiercing = 0;
		child.nosePiercing = 0;
		child.eyebrowPiercing = 0;
		child.stampTat = 0;
		child.bellyTat = 0;
		child.anusPiercing = 0;
		child.anusTat = 0;
		child.shouldersTat = 0;
		child.armsTat = 0;
		child.legsTat = 0;
		child.backTat = 0;
		child.skill.combat = 0;
		child.skill.whoring = 0;
		child.skill.entertainment = 0;
		child.skill.oral = 0;
		child.skill.anal = 0;
		child.skill.vaginal = 0;
		child.accent = 4;
		child.canRecruit = 0;
		child.hStyle = "long";
		child.hLength = 300;
		if (V.incubatorImprintSetting === "terror") {
			child.origin = "She was conditioned from birth into mindless terror in an aging tank.";
			child.tankBaby = 2;
		} else {
			child.origin = "She was conditioned from birth into trusting obedience in an aging tank.";
			child.tankBaby = 1;
		}
		child.intelligenceImplant = 0;
		child.navelPiercing = 0;
	}
	return child;
};


code:
/* eslint-disable no-undef */
/*
 * <<htag>> macro
 * A simple macro which allows to create wrapping html elements with dynamic IDs.
 *	idea blatantly robbed from the spanMacroJS.tw but expanded to a more generic
 *	case, allowing <div>, <button> or whatever you want. elements, default is for
 *	the div though. In addition, you can pass an object in as the first argument
 *	instead of an id, and each of the object's attributes will become attributes
 *	of the generate tag.
 *
 * Usage: <<htag id>>...<</htag>>
 * Usage: <<htag id tag>>...<</htag>>
 * Usage: <<htag attributes>>...<</htag>>
 * Usage: <<htag attributes tag>>...<</htag>>
 */
Macro.add('htag', {
	tags: null,
	handler() {
		const payload = this.payload[0].contents.replace(/(^\n+|\n+$)/, '');
		let htag = 'div';
		let attributes;
		function munge (val, key) {
			return `${key }="${ val }"`;
		}

		if (1 > this.args.length)
			return this.error('invalid syntax, format: <<htag [id [ tag ] | attributes [ tag ] >>');
		if (1 < this.args.length)
			htag = String(this.args[1]).trim();
		if ("object" === typeof this.args[0])
			attributes = $.map(this.args[0], munge).join(" ");
		else
			attributes = `id="${ String(this.args[0]).trim() }"`;
		if (Config.debug)
			this.debugView.modes({block: true});

		jQuery(`<${ htag } ${ attributes } />`)
			.wiki(payload)
			.appendTo(this.output);
	}
});

repo_name: Dhanze/fc


code:
/* eslint-disable no-undef */
/**
 * @param {App.Entity.SlaveState} heroSlave
 * @param {App.Entity.SlaveState} baseHeroSlave
 * @return {App.Entity.SlaveState}
 */
App.Utils.getHeroSlave = function (heroSlave, baseHeroSlave) {
	function isObject(o) {
		return (o !== undefined && typeof o === 'object' && !Array.isArray(o));
	}

	function deepAssign(target, source) {
		if (isObject(target) && isObject(source)) {
			for (const key in source) {
				if (!source.hasOwnProperty(key)) continue;
				if (isObject(source[key])) {
					if (!target.hasOwnProperty(key)) target[key] = {};
					deepAssign(target[key], source[key]);
				} else {
					Object.assign(target, {
						[key]: source[key]
					});
				}
			}
		}
	}
	const newSlave = clone(baseHeroSlave);
	deepAssign(newSlave, heroSlave);
	generatePuberty(newSlave);
	return newSlave;
};


code:
/* eslint-disable no-undef */
/* intended to condense the clothing/toy/etc availability checks into something less asinine */

/**
 * Checks whether item is accessible
 * @param {string} string Name of the item
 * @returns {boolean}
 */
window.isItemAccessible = function(string) {
	const V = State.variables;

	if (V.cheatMode === 1) {
		return true;
	}
	switch (string) { /* no breaks needed because we always return */
		case "attractive lingerie for a pregnant woman":
			return (V.arcologies[0].FSRepopulationFocus > 0 || V.clothesBoughtMaternityLingerie === 1);
		case "a bunny outfit":
			return (V.arcologies[0].FSGenderFundamentalist > 0 || V.clothesBoughtBunny === 1);
		case "body oil":
			return (V.arcologies[0].FSPhysicalIdealist > 0 || V.clothesBoughtOil === 1);
		case "chains":
			return (V.arcologies[0].FSDegradationist > 0 || V.clothesBoughtChains === 1);
		case "a chattel habit":
			return (V.arcologies[0].FSChattelReligionist > 0 || V.clothesBoughtHabit === 1);
		case "conservative clothing":
			return (V.arcologies[0].FSPaternalist > 0 || V.clothesBoughtConservative === 1);
		case "harem gauze":
			return (V.arcologies[0].FSArabianRevivalist > 0 || V.clothesBoughtHarem === 1);
		case "a huipil":
			return (V.arcologies[0].FSAztecRevivalist > 0 || V.clothesBoughtHuipil === 1);
		case "a kimono":
			return (V.arcologies[0].FSEdoRevivalist > 0 || V.clothesBoughtKimono === 1 || V.continent === "Japan");
		case "a maternity dress":
			return (V.arcologies[0].FSRepopulationFocus > 0 || V.clothesBoughtMaternityDress === 1);
		case "a slutty qipao":
			return (V.arcologies[0].FSChineseRevivalist > 0 || V.clothesBoughtQipao === 1);
		case "a long qipao":
			return (V.arcologies[0].FSChineseRevivalist > 0 || V.clothesBoughtCultural === 1);
		case "stretch pants and a crop-top":
			return (V.arcologies[0].FSHedonisticDecadence > 0 || V.clothesBoughtLazyClothes === 1);
		case "a toga":
			return (V.arcologies[0].FSRomanRevivalist > 0 || V.clothesBoughtToga === 1);
		case "Western clothing":
			return (V.arcologies[0].FSPastoralist > 0 || V.clothesBoughtWestern === 1);
		case "battlearmor":
		case "a military uniform":
		case "a red army uniform":
		case "battledress":
			return (V.clothesBoughtMilitary === 1);
		case "a biyelgee costume":
		case "a dirndl":
		case "lederhosen":
		case "a mounty outfit":
		case "a hanbok":
			return (V.clothesBoughtCultural === 1);
		case "a burqa":
		case "a niqab and abaya":
			return (V.clothesBoughtMiddleEastern === 1 || V.continent === "the Middle East");
		case "a hijab and blouse":
			return (V.clothesBoughtMiddleEastern === 1 || V.clothesBoughtConservative === 1 || V.continent === "the Middle East");
		case "a burkini":
			return (V.clothesBoughtMiddleEastern === 1 && V.clothesBoughtSwimwear === 1 || V.continent === "the Middle East");
		case "a Santa dress":
			return (V.clothesBoughtCostume === 1);
		case "a klan robe":
		case "a slutty klan robe":
		case "a schutzstaffel uniform":
		case "a slutty schutzstaffel uniform":
			return (V.clothesBoughtPol === 1);
		case "nice business attire":
		case "a nice nurse outfit":
		case "a police uniform":
			return (V.clothesBoughtCareer === 1);
		case "a nice maid outfit":
			return (V.clothesBoughtCareer === 1 || V.PC.career === "servant");
		case "a ball gown":
		case "a gothic lolita dress":
			//case 'a halter top dress':
			//case 'a mini dress':
			//case 'a slave gown':
			return (V.clothesBoughtDresses === 1);
		case "a cybersuit":
		case "a latex catsuit":
			return (V.clothesBoughtBodysuits === 1);
		case "a button-up shirt and panties":
		case "a button-up shirt":
		case "cutoffs":
		case "jeans":
		case "leather pants and a tube top":
		case "leather pants":
		case "an oversized t-shirt":
		case "a sweater and cutoffs":
		case "a sweater and panties":
		case "a sweater":
		case "a t-shirt and jeans":
		case "a t-shirt and panties":
		case "a t-shirt":
		case "a tank-top and panties":
		case "a tank-top":
		case "a tube top":
			return (V.clothesBoughtCasual === 1);
		case "boyshorts":
		case "a bra":
		case "kitty lingerie":
		case "panties and pasties":
		case "a skimpy loincloth":
		case "a thong":
			return (V.clothesBoughtUnderwear === 1);
		case "leather pants and pasties":
		case "a t-shirt and thong":
		case "a tube top and thong":
		case "an oversized t-shirt and boyshorts":
			return (V.clothesBoughtUnderwear === 1 && V.clothesBoughtCasual === 1);
		case "sport shorts and a sports bra":
		case "sport shorts":
		case "a sports bra":
			return (V.clothesBoughtSports === 1);
		case "sport shorts and a t-shirt":
			return (V.clothesBoughtSports === 1 && V.clothesBoughtCasual === 1);
		case "a nice pony outfit":
		case "a slutty pony outfit":
			return (V.clothesBoughtPony === 1);
		case "a monokini":
		case "a one-piece swimsuit":
			return (V.clothesBoughtSwimwear === 1);
		case "a striped bra":
		case "striped panties":
		case "striped underwear":
			return (V.clothesBoughtPantsu === 1 || V.continent === "Japan");
		case "bowtie":
			return (V.arcologies[0].FSGenderFundamentalist > 0 || V.clothesBoughtBunny === 1);
		case "ancient Egyptian":
			return (V.arcologies[0].FSEgyptianRevivalist > 0 || V.clothesBoughtEgypt === 1);
		case "pasties": /* an option in saChoosesOwnClothes.tw, but everything else (e.g. descriptions, artwork, option in wardrobeUse.tw) is missing or not hooked up correctly */
			return false;
		case "massive dildo gag":
			return (V.toysBoughtGags === 1);
		case "a small empathy belly":
		case "a medium empathy belly":
		case "a large empathy belly":
		case "a huge empathy belly":
			return (V.arcologies[0].FSRepopulationFocus > 0 || V.clothesBoughtBelly === 1);
		case "bullet vibrator":
		case "smart bullet vibrator":
		case "long dildo":
		case "long, large dildo":
		case "long, huge dildo":
			return (V.toysBoughtDildos === 1);
		case "vibrator":
			return (V.toysBoughtVaginalAttachments === 1);
		case "long plug":
		case "long, large plug":
		case "long, huge plug":
			return (V.toysBoughtButtPlugs === 1);
		case "tail":
		case "cat tail":
		case "fox tail":
			return (V.toysBoughtButtPlugTails === 1);
		default:
			return true;
	}
};


code:
/* eslint-disable no-empty */
/* eslint-disable no-console */
/* eslint-disable no-undef */
/* Use like:
	<<options $varname "New Passage (defaults to current passage)">>
	  A title
	  <<option "value_to_set_varname_to" "English text to show user" "additional variables to set when clicked" "Extra English text to show, but not as a link">>
		 Text to show if $varname matches this option
	  <<option ....>>
	  <<comment>>
		Some comment to add at the end
	<</option>>

	optionlt and optionslte lets you also specify a 'less than' or 'less than or
	equal' value, to show an option as selected if it is less than this amount
	(and not selected by a previous option)

	<<optionlt "less than value" "value_to_set_varname_to" "English text to show user" "additional variables to set when clicked" "Extra English text to show, but not as a link">>
  */
Macro.add('options', {
	skipArgs : false,
	tags	 : ['option', 'comment', 'optionlt', 'optionlte', 'optiongt', 'optiongte',
				'optiondefault', 'optionif'],
	handler : function () {
		try {
			var currentOption = this.payload[0].args[0];
			var currentOptionIsNumber = typeof currentOption === "number";
			var variable = null;
			var title = this.payload[0].contents || '';
			var passageName = this.payload[0].args[1] || passage();
			var found = false;
			var found_index = 0;
			var comment = null;
			var hasMultipleOptionsWithSameValue = false;
			var description = "";
			var hasCurrentOption = this.payload[0].args.full &&
			this.payload[0].args.full !== '""' && this.payload[0].args.full !== "''";

			/* Check if we have a first argument - if we do, it should be a
			   variable like $foo
			  */
			if (hasCurrentOption) {
				if (currentOption === undefined)
					currentOption = false;
				if (this.payload[0].args.full.startsWith("State.temporary.")) {
					variable = "_" + this.payload[0].args.full.split(' ',1)[0].substring("State.temporary.".length);
				} else if (this.payload[0].args.full.startsWith("State.variables.")) {
					variable = "$" + this.payload[0].args.full.split(' ',1)[0].substring("State.variables.".length);
				} else {
					console.log(this.payload[0].args.full);
					throw new Error("First parameter to 'options' must be a variable");
				}

				/* First print out the string for the current value */
				for (let i = 1, len = this.payload.length; i < len; ++i) {
					if (this.payload[i].name === 'option') {
						if (this.payload[i].args[0] === currentOption) {
							if (found) {
								hasMultipleOptionsWithSameValue = true;
							} else {
								description = this.payload[i].contents;
								found_index = i;
								found = true;
							}
						}
					} else if (this.payload[i].name === 'optionlt') {
						if (!found && this.payload[i].args[0] > currentOption) {
							description = this.payload[i].contents;
							found = true;
							found_index = i;
						}
					} else if (this.payload[i].name === 'optionlte') {
						if (!found && this.payload[i].args[0] >= currentOption) {
							description = this.payload[i].contents;
							found = true;
							found_index = i;
						}
					} else if (this.payload[i].name === 'optiongt') {
						if (!found && this.payload[i].args[0] < currentOption) {
							description = this.payload[i].contents;
							found = true;
							found_index = i;
						}
					} else if (this.payload[i].name === 'optiongte') {
						if (!found && this.payload[i].args[0] <= currentOption) {
							description = this.payload[i].contents;
							found = true;
							found_index = i;
						}
					} else if (this.payload[i].name === 'optiondefault') {
						if (!found) {
							description = this.payload[i].contents;
							found = true;
							found_index = i;
						}
					} else if (this.payload[i].name === 'comment') {
					} else if (this.payload[i].name === 'optionif') {
					} else {
						throw new Error("Only valid tag is 'option' inside 'options'");
					}
				}
			} else {
				// No variable was passed to <<options>>
				// This is valid, but then we only allow an empty <<option>> or <<comment>>
				// inside
				for (let i = 1, len = this.payload.length; i < len; ++i) {
					if (this.payload[i].name === 'option' && this.payload[i].args.length === 0) {
						// This is valid for an empty <<options>>
					} else if (this.payload[i].name === "comment") {
						// This is valid for an empty <<options>>
					} else {
						throw new Error("Missing variable to <<options>>");
					}

				}

			}

			var showSelectedOption = true; //this.payload.length !== 3 || !description;
			/* Now print out the list of options */
			var output = "";
			var optionIfIsFalse = false;
			for (let i = 1, len = this.payload.length; i < len; ++i) {
				if (this.payload[i].name === "optionif") {
					if (this.payload[i].args.length === 0) {
						optionIfIsFalse = false; /* No options means to turn off optionif */
					} else if (this.payload[i].args.length === 1) {
						// Evaluate it and see if is false
						if (typeof(this.payload[i].args[0]) !== 'boolean') {
							throw new Error("optionif requires true or false for the first (and only) parameter");
						}
						optionIfIsFalse = !this.payload[i].args[0];
					} else {
						throw new Error("Only one argument expected to 'optionif'");
					}
					continue;
				}
				if (optionIfIsFalse) {
					continue;
				} else if (this.payload[i].name.startsWith('option')) {
					var args = this.payload[i].args;
					var hasComparitor = this.payload[i].name !== "option" && this.payload[i].name !== "optiondefault";
					var argText = args[hasComparitor ? 2 : 1] || "";
					if (args.length === 0) {
						output += this.payload[i].contents.trim();
					} else {
						var extraComment = args[hasComparitor ? 4: 3];
						extraComment = extraComment ? ' ' + extraComment : '';
						// We use a very crude heuristic for styling 'Enable'
						// and 'Disable' buttons differently.
						const isEnableOption = argText && (argText.startsWith("Enable") || argText === "Yes" || argText.startsWith("Allow"));
						const isDisableOption = argText && (argText.startsWith("Disable") || argText === "No" || argText.startsWith("Deny"));
						var className = "optionMacroOption " + (isEnableOption ? "optionMacroEnable" : isDisableOption ? "optionMacroDisable" : "");
						if (found_index !== i || hasMultipleOptionsWithSameValue) {
							var onClickChange = args[hasComparitor ? 3 : 2];
							onClickChange = onClickChange ? ', ' + onClickChange : '';
							output += '[[' + argText + extraComment + '|' + passageName + "][" + variable + " = " + JSON.stringify(args[hasComparitor ? 1 : 0]) + onClickChange + "]]" + "";
						} else if (showSelectedOption) {
							output +='' + argText + extraComment + '';
						}
					}
				} else if (this.payload[i].name === 'comment') {
					comment = this.payload[i].contents;
				}
			}
			jQuery(this.output).wiki(
				'' +
					'' + title + ' ' + description + "" +
					'' + output + "" +
					(comment ? '//' + comment + "//" : '') +
				'');
		}
		catch (ex) {
			return this.error('bad options expression: ' + ex.message);
		}
	}
});


code:
/* eslint-disable no-empty */
/* eslint-disable no-undef */
/* Major props to the anons who worked together to forge the Super Pregnancy Project. Let your legacy go unforgotten.*/
window.getPregBellySize = function(s) {
	var targetLen;
	var gestastionWeek = s.preg;
	var fetuses = s.pregType;
	var phi = 1.618;

	if(gestastionWeek <= 32) {
		targetLen = ((0.00006396 * Math.pow(gestastionWeek, 4)) - (0.005501 * Math.pow(gestastionWeek, 3)) + (0.161 * Math.pow(gestastionWeek, 2)) - (0.76 * gestastionWeek) + 0.208);
	} else if(gestastionWeek <= 106) {
		targetLen = ((-0.0000004675 * Math.pow(gestastionWeek, 4)) + (0.0001905 * Math.pow(gestastionWeek, 3)) - (0.029 * Math.pow(gestastionWeek, 2)) + (2.132 * gestastionWeek) - 16.575);
	} else {
		targetLen = ((-0.00003266 * Math.pow(gestastionWeek,2)) + (0.076 * gestastionWeek) + 43.843);
	}

	var bellySize = ((4 / 3) * (Math.PI) * (phi / 2) * (Math.pow((targetLen / 2), 3)) * fetuses);
	return bellySize;
};

/** @param {App.Entity.SlaveState} slave */
window.bellyAdjective = function(slave) {
	slave = slave || State.variables.activeSlave;
	if(slave.belly >= 1500) {
		if(slave.belly >= 1000000) {
			if(slave.preg > slave.pregData.normalBirth/4) {
				return 'unfathomably distended, brimming with life';
			} else {
				return 'unfathomable';
			}
		} else if(slave.belly >= 750000) {
			if(slave.preg > slave.pregData.normalBirth/4) {
				return 'monolithic bulging';
			} else {
				return 'monolithic';
			}
		} else if(slave.belly >= 600000) {
			if(slave.preg > slave.pregData.normalBirth/4) {
				return 'titanic bulging';
			} else {
				return 'titanic';
			}
		} else if(slave.belly >= 450000) {
			if(slave.preg > slave.pregData.normalBirth/4) {
				return 'gigantic bulgy';
			} else {
				return 'gigantic';
			}
		} else if(slave.belly >= 300000) {
			return 'massive';
		} else if(slave.belly >= 100000) {
			return 'giant';
		} else if(slave.belly >= 15000) {
			return 'huge';
		} else if(slave.belly >= 10000) {
			return 'big';
		} else {
			return 'swollen';
		}
	} else {
		return '';
	}
};

/* calculates and returns expected ovum count during conception*/
window.setPregType = function(actor) {
	/* IMHO rework is possible. Can be more interesting to play, if this code will take in account more body conditions - age, fat, food, hormone levels, etc. */

	var ovum = jsRandom(actor.pregData.normalOvaMin, actor.pregData.normalOvaMax); //for default human profile it's always 1.
	var fertilityStack = 0; // adds an increasing bonus roll for stacked fertility drugs

	/* Suggestion for better animal pregnancy support - usage of another variable then ovum for fertility drugs bonus, and then adding actor.pregData.drugsEffect multiplier to it before adding to ovum. Example:

		var bonus = 0;

		... (code below where ovum changed to bonus)

		bonus *= actor.pregData.drugsEffect;
		ovum += bonus;

	*/

	if(actor.broodmother < 1) { // Broodmothers should be not processed here. Necessary now.
		if(typeof actor.readyOva === "number" && actor.readyOva !== 0) {
			ovum = actor.readyOva; //just single override; for delayed impregnation cases
		} else if(actor.ID === -1) {
			if(actor.geneticQuirks.fertility === 2 && actor.geneticQuirks.hyperFertility === 2) { // Do not mix with sperm
				if(actor.fertDrugs === 1) {
					ovum += jsEither([2, 3, 3, 3, 3, 4, 4, 5]);
				} else {
					ovum += jsEither([1, 1, 2, 2, 3, 3, 4]);
				}
				if(actor.forcedFertDrugs > 0) {
					ovum += jsEither([3, 3, 4, 4, 5]);
				}
			} else if(actor.geneticQuirks.hyperFertility === 2) { // Predisposed to multiples
				if(actor.fertDrugs === 1) {
					ovum += jsEither([1, 2, 2, 2, 2, 3, 3, 4]);
				} else {
					ovum += jsEither([0, 1, 1, 1, 1, 1, 2, 3]);
				}
				if(actor.forcedFertDrugs > 0) {
					ovum += jsEither([2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4]);
				}
			} else if(actor.geneticQuirks.fertility === 2) { // Predisposed to twins
				if(actor.fertDrugs === 1) {
					ovum += jsEither([1, 1, 2, 2, 2, 2, 3, 3]);
				} else {
					ovum += jsEither([0, 0, 0, 1, 1, 1, 1, 1, 1, 2]);
				}
				if(actor.forcedFertDrugs > 0) {
					ovum += jsEither([1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4]);
				}
			} else {
				if(actor.fertDrugs === 1) {
					ovum += jsEither([0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3]);
				} else {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
				}
				if(actor.forcedFertDrugs > 0) {
					ovum += jsEither([0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4]);
				}
			}
			ovum = Math.clamp(ovum, 0, 8);
		} else if(actor.pregType === 0) {
			if(actor.eggType === "horse" || actor.eggType === "cow") {
				if(actor.geneticQuirks.fertility === 2 && actor.geneticQuirks.hyperFertility === 2) { // Do not mix with sperm
					ovum += jsEither([0, 0, 0, 0, 0, 0, 1]);
					fertilityStack += .8;
				} else if(actor.geneticQuirks.hyperFertility === 2) { // Predisposed to multiples
					fertilityStack += .4;
				} else if(actor.geneticQuirks.fertility === 2) { // Predisposed to twins
					fertilityStack += .2;
				}
				if(actor.ovaImplant === "fertility") {
					fertilityStack += .3;
				}
				if(actor.hormones === 2) {
					fertilityStack += .2;
				}
				if(actor.hormoneBalance >= 200) {
					fertilityStack += .3;
				}
				if(actor.diet === "fertility") {
					fertilityStack += .3;
				}
				if(State.variables.masterSuitePregnancyFertilitySupplements === 1 && ((actor.assignment === "serve in the master suite" || actor.assignment === "be your Concubine"))) {
					fertilityStack += .5;
				}
				if(State.variables.reproductionFormula === 1 && (State.variables.week-actor.weekAcquired > 0)) {
					fertilityStack += .2;
				}
				if(actor.drugs === "super fertility drugs") {
					fertilityStack += 1.6;
				} else if(actor.drugs === "fertility drugs") {
					fertilityStack += .6;
				}
				fertilityStack = Math.floor(fertilityStack);
				if(State.variables.seeHyperPreg === 1) {
					if(actor.drugs === "super fertility drugs") {
						ovum += jsRandom(0, fertilityStack*2);
					} else {
						ovum += jsRandom(0, fertilityStack);
					}
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
					}
				} else {
					ovum += jsRandom(0, fertilityStack);
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
						if(ovum > 4) {
							ovum = 4;
						}
					} else if(ovum > 3) {
						ovum = 3;
					}
				}
			} else if(actor.eggType === "dog") {
				if(actor.geneticQuirks.fertility === 2 && actor.geneticQuirks.hyperFertility === 2) { // Do not mix with sperm
					ovum += jsEither([1, 2, 2, 3]);
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
				} else if(actor.geneticQuirks.hyperFertility === 2) { // Predisposed to multiples
					ovum += jsEither([0, 1, 1, 2]);
					fertilityStack++;
					fertilityStack++;
				} else if(actor.geneticQuirks.fertility === 2) { // Predisposed to twins
					ovum += jsEither([0, 0, 0, 0, 1]);
					fertilityStack++;
				}
				if(actor.ovaImplant === "fertility") {
					ovum += jsEither([0, 0, 0, 0, 1]);
					fertilityStack++;
				}
				if(actor.hormones === 2) {
					ovum += jsEither([0, 0, 0, 1, 1, 1, 1, 2]);
					fertilityStack++;
				}
				if(actor.hormoneBalance >= 200) {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2]);
					fertilityStack++;
				}
				if(actor.diet === "fertility") {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 0, 0, 1]);
					fertilityStack++;
				}
				if(State.variables.masterSuitePregnancyFertilitySupplements === 1 && ((actor.assignment === "serve in the master suite" || actor.assignment === "be your Concubine"))) {
					ovum += jsEither([0, 0, 0, 1, 1, 2, 2, 2, 3, 3]);
					fertilityStack++;
					fertilityStack++;
				}
				if(State.variables.reproductionFormula === 1 && (State.variables.week-actor.weekAcquired > 0)) {
					fertilityStack++;
				}
				if(actor.drugs === "super fertility drugs") {
					ovum += jsEither([1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5]);
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
				} else if(actor.drugs === "fertility drugs") {
					ovum += jsEither([0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3]);
					fertilityStack++;
				}
				if(State.variables.seeHyperPreg === 1) {
					if(actor.drugs === "super fertility drugs") {
						ovum += jsRandom(0, fertilityStack*2);
					} else {
						ovum += jsRandom(0, fertilityStack);
					}
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
					}
				} else {
					ovum += jsRandom(0, fertilityStack);
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
						if(ovum > 8) {
							ovum = jsEither([6, 8]);
						}
					} else if(ovum > 8) {
						ovum = jsRandom(6, 8);
					}
				}
			} else if(actor.eggType === "pig") {
				if(actor.geneticQuirks.fertility === 2 && actor.geneticQuirks.hyperFertility === 2) { // Do not mix with sperm
					ovum += jsRandom(4, 8);
					fertilityStack += 16;
				} else if(actor.geneticQuirks.hyperFertility === 2) { // Predisposed to multiples
					ovum += jsRandom(2, 6);
					fertilityStack += 10;
				} else if(actor.geneticQuirks.fertility === 2) { // Predisposed to twins
					ovum += jsRandom(2, 4);
					fertilityStack += 6;
				}
				if(actor.ovaImplant === "fertility") {
					ovum += jsRandom(4, 12);
					fertilityStack += 6;
				}
				if(actor.hormones === 2) {
					ovum += jsRandom(0, 4);
					fertilityStack += 3;
				}
				if(actor.hormoneBalance >= 200) {
					ovum += jsRandom(0, 4);
					fertilityStack += 3;
				}
				if(actor.diet === "fertility") {
					ovum += jsRandom(4, 10);
					fertilityStack += 6;
				}
				if(State.variables.masterSuitePregnancyFertilitySupplements === 1 && ((actor.assignment === "serve in the master suite" || actor.assignment === "be your Concubine"))) {
					ovum += jsRandom(8, 16);
					fertilityStack += 10;
				}
				if(State.variables.reproductionFormula === 1 && (State.variables.week-actor.weekAcquired > 0)) {
					fertilityStack += 2;
				}
				if(actor.drugs === "super fertility drugs") {
					ovum += jsRandom(10, 40);
					fertilityStack += 32;
				} else if(actor.drugs === "fertility drugs") {
					ovum += jsRandom(10, 20);
					fertilityStack += 16;
				}
				if(State.variables.seeHyperPreg === 1) {
					if(actor.drugs === "super fertility drugs") {
						ovum += jsRandom(fertilityStack/2, fertilityStack*2);
					} else {
						ovum += jsRandom(fertilityStack/4, fertilityStack);
					}
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
					}
				} else {
					ovum += jsRandom(0, fertilityStack);
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
						if(ovum > 76) {
							ovum = jsEither([70, 72, 74, 76]);
						}
					} else if(ovum > 75) {
						ovum = jsRandom(60, 75);
					}
				}
			} else {
				if(actor.geneticQuirks.fertility === 2 && actor.geneticQuirks.hyperFertility === 2) { // Do not mix with sperm
					ovum += jsEither([1, 2, 2, 3]);
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
				} else if(actor.geneticQuirks.hyperFertility === 2) { // Predisposed to multiples
					ovum += jsEither([0, 1, 1, 2]);
					fertilityStack++;
					fertilityStack++;
				} else if(actor.geneticQuirks.fertility === 2) { // Predisposed to twins
					ovum += jsEither([0, 0, 0, 0, 1]);
					fertilityStack++;
				} else {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); //base chance for twins
				}
				if(actor.ovaImplant === "fertility") {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
					fertilityStack++;
				}
				if(actor.hormones === 2) {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2]);
					fertilityStack++;
				}
				if(actor.hormoneBalance >= 200) {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2]);
					fertilityStack++;
				}
				if(actor.diet === "fertility") {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
					fertilityStack++;
				}
				if(State.variables.masterSuitePregnancyFertilitySupplements === 1 && ((actor.assignment === "serve in the master suite" || actor.assignment === "be your Concubine"))) {
					ovum += jsEither([0, 0, 0, 1, 1, 2, 2, 2, 3, 3]);
					fertilityStack++;
					fertilityStack++;
				}
				if(State.variables.reproductionFormula === 1 && (State.variables.week-actor.weekAcquired > 0)) {
					fertilityStack++;
				}
				if(actor.drugs === "super fertility drugs") {
					ovum += jsEither([1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5]);
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
					fertilityStack++;
				} else if(actor.drugs === "fertility drugs") {
					ovum += jsEither([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3]);
					fertilityStack++;
				}
				if(State.variables.seeHyperPreg === 1) {
					if(actor.drugs === "super fertility drugs") {
						ovum += jsRandom(0, fertilityStack*2);
					} else {
						ovum += jsRandom(0, fertilityStack);
					}
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
					}
				} else {
					ovum += jsRandom(0, fertilityStack);
					if(actor.ovaImplant === "sympathy") {
						ovum *= 2;
						if(ovum > 12) {
							ovum = jsEither([10, 12]);
						}
					} else if(ovum > 12) {
						ovum = jsRandom(6, 12);
					}
				}
			}
		}
	}
	if (actor.geneticQuirks.superfetation === 2 && actor.womb.length > 0) {
		ovum = Math.ceil(ovum / 4);
	}
	return ovum;
};

/*
 Penetrative ability, ability to become pregnant, and canBreed() must be checked outside of this. Designed to assume .eggType === "human".
 target is the slave to get pregnant. Also accepts the PC.
 chance is the % chance to conceive.
 hole control's the hole involved (0 - vagina, 1 - ass, 2 - both). .mpreg did this.
 fatherID is the ID of her sire or 0 if undefined.
 displayOverride is an override if defined - fatherID must be defined in this case.
*/
window.knockMeUp = function(target, chance, hole, fatherID, displayOverride) {
	const V = State.variables;
	let pronouns;
	let He;
	let r = "";
	if (target.ID !== -1) {
		pronouns = getPronouns(target);
		He = capFirstChar(pronouns.pronoun);
	}
	if (V.seePreg !== 0) {
		if (jsRandom(0,99) < (chance + (V.reproductionFormula*((target.pregSource <= 0) ? ((target.ID === -1) ? 0 : 10) : 20)))) {
			if (target.mpreg === hole) {

				if (target.pregWeek <= 0) {
					target.preg = 1;
					target.pregSource = (!fatherID ? 0 : fatherID);
					if (target.ID !== -1) {
						target.pregWeek = 1;
					}
				}

				target.pregType = setPregType(target);
				WombImpregnate(target, target.pregType, target.pregSource, 1);

				if (V.menstruation === 1) {
				}
				else if (!displayOverride) {
					target.pregKnown = 1;
					if (target.ID === -1) {
						/* r += "@@.lime;You have gotten pregnant.@@"; */
					} else {
						r += `<span class="lime">${He} has become pregnant.</span>`;
					}
				} else {
					target.pregKnown = 1;
				}

			} else if (hole === 2) {

				if (target.pregWeek <= 0) {
					target.preg = 1;
					target.pregSource = (!fatherID ? 0 : fatherID);
					if (target.ID !== -1) {
						target.pregWeek = 1;
					}
				}

				target.pregType = setPregType(target);
				WombImpregnate(target, target.pregType, target.pregSource, 1);

				if (V.menstruation === 1) {
				}
				else if (!displayOverride) {
					target.pregKnown = 1;
					if (target.ID === -1) {
						/* r += "@@.lime;You have gotten pregnant.@@"; */
					} else {
						r += `<span class="lime">${He} has become pregnant.</span>`;
					}
					if (target.geneticQuirks.superfetation === 2 && target.womb.length > 0) {
						if (V.seeHyperPreg === 1) {
							target.fertPeak = 1;
						} else {
							target.fertPeak = 4;
						}
					}
				} else {
					target.pregKnown = 1;
					if (target.geneticQuirks.superfetation === 2 && target.womb.length > 0) {
						if (V.seeHyperPreg === 1) {
							target.fertPeak = 1;
						} else {
							target.fertPeak = 4;
						}
					}
				}
			}
		}
	}
	return r;
};

window.getIncubatorReserved = function(/*slaves*/) {

	return FetusGlobalReserveCount("incubator");
};

window.getNurseryReserved = function (/*slaves*/) {

	return FetusGlobalReserveCount("nursery");
};

window.findFather = function(fatherID) {
	let father;
	let V = State.variables;

	father = V.slaves[V.slaveIndices[fatherID]];
	if (father === undefined) {
		if (V.incubator > 0) {
			father = V.tanks.find(function(s) { return s.ID === fatherID; });
		}
	}
	if (father === undefined) {
		if (V.nursery > 0) {
			father = V.cribs.find(function(s) { return s.ID === fatherID; });
		}
	}

	return father;
};

window.adjustFatherProperty = function(actor, property, newValue) {
	let father = findFather(actor.ID);
	if (father)
		father[property] = newValue;
};

/* OLD
window.adjustFatherProperty = function(actor, property, newValue) {
	let V = State.variables;
	let fatherIndex;

	fatherIndex = V.slaves.findIndex(function(s) { return s.ID === actor.ID; });
	if (fatherIndex > 0) {
		V.slaves[fatherIndex][property] = newValue;
	} else if (V.incubator > 0) {
		fatherIndex = V.tanks.findIndex(function(s) { return s.ID === actor.ID; });
		if (fatherIndex > 0) {
			V.tanks[fatherIndex][property] = newValue;
		}
	}
	if (fatherIndex === -1) {
		if (V.nursery > 0) {
			fatherIndex = V.cribs.findIndex(function(s) { return s.ID === actor.ID; });
			if (fatherIndex !== -1) {
				V.cribs[fatherIndex][property] = newValue;
			}
		}
	}
}
*/

/* not to be used until that last part is defined. It may become slave.boobWomb.volume or some shit */
/** @param {App.Entity.SlaveState} slave */
window.getBaseBoobs = function(slave) {
	return slave.boobs-slave.boobsImplant-slave.boobsMilk-slave.boobsWombVolume;
};


code:
/* eslint-disable no-undef */
window.sortDomObjects = function (objects, attrName, reverse = 0) {
	reverse = (reverse) ? -1 : 1;
	function sortingByAttr (a, b) {
		var aVal = a.getAttribute(attrName);
		var bVal = b.getAttribute(attrName);
		var aInt = parseInt(aVal);
		if (!isNaN(aInt))
			return ((parseInt(bVal) - aInt) * reverse);
		else if (bVal > aVal)
			return -1 * reverse;
		return ((aVal === bVal) ? 0 : 1) * reverse;
	}
	return objects.toArray().sort(sortingByAttr);
};

window.sortButtonsByDevotion = function () {
	var $sortedButtons = $('#qlWrapper button').remove();
	$sortedButtons = sortDomObjects($sortedButtons, 'data-devotion');
	$($sortedButtons).appendTo($('#qlWrapper'));
	quickListBuildLinks();
};

window.sortButtonsByTrust = function () {
	var $sortedButtons = $('#qlWrapper button').remove();
	$sortedButtons = sortDomObjects($sortedButtons, 'data-trust');
	$($sortedButtons).appendTo($('#qlWrapper'));
	quickListBuildLinks();
};

window.quickListBuildLinks = function () {
	$("[data-scroll-to]").click(function() {
		var $this = $(this), $toElement = $this.attr('data-scroll-to');
		// note the * 1 enforces $offset to be an integer, without
		// it we scroll to True, which goes nowhere fast.
		var $offset = $this.attr('data-scroll-offset') * 1 || 0;
		var $speed = $this.attr('data-scroll-speed') * 1 || 500;
		// Use javascript scrollTop animation for in page navigation.
		$('html, body').animate({
			scrollTop: $($toElement).offset().top + $offset
		}, $speed);
	});
};

window.sortIncubatorPossiblesByName = function () {
	var $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-name');
	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
};

window.sortIncubatorPossiblesByPregnancyWeek = function () {
	var $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-preg-week');
	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
};

window.sortIncubatorPossiblesByPregnancyCount = function () {
	var $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-preg-count');
	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
};

window.sortIncubatorPossiblesByReservedSpots = function () {
	var $sortedIncubatorPossibles = $('#qlIncubator div.possible').detach();
	$sortedIncubatorPossibles = sortDomObjects($sortedIncubatorPossibles, 'data-reserved-spots');
	$($sortedIncubatorPossibles).appendTo($('#qlIncubator'));
};

window.sortIncubatorPossiblesByPreviousSort = function () {
	var sort = State.variables.sortIncubatorList;
	if ('unsorted' !== sort) {
		if ('Name' === sort) {
			sortIncubatorPossiblesByName();
		} else if ('Reserved Incubator Spots' === sort) {
			sortIncubatorPossiblesByReservedSpots();
		} else if ('Pregnancy Week' === sort) {
			sortIncubatorPossiblesByPregnancyWeek();
		} else if ('Number of Children' === sort) {
			sortIncubatorPossiblesByPregnancyCount();
		}
	}
};

window.sortNurseryPossiblesByName = function () {
	var $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-name');
	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
};

window.sortNurseryPossiblesByPregnancyWeek = function () {
	var $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-preg-week');
	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
};

window.sortNurseryPossiblesByPregnancyCount = function () {
	var $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-preg-count');
	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
};

window.sortNurseryPossiblesByReservedSpots = function () {
	var $sortedNurseryPossibles = $('#qlNursery div.possible').detach();
	$sortedNurseryPossibles = sortDomObjects($sortedNurseryPossibles, 'data-reserved-spots');
	$($sortedNurseryPossibles).appendTo($('#qlNursery'));
};

window.sortNurseryPossiblesByPreviousSort = function () {
	var sort = State.variables.sortNurseryList;
	if ('unsorted' !== sort) {
		if ('Name' === sort) {
			sortNurseryPossiblesByName();
		} else if ('Reserved Nursery Spots' === sort) {
			sortNurseryPossiblesByReservedSpots();
		} else if ('Pregnancy Week' === sort) {
			sortNurseryPossiblesByPregnancyWeek();
		} else if ('Number of Children' === sort) {
			sortNurseryPossiblesByPregnancyCount();
		}
	}
};


code:
/* eslint-disable no-undef */
/* This is modified radiobutton macro, for automatic checked state setup*/
/* Usage (be sure to use quotes around parameters):

	<<rbutton "$variable" "value">>
Or:
	<<rbutton "$variable" "value" "HTML_element_ID" "Text to replace with, inside html element with ID from previous parameter. <br> HTML tags allowed.">>

Group of radiobutton will be created based on variable name. Checked state will be set up if variable contain value matched with second parameter. Full form of macro call can be used to display extended description of selected value.
*/

Macro.add('rbutton', {
	handler() {
		if (this.args.length < 2) {
			const errors = [];
			if (this.args.length < 1) { errors.push('variable name'); }
			if (this.args.length < 2) { errors.push('checked value'); }
			return this.error(`no ${errors.join(' or ')} specified`);
		}

		// Ensure that the variable name argument is a string.
		if (typeof this.args[0] !== 'string') {
			return this.error('variable name argument is not a string');
		}

		const varName = this.args[0].trim();

		// Try to ensure that we receive the variable's name (incl. sigil), not its value.
		if (varName[0] !== '$' && varName[0] !== '_') {
			return this.error(`variable name "${this.args[0]}" is missing its sigil ($ or _)`);
		}

		const initValue = Wikifier.getValue(this.args[0]);
		const varId = Util.slugify(varName);
		const checkValue = this.args[1];
		const el = document.createElement('input');

		var replaceID = "";
		var replaceText = "";
		if (typeof this.args[2] === 'string') {
			replaceID = this.args[2];
		}
		if (typeof this.args[3] === 'string') {
			replaceText = this.args[3];
		}

		/*
		Setup and initialize the group counter.
		*/
		if (!TempState.hasOwnProperty(this.name)) {
			TempState[this.name] = {};
		}

		if (!TempState[this.name].hasOwnProperty(varId)) {
			TempState[this.name][varId] = 0;
		}

		/*
		Setup and append the input element to the output buffer.
		*/
		jQuery(el)
			.attr({
				id : `${this.name}-${varId}-${TempState[this.name][varId]++}`,
				name : `${this.name}-${varId}`,
				type : 'radio',
				tabindex : 0 // for accessibility
			})
			.addClass(`macro-${this.name}`)
			.on('change', function () {
				if (this.checked) {
					Wikifier.setValue(varName, checkValue);

					if (replaceID.length > 0 && replaceText.length > 0){

						var replaceEl = document.getElementById(replaceID);
						//alert (replaceEl);
						if (replaceEl !== null) {
							replaceEl.innerHTML = replaceText;
						}

					}
				}
			})
			.ready (function () {
			//alert ("DOM finished");
				if (el.checked && replaceID.length > 0 && replaceText.length > 0){

					var replaceEl = document.getElementById(replaceID);
					//alert (replaceEl);
					if (replaceEl !== null) {
						replaceEl.innerHTML = replaceText;
					}

				}
			})
			.appendTo(this.output);

		/*
		Set the story variable to the checked value and the input element to checked, if requested.
		*/
		if (initValue === checkValue) {
			el.checked = true;
			Wikifier.setValue(varName, checkValue);
		}
	}
});


code:
window.rivalryTerm = function (id) {
	if (id.rivalry === 1) {
		return `growing rival`;
	} else if (id.rivalry === 2) {
		return `rival`;
	} else {
		return `bitter rival`;
	}
};
window.relationshipTerm = function (id) {
	if (id.relationship === 1) {
		return `friend`;
	} else if (id.relationship === 2) {
		return `best friend`;
	} else if (id.relationship === 3) {
		return `friend with benefits`;
	} else if (id.relationship === 4) {
		return `lover`;
	} else {
		return `slave wife`;
	}
};
window.relationshipTermShort = function (id) {
	if (id.relationship === 1) {
		return `friend`;
	} else if (id.relationship === 2) {
		return `BFF`;
	} else if (id.relationship === 3) {
		return `FWB`;
	} else if (id.relationship === 4) {
		return `lover`;
	} else {
		return `wife`;
	}
};