code:
App.EndWeek.weather = function() {
	if (V.weatherRemaining === 0) {
		if (V.continent === "Africa") {
			V.weatherType = either(1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 6, 6);
		} else if (V.continent === "Asia") {
			V.weatherType = either(1, 2, 2, 2, 2, 3, 4, 4, 5, 6);
		} else if (V.continent === "Australia") {
			V.weatherType = either(1, 1, 1, 2, 2, 2, 3, 4, 4, 5, 6);
		} else if (V.continent === "Western Europe") {
			V.weatherType = either(1, 2, 2, 3, 4, 5, 5, 6);
		} else if (V.continent === "Central Europe") {
			V.weatherType = either(1, 2, 3, 4, 5, 5, 5, 6);
		} else if (V.continent === "Scandinavia") {
			V.weatherType = either(1, 2, 3, 4, 5, 5, 5, 5, 5, 6);
		} else if (V.continent === "Eastern Europe") {
			V.weatherType = either(1, 2, 3, 4, 4, 5, 5, 5, 6);
		} else if (V.continent === "Southern Europe") {
			V.weatherType = either(1, 1, 1, 2, 2, 3, 4, 4, 5, 6);
		} else if (V.continent === "Brazil") {
			V.weatherType = either(1, 1, 2, 3, 3, 3, 4, 4, 5, 6);
		} else if (V.continent === "Japan") {
			V.weatherType = either(1, 2, 2, 2, 3, 4, 4, 5, 6, 6);
		} else if (V.continent === "the Middle East") {
			V.weatherType = either(1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 6);
		} else if (V.continent === "North America") {
			V.weatherType = either(1, 2, 3, 3, 4, 5, 6, 6, 6);
		} else if (V.continent === "South America") {
			V.weatherType = either(1, 1, 2, 3, 3, 3, 4, 4, 5, 6);
		} else if (V.terrain === "oceanic") {
			V.weatherType = either(1, 2, 2, 2, 2, 2, 3, 4, 5, 6);
		}
		V.weatherRemaining = random(3, 6);
	}

	if (V.weatherLastWeek === 0) {
		V.weatherLastWeek = 1;
	}

	const seed = random(1, 10);
	if (V.weatherType === 1) {
		if (V.week < 25) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 1) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 2) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 3) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 1) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 2) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 3) {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 3) {
			if (seed > 5) {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 1) {
			if (seed > 8) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 2) {
			if (seed > 7) {
				V.weatherToday = App.Data.Weather.hotNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 5) {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 3) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.hotLight.random();
				V.weatherLastWeek = 2;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.hotExtreme.random();
				V.weatherLastWeek = 4;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 4) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.hotHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.hotExtreme.random();
				V.weatherLastWeek = 4;
			}
		}
	} else if (V.weatherType === 2) {
		if (V.week < 25) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 1) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 2) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 3) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 1) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 2) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 3) {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 3) {
			if (seed > 5) {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 1) {
			if (seed > 8) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 2) {
			if (seed > 7) {
				V.weatherToday = App.Data.Weather.windyNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 5) {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 3) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.windyLight.random();
				V.weatherLastWeek = 2;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.windyExtreme.random();
				V.weatherLastWeek = 4;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 4) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.windyHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.windyExtreme.random();
				V.weatherLastWeek = 4;
			}
		}
	} else if (V.weatherType === 3) {
		if (V.week < 25) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 1) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 2) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 3) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 1) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 2) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 3) {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 3) {
			if (seed > 5) {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 1) {
			if (seed > 8) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 2) {
			if (seed > 7) {
				V.weatherToday = App.Data.Weather.smokyNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 5) {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 3) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.smokyLight.random();
				V.weatherLastWeek = 2;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.smokyExtreme.random();
				V.weatherLastWeek = 4;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 4) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.smokyHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.smokyExtreme.random();
				V.weatherLastWeek = 4;
			}
		}
	} else if (V.weatherType === 4) {
		if (V.week < 25) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 1) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 2) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 3) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 1) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 2) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 3) {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 3) {
			if (seed > 5) {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 1) {
			if (seed > 8) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 2) {
			if (seed > 7) {
				V.weatherToday = App.Data.Weather.toxicNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 5) {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 3) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.toxicLight.random();
				V.weatherLastWeek = 2;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.toxicExtreme.random();
				V.weatherLastWeek = 4;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 4) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.toxicHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.toxicExtreme.random();
				V.weatherLastWeek = 4;
			}
		}
	} else if (V.weatherType === 5) {
		if (V.week < 25) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 1) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 2) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 3) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 1) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 2) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 3) {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 3) {
			if (seed > 5) {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 1) {
			if (seed > 8) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 2) {
			if (seed > 7) {
				V.weatherToday = App.Data.Weather.coldNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 5) {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 3) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.coldLight.random();
				V.weatherLastWeek = 2;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.coldExtreme.random();
				V.weatherLastWeek = 4;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 4) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.coldHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.coldExtreme.random();
				V.weatherLastWeek = 4;
			}
		}
	} else if (V.weatherType === 6) {
		if (V.week < 25) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 1) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 2) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 50 && V.weatherLastWeek === 3) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 1) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 2) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 3) {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week < 75 && V.weatherLastWeek === 3) {
			if (seed > 5) {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 1) {
			if (seed > 8) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 2) {
			if (seed > 7) {
				V.weatherToday = App.Data.Weather.tectonicNice.random();
				V.weatherLastWeek = 1;
			} else if (seed > 5) {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			} else {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 3) {
			if (seed > 6) {
				V.weatherToday = App.Data.Weather.tectonicLight.random();
				V.weatherLastWeek = 2;
			} else if (seed > 2) {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.tectonicExtreme.random();
				V.weatherLastWeek = 4;
			}
		} else if (V.week > 75 && V.weatherLastWeek === 4) {
			if (seed > 4) {
				V.weatherToday = App.Data.Weather.tectonicHeavy.random();
				V.weatherLastWeek = 3;
			} else {
				V.weatherToday = App.Data.Weather.tectonicExtreme.random();
				V.weatherLastWeek = 4;
			}
		}
	}
};


code:
/**
 * @returns {DocumentFragment}
 */
