:: Summary Widgets JS [script]

window.SlaveStatClamp = function SlaveStatClamp(slave) {
	slave.energy = Math.clamp(slave.energy, 0, 100);
	const V = State.variables;

	if (slave.devotion > 100) {
		if (slave.trust < -95)
			slave.trust = -100;
		else if ((slave.trust < 100) && (slave.trust > 20))
			slave.trust += (Math.trunc((slave.devotion-100)*5)/10);
		else
			V.rep += 10*(slave.devotion-100);
		slave.devotion = 100;
	} else if (slave.devotion < -95)
		slave.devotion = -100;
	if (slave.trust > 100) {
		if (slave.devotion < -95)
			slave.devotion = -100;
		else if (slave.devotion < 100 && slave.devotion > 20)
			slave.devotion += Math.trunc(slave.trust-100);
		else
			V.rep += 10*(slave.trust-100);
		slave.trust = 100;
	} else if (slave.trust < -95)
		slave.trust = -100;
	if (slave.trust < -100)
		slave.trust = -100;
	if (slave.devotion < -100)
		slave.devotion = -100;
	if (isNaN(slave.oralCount)) {
		slave.oralCount = 0;
		alert("Oral count has broken, report what you just did!");
	}
	if (isNaN(slave.analCount)) {
		slave.analCount = 0;
		alert("Anal count has broken, report what you just did!");
	}
	if (isNaN(slave.vaginalCount)) {
		slave.vaginalCount = 0;
		alert("Vaginal count has broken, report what you just did!");
	}
	if (isNaN(slave.mammaryCount)) {
		slave.mammaryCount = 0;
		alert("Titfuck count has broken, report what you just did!");
	}
	if (isNaN(slave.penetrativeCount)) {
		slave.penetrativeCount = 0;
		alert("Penetration count has broken, report what you just did!");
	}
	if (slave.foreskin === undefined)
		slave.foreskin = 0;
	if (slave.amp != 0 && slave.heels == 1)
		slave.heels = 0;
	if (slave.vagina < 0 && slave.mpreg == 0 && slave.preg == -1) {
		slave.preg = 0;
		WombFlush(slave);
	}

};