App.EndWeek.arcadeReport = function() {
	const el = new DocumentFragment();
	let r;

	const arcadeStats = document.createElement("span");
	el.append(arcadeStats);

	const slaves = App.Utils.sortedEmployees(App.Entity.facilities.arcade);
	const slavesLength = slaves.length;

	const cockMilkedSlaves = [];
	const milkedSlaves = [];
	const boobsImplantedSlaves = [];
	const prostatesImplantedSlaves = [];
	let vasectomiesUndone = 0;
	let milkProfits = 0;
	let profits = 0;

	// Statistics gathering
	V.facility = V.facility || {};
	V.facility.arcade = initFacilityStatistics(V.facility.arcade);
	const arcadeNameCaps = capFirstChar(V.arcadeName);

	if (slavesLength > 1) {
		App.UI.DOM.appendNewElement("p", el, `There are ${slavesLength} inmates confined in ${V.arcadeName}.`, ["bold", "indent"]);
	} else {
		App.UI.DOM.appendNewElement("p", el, `There is one inmate confined in ${V.arcadeName}.`, ["bold", "indent"]);
	}
	r = [];
	if (V.arcologies[0].FSDegradationist > 20) {
		if (V.arcologies[0].FSDegradationistLaw === 1) {
			r.push(`The tenants located near the arcade consider the facility a normal part of their surroundings, including the crowd of menial slaves waiting their turn spills out into the hallway, 24 hours a day.`);
		} else {
			r.push(`The tenants located near the arcade consider the facility a normal part of their surroundings.`);
		}
	} else if (V.arcologies[0].FSPaternalist > 20) {
		r.push(`The tenants located near the arcade consider it an <span class="red">intolerable</span> establishment.`);
	}
	App.Events.addNode(el, r, "div", "indent");
	if (V.arcadeDecoration !== "standard") {
		App.Events.addNode(el, [`${arcadeNameCaps}'s customers enjoy <span class="green">getting off in ${V.arcadeDecoration} surroundings.</span>`], "p", "indent");
	}

	for (const slave of App.SlaveAssignment.reportSlaves(slaves)) {
		r = [];
		/* for the included passages */

		/* Perform facility based rule changes */
		slave.clothes = "no clothing";
		/* Health */
		if (V.arcadeUpgradeHealth === 2 && slave.health.condition < 40) {
			improveCondition(slave, 2);
		} else if (slave.health.condition > 20) {
			healthDamage(slave, 5);
		} else if (V.arcadeUpgradeHealth === 1 && slave.health.condition < -30) {
			improveCondition(slave, 2);
		} else if (slave.health.condition > -50) {
			healthDamage(slave, 3);
		} else if (slave.health.condition > -90) {
			healthDamage(slave, 1);
		}
		/* Curatives */
		if (V.arcadeUpgradeHealth === 2) {
			slave.curatives = 2;
		} else if (V.arcadeUpgradeHealth === 1) {
			slave.curatives = 1;
		}
		/* Stimulation or lack thereof trust/devotion effect */
		if (V.arcadeUpgradeInjectors > 0) {
			if (V.arcadeUpgradeInjectors === 2) {
				slave.aphrodisiacs = 2;
			}
			slave.devotion -= 5;
			slave.trust -= 10;
		} else {
			slave.trust -= 5;
		}
		/* Muscles */
		if (slave.muscles > -100) {
			slave.muscles--;
		}
		const oldCash = V.cash;
		if (V.showEWD !== 0) {
			const {He} = getPronouns(slave);
			const slaveEntry = App.UI.DOM.appendNewElement("div", el, '', "slave-report");
			const artSpan = App.UI.DOM.appendNewElement("span", slaveEntry);
			App.SlaveAssignment.appendSlaveLinks(slaveEntry, slave);
			r = [];
			r.push(App.UI.DOM.makeElement("span", SlaveFullName(slave), "slave-name"));
			if (slave.choosesOwnAssignment === 2) {
				r.push(App.SlaveAssignment.choosesOwnJob(slave));
			} else {
				r.push(`is confined in ${V.arcadeName}.`);
			}
			App.Events.addNode(slaveEntry, r);

			App.Events.addNode(
				slaveEntry,
				[
					He,
					App.SlaveAssignment.workAGloryHole(slave),
				],
				"div",
				"indent"
			);
			App.SlaveAssignment.appendSlaveArt(artSpan, slave);
		} else {
			// discard return values silently
			App.SlaveAssignment.choosesOwnJob(slave);
			App.SlaveAssignment.workAGloryHole(slave);
		}
		profits += V.cash - oldCash;

		if (V.arcadeUpgradeCollectors > 0) {
			applyCollectors(slave);
		}
		if (slave.inflation > 0) {
			deflate(slave);
		}
		if (V.showEWD !== 0) {
			el.append(App.SlaveAssignment.standardSlaveReport(slave, false));
		} else {
			App.SlaveAssignment.standardSlaveReport(slave, true);
		}
	}

	if (slavesLength + V.fuckdolls > 0) {
		r = [];
		if (milkedSlaves.length > 0) {
			if (milkedSlaves.length === 1) {
				const {his} = getPronouns(milkedSlaves[0]);
				r.push(`One of them is lactating and spends ${his} time in ${V.arcadeName} being simultaneously milked and fucked.`);
			} else {
				r.push(`${capFirstChar(num(milkedSlaves.length))} of them are lactating and spend their time in ${V.arcadeName} being simultaneously milked and fucked.`);
			}
		}

		if (vasectomiesUndone > 0) {
			if (vasectomiesUndone === 1) {
				r.push(`One`);
			} else {
				r.push(capFirstChar(num(vasectomiesUndone)));
			}
			r.push(`of them had severed vas deferens, so they were reattached to allow sperm through, costing <span class="red">${cashFormat(V.surgeryCost * vasectomiesUndone)}.</span>`);
		}

		if (boobsImplantedSlaves.length > 0) {
			if (boobsImplantedSlaves.length === 1) {
				const {he} = getPronouns(boobsImplantedSlaves[0]);
				r.push(`One of them was not lactating, so ${he} was`);
			} else {
				r.push(`${capFirstChar(num(boobsImplantedSlaves.length))} of them were not lactating, so they were`);
			}
			r.push(`implanted with long-acting lactation inducing drugs, costing <span class="red">${cashFormat(V.surgeryCost * boobsImplantedSlaves.length)}.</span>`);
		}

		if (prostatesImplantedSlaves.length > 0) {
			if (prostatesImplantedSlaves.length === 1) {
				const {he} = getPronouns(prostatesImplantedSlaves[0]);
				r.push(`One of them was not producing the maximum possible amount of precum, so ${he} was`);
			} else {
				r.push(`${capFirstChar(num(prostatesImplantedSlaves.length))} of them were not producing the maximum possible amount of precum, so they were`);
			}
			r.push(`implanted with long-acting prostate stimulation drugs, costing <span class="red">${cashFormat(V.surgeryCost * prostatesImplantedSlaves.length)}.</span>`);
		}

		if (cockMilkedSlaves.length > 0) {
			if (cockMilkedSlaves.length === 1) {
				const {he} = getPronouns(cockMilkedSlaves[0]);
				r.push(`One of them retains testicles and is brutally cockmilked as ${he} is used.`);
			} else {
				r.push(`${capFirstChar(num(cockMilkedSlaves.length))} of them retain testicles and are brutally cockmilked as they are used.`);
			}
		}

		r.push(`The arcade makes you`);
		if (V.policies.publicFuckdolls === 0) {
			r.push(`<span class="yellowgreen">${cashFormat(profits)}</span> from selling the inmates' holes`);
		} else {
			r.push(`<span class="green">more reputable</span> from freely providing the inmates' holes`);
		}
		if (V.arcadeUpgradeCollectors > 0 && V.policies.publicFuckdolls === 0) {
			r.push(`and`);
		}
		if (V.arcadeUpgradeCollectors > 0) {
			r.push(`<span class="yellowgreen">${cashFormat(milkProfits)}</span> from selling the fluids they produced`);
		}
		r.push(`this week.`);
		if (V.arcologies[0].FSPaternalist > 20) {
			repX(forceNeg(Math.trunc(profits / 20)), "arcade");
		}
		App.Events.addNode(el, r, "div", "indent");
	}

	if (V.arcadeUpgradeFuckdolls > 1) {
		const fuckdolls = slaves.filter(s => fuckdollQualifier(s));
		if (fuckdolls.length > 0) {
			// ascending sort by sexAmount...least popular slaves are converted first
			fuckdolls.sort((a, b) => b.sexAmount - a.sexAmount);
			for (const fuckdoll of fuckdolls) {
				const {he} = getPronouns(fuckdoll);
				App.UI.DOM.appendNewElement("div", el, `${fuckdoll.slaveName} is low-quality merchandise, so ${he} has been converted into a Fuckdoll.`, "indent");
				removeSlave(fuckdoll);
				V.fuckdolls++;
				if (V.arcadeUpgradeFuckdolls === 2) {
					break; // convert at most one per week on this setting
				}
			}
		} else {
			App.UI.DOM.appendNewElement("div", el, `No slaves have failed quality inspection for Fuckdoll conversion. ${arcadeNameCaps} will remain overcrowded this week.`, "indent");
		}
	}

	if (slavesLength > 0) {
		// Record statistics gathering
		let b = V.facility.arcade;
		b.whoreIncome = 0;
		b.customers = 0;
		b.whoreCosts = 0;
		b.rep = 0;
		for (let si of b.income.values()) {
			b.whoreIncome += si.income;
			b.customers += si.customers;
			b.whoreCosts += si.cost;
			b.rep += si.rep;
		}
		b.maintenance = V.arcade * V.facilityCost * (0.05 + 0.02 * V.arcadeUpgradeInjectors + 0.05 * V.arcadeUpgradeCollectors);
		b.totalIncome = b.whoreIncome;
		b.totalExpenses = b.whoreCosts + b.maintenance;
		b.profit = b.totalIncome - b.totalExpenses;

		// Arcade stats
		el.append(App.Facilities.Arcade.Stats(false));
		arcadeStats.append(App.Facilities.Arcade.Stats(true));
	}
	return el;

	/**
	 *
	 * @param {App.Entity.SlaveState} slave
	 */
	function fuckdollQualifier(slave) {
		if (slave.sentence === 0 && slave.fuckdoll === 0 && slave.fetish === "mindbroken") {
			if (slave.physicalAge > 35) {
				return true;
			} else if (slave.vagina >= 4 || slave.anus >= 4) {
				return true;
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 */
	function applyCollectors(slave) {
		if (slave.vasectomy === 1) {
			slave.vasectomy = 0;
			vasectomiesUndone++;
			cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
			surgeryDamage(slave, 10);
		} else if (slave.lactation < 2) {
			slave.lactation = 2;
			boobsImplantedSlaves.push(slave);
			cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
			surgeryDamage(slave, 10);
		} else if (slave.prostate === 1) {
			slave.prostate = 2;
			prostatesImplantedSlaves.push(slave);
			cashX(forceNeg(V.surgeryCost), "slaveSurgery", slave);
			surgeryDamage(slave, 10);
		} else if (slave.lactation > 0 || slave.balls > 0) {
			milkProfits += milk(slave);
			slave.boobs += boobGrowth(slave);
			if (
				slave.balls.isBetween(0, 10) &&
				(random(1, 100) > (40 + (10 * (slave.balls + (2 * slave.geneMods.NCS)))))
			) {
				slave.balls++;
			}
			if (
				(slave.dick > 0) &&
				(slave.dick < 10) &&
				(random(1, 100) > (40 + (10 * slave.dick + (2 * slave.geneMods.NCS))))
			) {
				slave.dick++;
			}
			if (slave.lactation > 0) {
				milkedSlaves.push(slave);
			}
			if (slave.balls > 0) {
				cockMilkedSlaves.push(slave);
			}
		}
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {number}
	 */
	function milk(slave) {
		const {He} = getPronouns(slave);
		const milkResults = App.SlaveAssignment.getMilked(slave, 1.0);
		if (V.showEWD !== 0) {
			App.Events.addNode(el, [He, milkResults.text], "div", "indent");
		}
		return milkResults.cash;
	}

	/**
	 * @param {App.Entity.SlaveState} slave
	 * @returns {number}
	 */
	function boobGrowth(slave) {
		let growth = 0;
		const gigantomastiaMod = slave.geneticQuirks.gigantomastia === 2 ? (slave.geneticQuirks.macromastia === 2 ? 3 : 2) : 1;
		if (slave.boobs < 2000) {
			growth = 100;
		} else if (slave.boobs < 5000 * gigantomastiaMod) {
			growth = 50;
		} else if (slave.boobs < 10000 * gigantomastiaMod) {
			growth = 25;
		}
		if (slave.geneMods.NCS === 1) {
			/*
			** NCS will allow some growth for Arcade milking, but not as much as the Dairy.
			*/
			growth = Math.trunc(growth / 3.5);
		}
		return growth;
	}
};

repo_name: Pecanus/fc

license: mit


code:
App.EndWeek.brothelReport = function() {
	const el = document.createElement("p");
	let r;

	const brothelStats = document.createElement("span");
	el.append(brothelStats);

	const madam = S.Madam ? App.SlaveAssignment.reportSlave(S.Madam) : undefined;
	const slaves = App.Utils.sortedEmployees(App.Entity.facilities.brothel);
	const SL = slaves.length;
	let profits = 0;

	// Statistics gathering
	V.facility = V.facility || {};
	V.facility.brothel = initFacilityStatistics(V.facility.brothel);
	const brothelNameCaps = capFirstChar(V.brothelName);

	function madamText() {
		let FLsFetish = 0;
		let r = [];
		if (V.MadamID !== 0) {
			if (S.Madam.health.condition < -80) {
				improveCondition(S.Madam, 20);
			} else if (S.Madam.health.condition < -40) {
				improveCondition(S.Madam, 15);
			} else if (S.Madam.health.condition < 0) {
				improveCondition(S.Madam, 10);
			} else if (S.Madam.health.condition < 90) {
				improveCondition(S.Madam, 7);
			}
			if (S.Madam.devotion <= 45) {
				S.Madam.devotion += 5;
			}
			if (S.Madam.trust < 45) {
				S.Madam.trust += 5;
			}
			if (S.Madam.rules.living !== "luxurious") {
				S.Madam.rules.living = "luxurious";
			}
			if (S.Madam.rules.rest !== "restrictive") {
				S.Madam.rules.rest = "restrictive";
			}
			if (S.Madam.fetishStrength <= 95) {
				if (S.Madam.fetish !== "dom") {
					if (fetishChangeChance(S.Madam) > random(0, 100)) {
						FLsFetish = 1;
						S.Madam.fetishKnown = 1;
						S.Madam.fetish = "dom";
						S.Madam.fetishStrength = 10;
					}
				} else if (S.Madam.fetishKnown === 0) {
					FLsFetish = 1;
					S.Madam.fetishKnown = 1;
				} else {
					FLsFetish = 2;
					S.Madam.fetishStrength += 4;
				}
			}
			/* Make sure we have registered living expenses as for any other slave */
			getSlaveStatisticData(S.Madam, V.facility.brothel);
			const {
				he, him, his, himself, He, His, wife
			} = getPronouns(S.Madam);

			r = [];
			r.push(`${SlaveFullName(S.Madam)} is serving as the madam.`);
			if (S.Madam.relationship === -3 && S.Madam.devotion > 50) {
				r.push(`As your loving ${wife}, ${he} does ${his} best to attract attention to your brothel.`);
			}
			if (FLsFetish === 1) {
				r.push(`${He} isn't above sampling the merchandise ${himself}; before long it's obvious to ${his} girls that ${he}`);
				r.push(App.UI.DOM.makeElement("span", `really likes fucking them.`, "fetish-gain"));
			} else if (FLsFetish === 2) {
				r.push(`${He}'s careful that all of the whores under ${his} supervision are all warmed up and ready to get fucked every morning, and ${he}`);
				r.push(App.UI.DOM.makeElement("span", `really likes fucking them.`, ["fetish", "inc"]));
			}
			const improve = App.UI.DOM.makeElement("span", "improve", ["cash", "inc"]);
			if (S.Madam.skill.whoring <= 10) {
				r.push(`Though ${S.Madam.slaveName} does ${his} best to manage the brothel, with ${his} lack of skill ${he} can do little.`);
			} else if (S.Madam.skill.whoring <= 30) {
				r.push(`${S.Madam.slaveName}'s basic skills marginally`, improve, `business at ${V.brothelName}.`);
			} else if (S.Madam.skill.whoring <= 60) {
				r.push(`${S.Madam.slaveName}'s skills`, improve, `business at ${V.brothelName}.`);
			} else if (S.Madam.skill.whoring < 100) {
				r.push(`${S.Madam.slaveName}'s skills greatly`, improve, `business at ${V.brothelName}.`);
			} else {
				r.push(`${S.Madam.slaveName}'s mastery immensely`, improve, `business at ${V.brothelName}.`);
			}
			if (S.Madam.actualAge > 35) {
				r.push(`${His} age and experience also contribute.`);
			}
			if (App.Data.Careers.Leader.madam.includes(S.Madam.career)) {
				r.push(`${He} has experience from ${his} life before ${he} was a slave that helps ${him} in the seedy business of selling other people's bodies for sex.`);
			} else if (S.Madam.skill.madam >= V.masteredXP) {
				r.push(`${He} has experience from working for you that helps ${him} in the seedy business of selling other people's bodies for sex.`);
			} else if (S.Madam.skill.madam > 120) {
				r.push(`${He} understands how to handle whores while keeping customers happy.`);
			} else if (S.Madam.skill.madam > 60) {
				r.push(`${He} understands how to read the customer and please them effectively.`);
			} else if (S.Madam.skill.madam > 20) {
				r.push(`${He} has basic knowledge of how to run a whorehouse.`);
			}
			if (S.Madam.skill.madam < V.masteredXP) {
				const skillIncrease = jsRandom(1, Math.ceil((S.Madam.intelligence + S.Madam.intelligenceImplant) / 15) + 8);
				r.push(slaveSkillIncrease('madam', S.Madam, skillIncrease));
			}
			if (S.Madam.intelligence + S.Madam.intelligenceImplant > 15) {
				r.push(`${He} is a clever manager.`);
			}
			if (S.Madam.dick > 2 && canPenetrate(S.Madam)) {
				r.push(`${His} turgid dick helps ${him} manage the bitches.`);
			}
			App.Events.addParagraph(el, r);

			r = [];
			for (const slave of slaves) {
				const {
					he2, him2, his2
				} = getPronouns(slave).appendSuffix('2');

				if (S.Madam.rivalryTarget === slave.ID) {
					r.push(`${He} forces ${his} ${rivalryTerm(S.Madam)}, ${slave.slaveName}, to service all the men in the brothel.`);
					slave.devotion -= 2;
					slave.trust -= 2;
					if (canDoVaginal(slave)) {
						seX(slave, "vaginal", "public", "penetrative", 10);
					}
					if (canDoAnal(slave)) {
						seX(slave, "anal", "public", "penetrative", 12);
					}
					seX(slave, "anal", "public", "penetrative", 10);
					if (random(1, 100) > 65) {
						S.Madam.rivalry++;
						slave.rivalry++;
					}
				} else if (S.Madam.relationshipTarget === slave.ID) {
					r.push(`${He} dotes over ${his} ${relationshipTerm(S.Madam)}, ${slave.slaveName}, making sure ${he2} is safe, but unfortunately driving potential customers away from ${him2}.`);
					slave.devotion++;
				} else if (areRelated(S.Madam, slave)) {
					r.push(`${He} pays special attention to ${his} ${relativeTerm(S.Madam, slave)}, ${slave.slaveName}, making sure ${he2} is treated well and showing off ${his2} skills.`);
					slave.trust++;
				}
				if (slave.prestigeDesc === "$He is a famed Free Cities whore, and commands top prices.") {
					r.push(`${He} makes sure to promote ${slave.slaveName}, the famed whore, in order to capitalize on ${his2} popularity.`);
				} else if (slave.prestigeDesc === "$He is a famed Free Cities slut, and can please anyone.") {
					r.push(`${He} makes sure to promote ${slave.slaveName}, the famed entertainer, in order to capitalize on ${his2} popularity.`);
				} else if (slave.prestigeDesc === "$He is remembered for winning best in show as a dairy cow.") {
					if (V.arcologies[0].FSPhysicalIdealist !== "unset") {
						if (slave.muscles > 60 && slave.weight < 30 && slave.lactation > 0 && (slave.boobs - slave.boobsImplant) > 6000) {
							r.push(`${He} shows off how even a cow like ${slave.slaveName} can achieve physical perfection.`);
						} else {
							if (slave.muscles < 30) {
								r.push(`An unmuscled,`);
							} else {
								r.push(`A`);
							}
							if (slave.weight > 30) {
								r.push(`fat,`);
							}
							r.push(`'prestigious'`);
							if (slave.lactation > 0) {
								r.push(`cow`);
							} else if ((slave.boobs - slave.boobsImplant) > 6000) {
								r.push(`mass of titflesh`);
							} else {
								r.push(`slave`);
							}
							r.push(`like ${slave.slaveName} is woefully out of fashion, so ${S.Madam.slaveName} tries to draw attention away from ${him2}.`);
						}
					} else {
						if (slave.lactation > 0 && (slave.boobs - slave.boobsImplant) > 6000) {
							r.push(`${He} makes sure to massage ${slave.slaveName}'s huge breasts to get the milk flowing before enticing clients to suckle and play with ${him2}.`);
						} else {
							r.push(`${He} would like to show off ${slave.slaveName}'s huge udders, but ${slave.slaveName}`);
							if (slave.lactation === 0) {
								r.push(`isn't producing milk anymore.`);
							} else {
								r.push(`doesn't exactly have huge udders anymore.`);
							}
						}
					}
				} else if (slave.prestigeDesc === "$He is remembered for winning best in show as a cockmilker.") {
					if (V.arcologies[0].FSGenderFundamentalist !== "unset") {
						/* this needs review - doesn't fit right. An XY slave would be expected to be masculine. */
						if (slave.balls === 0 && slave.dick === 0 && slave.vagina > -1) {
							r.push(`${He} uses ${slave.slaveName} as an example of how even a huge-balled freak like ${him2} can be restored to proper femininity.`);
						} else {
							r.push(`${He} tries to hide ${slave.slaveName}, 'her' body being notorious for its defiance of conventional femininity.`);
						}
					} else {
						if (((slave.balls > 5) && (slave.dick !== 0)) || ((slave.balls > 4) && (slave.dick !== 0) && (slave.prostate > 1))) {
							r.push(`${He} shows off ${slave.slaveName}'s copious loads by putting a condom over ${his2} dick and teasing ${him2} till ${he2} bursts it. The show draws multiple clients that want to play with ${his2} oversized junk and messy orgasms.`);
						} else {
							r.push(`${He} would love to show off ${slave.slaveName}'s copious loads, but`);
							if (slave.dick === 0) {
								r.push(`${slave.slaveName} doesn't have a dick.`);
							} else if (slave.balls === 0) {
								r.push(`${slave.slaveName}'s not producing cum.`);
							} else {
								r.push(`${slave.slaveName}'s orgasms just aren't messy enough.`);
							}
						}
					}
				} else if (slave.prestigeDesc === "$He is remembered for winning best in show as a breeder.") {
					if (slave.bellyPreg >= 5000) {
						r.push(`${He} makes sure ${slave.slaveName}'s growing pregnancy is well taken care of, even if it means driving away potential customers away when the mother-to-be needs a rest.`);
					} else if (canGetPregnant(slave)) {
						r.push(`${He} makes sure to play off ${slave.slaveName}'s fame and fertility by enticing potential customers to be the one to claim ${his2} womb by filling it with their child.`);
					} else {
						r.push(`${He} would love to play off of ${slave.slaveName}'s fame and fertility, but unfortunately ${he2}`);
						if (slave.pregKnown === 1 && slave.bellyPreg < 1500) {
							r.push(`is already pregnant and not far enough along to show it.`);
						} else if (slave.pregKnown === 1 && slave.bellyPreg < 5000) {
							r.push(`already pregnant, but not enough to be exciting.`);
						} else {
							r.push(`is unable to get knocked up.`);
						}
					}
				}
			}
			App.Events.addNode(el, r);

			if ((SL + V.brothelSlavesGettingHelp < 10) && V.MadamNoSex !== 1 && !slaveResting(madam)) {
				const oldCash = V.cash;
				if (V.showEWD !== 0) {
					App.Events.addParagraph(
						el,
						[
							He,
							App.SlaveAssignment.whore(madam)
						]
					);
				} else {
					App.SlaveAssignment.whore(madam);
				}
				App.Events.addParagraph(
					el,
					[
						`${He} whores ${himself} because ${he} doesn't have enough whores to manage to keep ${him} busy, and makes`,
						App.UI.DOM.makeElement("span", `${cashFormat(S.Madam.lastWeeksCashIncome)}.`, ["cash", "inc"]),
						`${He} can charge more for ${his} time, since many citizens find it erotic to fuck the Madam.`
					]
				);
				profits += V.cash - oldCash;
			}
		}
	}

	madamText();

	if (SL > 0) {
		const whoreNumber = document.createElement("p");
		whoreNumber.classList.add("indent", "bold");

		if (SL === 1) {
			whoreNumber.append(`There is one slave whore working out of ${V.brothelName}.`);
		} else {
			whoreNumber.append(`There are ${SL} slave whores working out of ${V.brothelName}.`);
		}
		el.append(whoreNumber);
	}

	if (madam) {
		tired(madam);
		if (V.showEWD !== 0) {
			const madamEntry = App.UI.DOM.appendNewElement("div", el, '', "slave-report");
			const artSpan = App.UI.DOM.appendNewElement("span", madamEntry);
			App.SlaveAssignment.appendSlaveLinks(madamEntry, madam);
			App.Events.addNode(
				madamEntry,
				[
					App.UI.DOM.makeElement("span", SlaveFullName(madam), "slave-name"),
					`is serving as the Madam.`
				]
			);
			madamEntry.append(App.SlaveAssignment.standardSlaveReport(madam, false));
			App.SlaveAssignment.appendSlaveArt(artSpan, madam);
		} else {
			App.SlaveAssignment.standardSlaveReport(madam, true);
		}
	}

	if (SL > 0) {
		let healthBonus = 0;
		let aphrodisiacs = 0;
		if (V.brothelUpgradeDrugs === 1) {
			healthBonus += 1;
			aphrodisiacs = 1;
		} else if (V.brothelUpgradeDrugs === 2) {
			healthBonus += 3;
			aphrodisiacs = 2;
		}
		let oldCash = V.cash;
		for (const slave of App.SlaveAssignment.reportSlaves(slaves)) {
			/* Perform facility based rule changes */
			improveCondition(slave, healthBonus);
			slave.aphrodisiacs = aphrodisiacs;
			switch (V.brothelDecoration) {
				case "Degradationist":
				case "standard":
					slave.rules.living = "spare";
					break;
				default:
					slave.rules.living = "normal";
			}
			if (slave.health.condition < -80) {
				improveCondition(slave, 20);
			} else if (slave.health.condition < -40) {
				improveCondition(slave, 15);
			} else if (slave.health.condition < 0) {
				improveCondition(slave, 10);
			} else if (slave.health.condition < 90) {
				improveCondition(slave, 7);
			}
			if (slave.devotion <= 20 && slave.trust >= -20) {
				slave.devotion -= 5;
				slave.trust -= 5;
			} else if (slave.devotion < 45) {
				slave.devotion += 4;
			} else if (slave.devotion > 50) {
				slave.devotion -= 4;
			}
			if (slave.trust < 30) {
				slave.trust += 5;
			}
			if (slave.energy.isBetween(40, 95)) {
				slave.energy++;
			}

			if (V.showEWD !== 0) {
				const {He} = getPronouns(slave);
				const slaveEntry = App.UI.DOM.appendNewElement("div", el, '', "slave-report");
				const artSpan = App.UI.DOM.appendNewElement("span", slaveEntry);
				App.SlaveAssignment.appendSlaveLinks(slaveEntry, slave);
				r = [];
				r.push(App.UI.DOM.makeElement("span", SlaveFullName(slave), "slave-name"));
				if (slave.choosesOwnAssignment === 2) {
					r.push(App.SlaveAssignment.choosesOwnJob(slave));
				} else {
					r.push(`is working out of ${V.brothelName}.`);
				}
				App.Events.addNode(slaveEntry, r);

				App.Events.addNode(
					slaveEntry,
					[
						He,
						App.SlaveAssignment.whore(slave),
					],
					"div",
					"indent"
				);
				slaveEntry.append(App.SlaveAssignment.standardSlaveReport(slave, false));
				App.SlaveAssignment.appendSlaveArt(artSpan, slave);
			} else {
				// discard return values silently
				App.SlaveAssignment.choosesOwnJob(slave);
				App.SlaveAssignment.whore(slave);
				App.SlaveAssignment.standardSlaveReport(slave, true);
			}

			const seed = Math.max(App.Ads.getMatchedCategoryCount(slave, "brothel"), 1);
			const adsIncome = seed * random(50, 60) * Math.trunc(V.brothelAdsSpending / 1000);
			getSlaveStatisticData(slave, V.facility.brothel).adsIncome += adsIncome;
			cashX(adsIncome, "brothelAds");
		}
		App.Events.addNode(el, [App.Ads.report("brothel", false)]);

		profits += V.cash - oldCash;

		// Record statistics gathering
		const b = V.facility.brothel;
		b.whoreIncome = 0;
		b.customers = 0;
		b.whoreCosts = 0;
		b.rep = 0;
		for (const si of b.income.values()) {
			b.whoreIncome += si.income + si.adsIncome;
			b.customers += si.customers;
			b.whoreCosts += si.cost;
			b.rep += si.rep;
		}
		b.adsCosts = V.brothelAdsSpending;
		b.maintenance = V.brothel * V.facilityCost * (1.0 + 0.2 * V.brothelUpgradeDrugs);
		b.totalIncome = b.whoreIncome + b.adsIncome;
		b.totalExpenses = b.whoreCosts + b.adsCosts + b.maintenance;
		b.profit = b.totalIncome - b.totalExpenses;

		App.Events.addNode(
			el,
			[
				`${brothelNameCaps} makes you`,
				App.UI.DOM.makeElement("span", cashFormat(profits), ["cash", "inc"]),
				`this week.`
			]
		);

		if (V.brothelDecoration !== "standard") {
			App.Events.addParagraph(
				el,
				[
					`${brothelNameCaps}'s customers enjoyed`,
					App.UI.DOM.makeElement("span", `fucking whores in ${V.brothelDecoration} surroundings.`, ["reputation", "inc"])
				]
			);
		}

		// Brothel stats
		el.append(App.Facilities.Brothel.Stats(false));
		brothelStats.append(App.Facilities.Brothel.Stats(true));
	}
	return el;
};


code:
/**
 * @returns {DocumentFragment}
 */
App.EndWeek.cellblockReport = function() {
	const el = new DocumentFragment();
	let r;

	const slaves = App.Utils.sortedEmployees(App.Entity.facilities.cellblock);
	let brokenSlaves = 0;
	let idleBonus = 0;
	let softenedQuirks = 0;
	let trustMalus = 0;
	let FLsFetish = 0;
	let devBonus = (V.cellblockDecoration !== "standard") ? 1 : 0;
	let confinedResults;

	const cellblockNameCaps = capFirstChar(V.cellblockName);
	V.flSex = App.EndWeek.getFLSex(App.Entity.facilities.cellblock);/* FIXME: should be local, passed as a parameter to saRules */

	if (S.Wardeness) {
		const {
			He, His,
			he, his, him, wife
		} = getPronouns(S.Wardeness);
		r = [];

		if (S.Wardeness.health.condition < -80) {
			improveCondition(S.Wardeness, 20);
		} else if (S.Wardeness.health.condition < -40) {
			improveCondition(S.Wardeness, 15);
		} else if (S.Wardeness.health.condition < 0) {
			improveCondition(S.Wardeness, 10);
		} else if (S.Wardeness.health.condition < 90) {
			improveCondition(S.Wardeness, 7);
		}
		if (S.Wardeness.devotion <= 60) {
			S.Wardeness.devotion += 2;
		}
		S.Wardeness.devotion += devBonus;
		if (S.Wardeness.trust < 60) {
			S.Wardeness.trust += 3;
		}
		if (S.Wardeness.rules.living !== "luxurious") {
			S.Wardeness.rules.living = "luxurious";
		}
		if (S.Wardeness.rules.rest !== "restrictive") {
			S.Wardeness.rules.rest = "restrictive";
		}
		if (S.Wardeness.fetishStrength <= 95) {
			if (S.Wardeness.fetish !== "sadist") {
				if (fetishChangeChance(S.Wardeness) > random(0, 100)) {
					FLsFetish = 1;
					S.Wardeness.fetishKnown = 1;
					S.Wardeness.fetish = "sadist";
					S.Wardeness.fetishStrength = 10;
				}
			} else if (S.Wardeness.fetishKnown === 0) {
				FLsFetish = 1;
				S.Wardeness.fetishKnown = 1;
			} else {
				FLsFetish = 2;
				S.Wardeness.fetishStrength += 4;
			}
		}
		if (S.Wardeness.energy > 95 || S.Wardeness.fetish === "sadist") {
			devBonus++;
			trustMalus++;
			idleBonus++;
		}
		r.push(`${SlaveFullName(S.Wardeness)} is serving as the Wardeness.`);
		if (S.Wardeness.relationship === -3 && S.Wardeness.devotion > 50) {
			devBonus++;
			trustMalus++;
			idleBonus++;
			r.push(`As your ${wife}, ${he} tries ${his} best to break the disobedient slaves to your will.`);
		}
		if (FLsFetish === 1) {
			r.push(`One day ${he} demands obedience. The next day ${he} strikes a slave when it isn't given. The next, ${he} seems more excited than embarrassed when beating a prisoner. Soon, ${he}'s looking for an excuse to punish. ${He}'s become more of a sadist.`);
		} else if (FLsFetish === 2) {
			r.push(`Being not only allowed but encouraged to get off while punishing prisoners <span class="lightsalmon">deepens ${his} sadism.</span>`);
		}
		if (App.Data.Careers.Leader.wardeness.includes(S.Wardeness.career)) {
			devBonus++;
			trustMalus++;
			idleBonus++;
			r.push(`${He} has experience with detecting security issues and grinding down potential miscreants from ${his} life before ${he} was a slave, making ${him} more effective.`);
		} else if (S.Wardeness.skill.wardeness >= V.masteredXP) {
			devBonus++;
			trustMalus++;
			idleBonus++;
			r.push(`${He} has experience with detecting security issues and grinding down potential miscreants from working for you, making ${him} more effective.`);
		} else {
			const skillIncrease = random(1, Math.ceil((S.Wardeness.intelligence + S.Wardeness.intelligenceImplant) / 15) + 8);
			r.push(slaveSkillIncrease('wardeness', S.Wardeness, skillIncrease));
		}
		if (S.Wardeness.fetish === "sadist") {
			r.push(`${He} uses the prisoners to gratify ${his} sadism, terrifying them and quickly breaking their resistance.`);
		} else if (S.Wardeness.energy > 95) {
			r.push(`${He} is so sexually depraved that ${he} constantly molests the prisoners, breaking them to a life of servitude.`);
		}
		if (S.Wardeness.sexualFlaw === "malicious" || S.Wardeness.sexualFlaw === "abusive") {
			devBonus++;
			trustMalus += 2;
			idleBonus += 2;
			r.push(`Sexual abuse of prisoners has become an end for ${him}, not a means. ${He} inspires ${his} prisoners to do everything possible to qualify to get away from ${him}, even as ${he} slowly grinds away their interest in sex to do it.`);
		} else if (S.Wardeness.sexualQuirk === "caring") {
			devBonus--;
			trustMalus--;
			idleBonus--;
			r.push(`${His} kindness sometimes shows through ${his} tough façade, letting prisoners get off easier than they should.`);
		}
		if (S.Wardeness.dick > 2 && canPenetrate(S.Wardeness)) {
			devBonus++;
			trustMalus++;
			idleBonus++;
			r.push(`${His} molestation of the prisoners is more varied and effective because ${he} has a dick to fuck them with.`);
		}
		if (S.Wardeness.muscles > 35) {
			devBonus++;
			trustMalus++;
			idleBonus++;
			r.push(`${He} is strong enough to restrain anyone that tries anything with ${his} own hands.`);
		}
		if (S.Wardeness.devotion > 95) {
			devBonus++;
			trustMalus++;
			idleBonus++;
			r.push(`${His} devotion to you is so absolute that ${he} sees breaking bitches for your service as a noble calling.`);
		}
		App.Events.addNode(el, r, "div", "indent");
		for (const slave of slaves) {
			r = [];
			if (S.Wardeness.rivalryTarget === slave.ID) {
				r.push(`${He} greatly enjoys breaking ${his} ${rivalryTerm(S.Wardeness)}, ${slave.slaveName}'s will.`);
				slave.devotion++;
				slave.trust -= 3;
				if (random(1, 100) > 30) {
					S.Wardeness.rivalry++;
					slave.rivalry++;
				}
			} else if (S.Wardeness.relationshipTarget === slave.ID) {
				r.push(`${He} hates having to break ${his} ${relationshipTerm(S.Wardeness)}, ${slave.slaveName}, but ${his} devotion to you wins out in the end.`);
				slave.devotion++;
				slave.trust -= 3;
				if (random(1, 100) >= 50) {
					r.push(`${His} and ${slave.slaveName}'s relationship has been shattered by these events.`);
					S.Wardeness.relationship = 0;
					S.Wardeness.relationshipTarget = 0;
					slave.relationship = 0;
					slave.relationshipTarget = 0;
				}
			} else if (areRelated(S.Wardeness, slave)) {
				const {he2, his2} = getPronouns(slave).appendSuffix("2");
				r.push(`${He} shows ${his} ${relativeTerm(S.Wardeness, slave)} ${slave.slaveName} no mercy, making sure ${he2} understands ${his2} place.`);
				slave.devotion++;
				slave.trust--;
			}
			App.Events.addNode(el, r, "div", "indent");
		}
		if (slaves.length < V.cellblock && !slaveResting(S.Wardeness)) {
			const seed = random(1, 10) + ((V.cellblock - slaves.length) * (random(150, 170) + (idleBonus * 10)));
			cashX(seed, "cellblock", S.Wardeness);
			App.Events.addNode(el, [`Since ${he} doesn't have enough prisoners to manage to keep ${him} busy, ${he} works on citizens' slaves, earning <span class="yellowgreen"> ${cashFormat(seed)}.</span>`], "div", "indent");
		}
	}

	if (slaves.length > 0) {
		if (slaves.length === 1) {
			App.UI.DOM.appendNewElement("div", el, `One slave is being confined in ${V.cellblockName} until they are willing to obey.`, "indent");
		} else {
			App.UI.DOM.appendNewElement("div", el, `${slaves.length} slaves are being confined in ${V.cellblockName} until they are willing to obey.`, "indent");
		}
	}

	if (S.Wardeness) {
		const slave = App.SlaveAssignment.reportSlave(S.Wardeness);
		tired(slave);
		/* apply following SA passages to facility leader */
		if (V.showEWD !== 0) {
			const wardenessEntry = App.UI.DOM.appendNewElement("div", el, '', "slave-report");
			const artSpan = App.UI.DOM.appendNewElement("span", wardenessEntry);
			App.SlaveAssignment.appendSlaveLinks(wardenessEntry, slave);
			App.Events.addNode(
				wardenessEntry,
				[
					App.UI.DOM.makeElement("span", SlaveFullName(slave), "slave-name"),
					`is serving as the Wardeness in ${V.cellblockName}.`,
				]
			);
			wardenessEntry.append(App.SlaveAssignment.standardSlaveReport(slave, false));
			App.SlaveAssignment.appendSlaveArt(artSpan, slave);
		} else {
			App.SlaveAssignment.standardSlaveReport(slave, true);
		}
	}

	for (const slave of App.SlaveAssignment.reportSlaves(slaves)) {
		const {He} = getPronouns(slave);
		if (slave.devotion <= 20) {
			if (slave.trust >= -20) {
				if (
					(slave.hears === -1 && slave.earwear !== "hearing aids") ||
					(slave.hears === 0 && slave.earwear === "muffling ear plugs") ||
					(slave.hears === -2)
				) {
					slave.devotion -= 2;
					slave.trust -= 2;
				} else {
					slave.devotion -= 4;
					slave.trust -= 4;
				}
			} else {
				slave.devotion++;
			}
		}
		switch (V.cellblockDecoration) {
			case "Paternalist":
				slave.rules.living = "normal";
				if (slave.inflation > 0) {
					deflate(slave);
				}
				break;
			case "Pastoralist":
				slave.rules.living = "spare";
				if (slave.inflation === 0) {
					if (slave.pregKnown === 0 && slave.bellyImplant < 1500) {
						slave.inflation = 2;
						slave.inflationType = "milk";
						slave.inflationMethod = 1;
					} else {
						slave.inflation = 1;
						slave.inflationType = "milk";
						slave.inflationMethod = 1;
					}
					SetBellySize(slave);
				}
				break;
			case "Hedonistic":
				slave.rules.living = "spare";
				if (slave.weight < 200) {
					if (slave.weightDirection === 1) {
						slave.weight += 5;
					} else if (slave.weightDirection === -1) {
						slave.weight += 1;
					} else {
						slave.weight += 3;
					}
				}
				if (slave.muscles > -100) {
					slave.muscles -= 2;
				}
				if (slave.inflation === 0) {
					if (slave.pregKnown === 0 && slave.bellyImplant < 1500) {
						slave.inflation = 3;
						slave.inflationType = "food";
						slave.inflationMethod = 1;
					} else {
						slave.inflation = 1;
						slave.inflationType = "food";
						slave.inflationMethod = 1;
					}
					SetBellySize(slave);
				}
				break;
			default:
				slave.rules.living = "spare";
				if (slave.inflation > 0) {
					deflate(slave);
				}
		}
		if (V.cellblockUpgrade === 1) {
			if (slave.behavioralFlaw !== "none" && slave.behavioralQuirk === "none") {
				SoftenBehavioralFlaw(slave);
				slave.devotion -= 10;
				softenedQuirks++;
			} else if (slave.sexualFlaw !== "none" && slave.sexualQuirk === "none") {
				SoftenSexualFlaw(slave);
				slave.devotion -= 10;
				softenedQuirks++;
			}
		}
		slave.devotion += devBonus;
		slave.trust -= trustMalus;
		if (S.Wardeness && S.Wardeness.sexualFlaw === "malicious" && slave.energy >= 2) {
			slave.energy -= 2;
		}
		if (slave.health.condition < -80) {
			improveCondition(slave, 20);
		} else if (slave.health.condition < -40) {
			improveCondition(slave, 15);
		} else if (slave.health.condition < 0) {
			improveCondition(slave, 10);
		} else if (slave.health.condition < 40) {
			improveCondition(slave, 7);
		} else if (slave.health.condition < 100) {
			improveCondition(slave, 3);
		}

		if (V.showEWD !== 0) {
			const slaveEntry = App.UI.DOM.appendNewElement("div", el, '', "slave-report");
			const artSpan = App.UI.DOM.appendNewElement("span", slaveEntry);
			App.SlaveAssignment.appendSlaveLinks(slaveEntry, slave);
			r = [];
			r.push(App.UI.DOM.makeElement("span", SlaveFullName(slave), "slave-name"));
			if (slave.choosesOwnAssignment === 2) {
				r.push(App.SlaveAssignment.choosesOwnJob(slave));
			} else {
				r.push(`is confined in ${V.cellblockName}.`);
			}
			App.Events.addNode(slaveEntry, r);

			confinedResults = App.SlaveAssignment.stayConfined(slave);
			App.Events.addNode(slaveEntry, [He, confinedResults.text], "div", "indent");
			if (confinedResults.broken) {
				brokenSlaves++;
				continue; // slave has been reassigned; remaining report will run at her new assignment
			}
			slaveEntry.append(App.SlaveAssignment.standardSlaveReport(slave, false));
			App.SlaveAssignment.appendSlaveArt(artSpan, slave);
		} else {
			// discard return values silently
			App.SlaveAssignment.choosesOwnJob(slave);
			confinedResults = App.SlaveAssignment.stayConfined(slave);
			if (confinedResults.broken) {
				brokenSlaves++;
				continue; // slave has been reassigned; remaining report will run at her new assignment
			}
			App.SlaveAssignment.standardSlaveReport(slave, true);
		}
	}
	if (softenedQuirks || brokenSlaves) {
		r = [];
		if (softenedQuirks > 0) {
			r.push(`${cellblockNameCaps}'s advanced compliance systems successfully softened`);
			if (softenedQuirks === 1) {
				r.push(`one slave's mental flaw into an <span class="green">appealing quirk,</span> though the constant correction caused them <span class="mediumorchid">considerable anguish.</span>`);
			} else {
				r.push(`${softenedQuirks} slaves' mental flaws into <span class="green">appealing quirks,</span> though the constant correction caused them <span class="mediumorchid">considerable anguish.</span>`);
			}
		}
		if (brokenSlaves > 0) {
			if (brokenSlaves === 1) {
				r.push(`One slave is now willing to <span class="hotpink">do as they're told</span> and has been released.`);
			} else {
				r.push(`${brokenSlaves} slaves are now willing to <span class="hotpink">do as they're told</span> and have been released.`);
			}
			if (V.cellblockDecoration !== "standard") {
				App.Events.addNode(el, r, "p", "indent");
				r = [];
				r.push(`${cellblockNameCaps}'s ${V.cellblockDecoration} atmosphere <span class="hotpink">had an impact on them while they were</span> imprisoned.`);
			}
		}
		App.Events.addNode(el, r, "p", "indent");
	}
	return el;
};


code:
/**
 * Details week-to-week changes in children in the Nursery
 * @returns {DocumentFragment}
 */
App.Facilities.Nursery.childrenReport = function childrenReport() {
	const frag = new DocumentFragment();

	const Matron = S.Matron;
	const nannies = App.Utils.sortedEmployees(App.Entity.facilities.nursery);
	const NL = App.Entity.facilities.nursery.employeesIDs().size;
	const CL = V.cribs.length;

	const medianNannyIntelligence = NL ? findMedianNannyIntelligence() : null;
	const medianNannyIntelligenceImplant = NL ? findMedianNannyIntelligenceImplant() : null;

	for (const child of V.cribs) {
		const childDiv = App.UI.DOM.appendNewElement("div", frag, '', "child-section");

		childDiv.append(childGrowTime(child));

		if (child.actualAge >= 3) {
			if (Matron) {
				if (Matron.fetish !== "none") {
					childDiv.append(matronFetishEffects(child));
				}

				childDiv.append(matronEducationEffects(child));
				// childDiv.append(matronFitnessEffects(child));
			}

			if (NL > 0) {
				const randomNanny = NL > 1 ? jsRandom(0, nannies.length - 1) : 0;
				const nanny = nannies[randomNanny];

				if (nanny.fetish !== "none") {
					childDiv.append(nannyFetishEffects(child, nanny));
				}

				childDiv.append(nannyEducationEffects(child));
				// childDiv.append(nannyFitnessEffects(child));
			}

			if (multipleChildrenOverTargetAge(V.cribs.findIndex(c => c.ID === child.ID))) {
				childDiv.append(childFriendshipRivalries(child));
			}

			// TODO: rework these entirely
			if (Matron || nannies) {
				childDiv.appendChild(weightRulesEffects(child));
				childDiv.appendChild(musclesRulesEffects(child));
			}
		} else {
			// TODO:
		}
	}

	// MARK: Matron Effects

	function matronFetishEffects(child) {
		const chance = jsRandom(1, 100);

		if ((chance > 90 && child.fetish === "none") || chance > 95) {
			child.fetish = Matron.fetish;

			return `${child.slaveName} has taken a few cues from ${Matron.slaveName}, and ${newChildFetish(child.fetish)}. `;
		}
	}

	function matronEducationEffects(child) {
		// TODO: expand this
		const {he, him, his} = getPronouns(Matron);

		const theChildren = CL > 1 ? `the children` : `${child.slaveName}`;

		if (Matron.intelligence + Matron.intelligenceImplant > 65) {
			child.intelligenceImplant += 3;

			return `${Matron.slaveName} is so intelligent and well-educated that ${he} is able to teach ${theChildren} very effectively, and so ${CL > 1 ? `they gradually grow` : `${child.slaveName} gradually grows`} smarter. `;
		} else if (Matron.intelligenceImplant > 20) {
			child.intelligenceImplant += 2;

			return `${Matron.slaveName}'s education makes up for the fact that ${he} isn't the brightest and allows ${him} to teach ${theChildren} quite effectively, and so ${CL > 1 ? `they grow` : `${child.slaveName} grows`} a bit smarter. `;
		} else if (Matron.intelligence > 50) {
			child.intelligenceImplant += 2;

			return `Though ${Matron.slaveName} has had little to no formal education, ${his} natural brilliance allows ${him} to teach ${theChildren} quite effectively, and so ${CL > 1 ? `they grow` : `${child.slaveName} grows`} a bit smarter. `;
		} else {
			const totalSpan = App.UI.DOM.makeElement("span", `${Matron.slaveName} isn't the brightest and not well educated, `);
			const damageSpan = App.UI.DOM.makeElement("span", `damaging the amount of real education ${theChildren} receive. `, "red");

			child.intelligenceImplant--;

			totalSpan.appendChild(damageSpan);

			return totalSpan;
		}
	}

	// function matronFitnessEffects(child) {
	// 	// TODO:
	// 	return;
	// }

	// MARK: Nanny Effects

	function nannyFetishEffects(child, slave) {
		const {he} = getPronouns(child);
		const chance = jsRandom(1, 100);

		if (chance > 85) {
			if (child.fetish === "none") {
				child.fetish = slave.fetish;

				return `${slave.slaveName} has left quite an impression on ${child.slaveName}, and ${he} ${newChildFetish(child.fetish)}. `;
			} else {
				if (chance > 90) {
					child.fetish = slave.fetish;

					return `${child.slaveName} seems to have taken to ${slave.slaveName}'s example, and ${newChildFetish(child.fetish)}. `;
				}
			}
		}
	}

	function nannyEducationEffects(child) {
		// TODO: redo this entire section
		// TODO: expand this
		const firstNanny = nannies[0];
		const theNanniesAre = NL > 1 ? `The nannies are mostly` : `${firstNanny.slaveName} is`;
		const theChildren = CL > 1 ? `the children` : child.slaveName;

		if (medianNannyIntelligence + medianNannyIntelligenceImplant > 65) {
			child.intelligenceImplant += 3;

			return `${theNanniesAre} very intelligent and well educated and are able to teach ${theChildren} very effectively. `;
		} else if (medianNannyIntelligence > 50) {
			child.intelligenceImplant += 2;

			return `${theNanniesAre} very intelligent and able to teach ${theChildren} quite effectively. `;
		} else if (medianNannyIntelligenceImplant > 25) {
			child.intelligenceImplant += 2;

			return `${theNanniesAre} very well educated and able to teach ${theChildren} quite effectively. `;
		} else if (medianNannyIntelligenceImplant > 15) {
			child.intelligenceImplant++;

			return `${theNanniesAre} well educated and able to teach ${theChildren} fairly effectively. `;
		}
	}

	// function nannyFitnessEffects(child) {
	// 	// TODO:
	// 	return;
	// }

	// MARK: Nursery Rules Effects

	function weightRulesEffects(child) {
		// TODO: redo this entire section
		// TODO: double check these classes, make sure they make sense
		const span = document.createElement("span");
		const {he, He, His} = getPronouns(child);

		if (V.nurseryWeight) {
			const firstNanny = NL > 0 ? nannies[0] : null;
			const caretaker = Matron ? Matron.slaveName : NL > 1 ? `A nanny` : firstNanny.slaveName;

			if (V.nurseryWeightSetting === 1) {
				const weightSpan = App.UI.DOM.makeElement("span", 'rapid weight gain.', ["health", "dec"]);

				if (child.weight < 200) {
					child.weight += 5;
				}

				span.append(`${He} is being fed an excessive amount of food, causing`, weightSpan);
			} else if (V.nurseryWeightSetting === 2) {
				const weightSpan = App.UI.DOM.makeElement("span", `decreases the amount of food ${he} eats. `, "improvement");

				if (child.weight > 10) {
					child.weight--;

					span.append(`${caretaker} notices ${he} is overweight and `, weightSpan);
				} else if (child.weight <= -10) {
					const weightSpan = App.UI.DOM.makeElement("span", `increases the amount of food ${he} eats. `, "improvement");

					child.weight++;

					span.append(`${caretaker} notices ${he} is underweight and `, weightSpan);
				} else {
					const weightSpan = App.UI.DOM.makeElement("span", 'currently a healthy weight;', ["change", "positive"]);

					span.append(`${He} is `, weightSpan, ` efforts will be made to maintain it. `);
				}
			} else if (V.nurseryWeightSetting === 0) {
				if (child.weight > -20) {
					const weightSpan = App.UI.DOM.makeElement("span", 'quickly sheds its gained weight.', ["health", "dec"]);

					child.weight -= 40;

					span.append(`${His} developing body `, weightSpan);
				}
			}
		} else {
			if (child.weight > -20) {
				const weightSpan = App.UI.DOM.makeElement("span", 'quickly sheds its gained weight. ', ["health", "dec"]);

				child.weight -= 40;

				span.append(`${His} developing body `, weightSpan);
			}
		}

		return span;
	}

	function musclesRulesEffects(child) {
		const div = document.createElement("div");

		// TODO: rewrite these
		// FIXME: this entire section needs a rewrite - numbers and text don't line up at all
		if (V.nurseryMuscles) {
			const firstNanny = NL > 0 ? nannies[0] : null;
			const caretaker = Matron ? Matron.slaveName : NL > 1 ? `A nanny` : firstNanny.slaveName;
			const {His, He, he} = getPronouns(child);

			const muscleSpan = App.UI.DOM.makeElement("div", 'rapid muscle development.', "improvement");

			div.append(`${He} is being worked out as often as possible, resulting in `, muscleSpan);

			if (V.nurseryMusclesSetting === 2) {
				const muscleSpan = App.UI.DOM.makeElement("span", `decreases the amount of exercise ${he} receives. `, "improvement");

				if (child.muscles > 100) {
					child.muscles -= 5;
				}

				div.append(`${caretaker} notices ${he} is overly muscular and `, muscleSpan);
			} else if (V.nurseryMusclesSetting === 1) {
				if (child.muscles < -10) {
					const muscleSpan = App.UI.DOM.makeElement("span", `increases the amount of exercise ${he} receives. `, "improvement");

					child.muscles--;

					div.append(`${caretaker} notices ${he} is weak and `, muscleSpan);
				} else if (child.muscles > 10) {
					const muscleSpan = App.UI.DOM.makeElement("span", 'a healthy musculature;', ["change", "positive"]);

					child.muscles++;

					div.append(`${He} has `, muscleSpan, ` efforts will be made to maintain it. `);
				} else {
					const muscleSpan = App.UI.DOM.makeElement("span", 'quickly loses its gained muscle.', ["health", "dec"]);

					div.append(`${His} developing body `, muscleSpan);
				}
			} else if (V.nurseryMusclesSetting === 0) {
				const muscleSpan = App.UI.DOM.makeElement("span", 'quickly loses its gained muscle.', ["health", "dec"]);

				if (child.muscles > 100) {
					child.muscles -= 40;
					div.append(`${His} developing body `, muscleSpan);
				}
			}
		}

		return div;
	}

	// MARK: Miscellaneous Functions

	function childFriendshipRivalries(child) {
		const el = new DocumentFragment();
		const cribsCopy = Array.from(V.cribs);

		cribsCopy.splice(V.cribs.findIndex(c => c.ID === child.ID));

		for (const target of cribsCopy) {
			const becomeFriends = () => `${child.slaveName} and ${target.slaveName} have realized that they have more in common that they originally thought, and have become friends. `;
			const becomeRivals = () => `${child.slaveName} and ${target.slaveName} have more differences between them than they could put aside and have become rivals. `;
			const haveSameFetish = () => child.fetish === target.fetish && child.fetish !== "none";
			const haveSameBehavioralQuirk = () => child.behavioralQuirk && child.behavioralQuirk === target.behavioralQuirk && child.behavioralQuirk !== "none";
			const haveSameSexualQuirk = () => child.sexualQuirk && child.sexualQuirk === target.sexualQuirk && child.sexualQuirk !== "none";

			const div = document.createElement("div");

			const {his} = getPronouns(target);
			const chance = jsRandom(1, 100);

			let friend = 0;
			let rival = 0;

			if (target.actualAge >= 3) {
				if (haveSameFetish()) {
					div.append(`${sameFetish(child, target)}, a fact over which they bond. `);

					friend++;
				}

				if (haveSameBehavioralQuirk()) {	// TODO:
					div.append(`Since ${sameBehavioralQuirk(child, target)}, they learn to get along a bit better. `);

					friend++;
				}

				if (haveSameSexualQuirk()) {
					div.append(`Because ${sameSexualQuirk(child, target, haveSameBehavioralQuirk())}, the two grow a bit closer. `);

					friend++;
				}

				if (target.fetish === "sadist" || target.fetish === "dom") {
					div.append(`${target.slaveName} is a ${target.fetish}, and ${child.slaveName} is often ${his} target, which ${child.slaveName} doesn't particularly like. `);

					rival++;
				} else if (child.fetish === "sadist" || child.fetish === "dom") {
					div.append(`${child.slaveName} is a ${child.fetish}, and ${target.slaveName} is often ${his} target, which ${target.slaveName} doesn't particularly like. `);

					rival++;
				}

				if (areRelated(child, target) || areCousins(child, target)) {
					if (areRelated(child, target)) {
						if (rival) {
							div.append(`${child.slaveName} and ${target.slaveName} are siblings, and find it difficult to really stay mad at each other, and they make up their differences somewhat. `);

							friend += 2;
						} else {
							div.append(`${child.slaveName} and ${target.slaveName} are siblings, a fact that draws them closer together. `);

							friend += 2;
						}
					} else {
						if (rival) {
							div.append(`${child.slaveName} and ${target.slaveName} are cousins, and find it difficult to really stay mad at each other, and they make up their differences somewhat. `);

							friend++;
						} else {
							div.append(`${child.slaveName} and ${target.slaveName} are cousins, a fact that draws them closer together. `);

							friend++;
						}
					}
				}

				if (friend) {
					if (rival) {
						if (friend > rival && child.relationshipTarget !== target.ID) {
							if (chance > 75) {
								div.append(becomeFriends());

								child.relationship = 1;
								child.relationshipTarget = target.ID;

								target.relationship = 1;
								target.relationshipTarget = child.ID;
							}
						}
					} else {
						if (chance > 60) {
							div.append(becomeRivals());

							child.relationship = 1;
							child.relationshipTarget = target.ID;

							target.relationship = 1;
							target.relationshipTarget = child.ID;
						}
					}
				}

				if (rival) {
					if (friend) {
						if (rival > friend) {
							if (chance > 75) {
								div.append(becomeRivals());
							}
						}
					} else {
						if (chance > 60) {
							div.append(becomeFriends());
						}
					}
				}
			}

			el.append(div);
		}
		return el;

		function sameFetish(child, target) {
			switch (child.fetish) {
				case "submissive":
					return `${child.slaveName} and ${target.slaveName} are both sexually submissive`;
				case "cumslut":
					return `Neither ${child.slaveName} nor ${target.slaveName} can get enough cum`;
				case "humiliation":
					return `Both ${child.slaveName} and ${target.slaveName} have a fetish for humiliation`;
				case "buttslut":
					return `Neither ${child.slaveName} nor ${target.slaveName} can get enough assplay`;
				case "boobs":
					return `${child.slaveName} and ${target.slaveName} both love breastplay`;
				case "sadist":
					return `Both ${child.slaveName} are ${target.slaveName} are sadists`;
				case "masochist":
					return `${child.slaveName} and ${target.slaveName} are both masochists`;
				case "dom":
					return `Both ${child.slaveName} and ${target.slaveName} are sexually dominant`;
				case "pregnancy":
					return `The idea of pregnancy titillates both ${child.slaveName} and ${target.slaveName}`;
				default:
					throw Error(`Unexpected value ${child.fetish} in sameFetish(). Please report this.`);
			}
		}

		function sameBehavioralQuirk(child, target) {
			switch (child.behavioralQuirk) {
				case "confident":
					return `${child.slaveName} and ${target.slaveName} are both naturally confident`;
				case "cutting":
					return `both ${child.slaveName} and ${target.slaveName} have a cutting wit about them`;
				case "funny":
					return `${child.slaveName} and ${target.slaveName} can both make the other laugh`;
				case "fitness":
					return `${child.slaveName} and ${target.slaveName} both love to try to stay in shape`;
				case "adores women":
					return `${child.slaveName} and ${target.slaveName} both adore women`;
				case "adores men":
					return `both ${child.slaveName} are ${target.slaveName} adore men`;
				case "insecure":
					return `${child.slaveName} and ${target.slaveName} are both equally insecure`;
				case "sinful":
					return `both ${child.slaveName} and ${target.slaveName} love breaking cultural and religious mores`;
				case "advocate":
					return `${child.slaveName} and ${target.slaveName} can both make a strong case for slavery`;
				default:
					throw Error(`Unexpected value ${child.behavioralQuirk} in sameBehavioralQuirk(). Please report this.`);
			}
		}

		// TODO: incorporate minimumSlaveAge
		function sameSexualQuirk(child, target, sameQuirk = false) {
			switch (child.sexualQuirk) {
				case "gagfuck queen":
					return `${sameQuirk ? `the two also` : `${child.slaveName} and ${target.slaveName} both`} love having their little throats fucked`;
				case "painal queen":
					return `${sameQuirk ? `neither` : `neither ${child.slaveName} nor ${target.slaveName}`} can get enough painal`;
				case "strugglefuck queen":
					return `${sameQuirk ? `the two also` : `${child.slaveName} and ${target.slaveName} both`} love to put up a struggle during sex`;
				case "tease":
					return `${sameQuirk ? `the two are also both teases` : `${child.slaveName} and ${target.slaveName} are both teases`}`;
				case "romantic":
					return `${sameQuirk ? `the two also` : `${child.slaveName} and ${target.slaveName} both`} see the world from under a romantic lens`;
				case "perverted":
					return `${sameQuirk ? `the two are also` : `${child.slaveName} and ${target.slaveName} are both`} big-time perverts`;
				case "caring":
					return `${sameQuirk ? `the two also` : `${child.slaveName} and ${target.slaveName} both`} care about their partners`;
				case "unflinching":
					return `${sameQuirk ? `the two can also` : `${child.slaveName} and ${target.slaveName} can both`} take whatever their partner might throw at them `;
				case "size queen":
					return `${sameQuirk ? `the two also` : `${child.slaveName} and ${target.slaveName} both`} have a love for huge cock`;
				default:
					throw Error(`Unexpected value ${child.fetish} in sameSexualQuirk(). Please report this.`);
			}
		}
	}

	function newChildFetish(fetish = "none") {
		switch (fetish) {
			case "submissive":
				return `is now sexually submissive`;
			case "cumslut":
				return `is now a cumslut`;
			case "humiliation":
				return `now has a fetish for humiliation`;
			case "buttslut":
				return `is now a buttslut`;
			case "boobs":
				return `now has a fetish for all things breast-related`;
			case "sadist":
				return `now gets off on causing pain`;
			case "masochist":
				return `now gets off on pain`;
			case "dom":
				return `is now very sexually dominant`;
			case "pregnancy":
				return `has developed a fascination for all things pregnancy-related`;
			default:
				throw Error(`Unexpected fetish value of "${fetish}" in newChildFetish(). Please report this.`);
		}
	}

	function childGrowTime(child) {
		const nameSpan = App.UI.DOM.makeElement("span", child.slaveName, "pink");
		const limeSpan = App.UI.DOM.makeElement("span", 'ready for release.', "lime");
		const mainSpan = document.createElement("span");

		const {He} = getPronouns(child);

		if (child.growTime > 0) {
			mainSpan.append(nameSpan, ` is growing steadily. ${He} will be ready for release in about ${years(child.growTime)}. `);
		} else {
			mainSpan.append(nameSpan, ' is ', limeSpan, ` ${He} will be removed from ${V.nurseryName} upon your approach. `);
		}

		return mainSpan;
	}

	function findMedianNannyIntelligence() {
		return median(nannies.map(n => n.intelligence));
	}

	function findMedianNannyIntelligenceImplant() {
		return median(nannies.map(n => n.intelligenceImplant));
	}

	/**
	 * Checks if there are more than one children over the target age in the Nursery
	 * @param {number} index
	 * @param {number} [age=3]
	 */
	function multipleChildrenOverTargetAge(index, age = 3) {
		const cribsCopy = Array.from(V.cribs);

		cribsCopy.splice(index, 1);

		return V.cribs.length > 1 && cribsCopy.some(c => c.actualAge >= age);
	}

	return frag;
};