:: SA rest [script]

window.saRest = function saRest(slave) {

	var pronouns = getPronouns(slave);
	var he = pronouns.pronoun, him = pronouns.object, his = pronouns.possessive, hers = pronouns.possessivePronoun, himself = pronouns.objectReflexive, boy = pronouns.noun;
	var He = capFirstChar(he), His = capFirstChar(his);
	var V = State.variables;

	var t = " takes the week off.";

	if (slave.fuckdoll > 0) {
		t += " ${He} has nothing to do but ";
		if (slave.amp == 0) {
			t += "lie ";
		} else {
			t += "stand ";
		}
		t += "in place.";
	}

	if (slave.health > 90) {
		t += ` ${His} health is so outstanding that rest does not improve it.`;
	} else if (slave.health > -100) {
		t += ` ${His} <span class='green'>health recovers</span> with rest.`;
		slave.health += 10;
		if (!(canHear(slave))) {
			t += ` Since ${he} is deaf, the hustle and bustle of daily life in the penthouse <span class='green'>didn't bother ${him} at all.</span>`;
			slave.health += 3;
		} else if ((slave.hears == -1 && slave.earwear != "hearing aids") || (slave.hears == 0 && slave.earwear == "muffling ear plugs")) {
			t += ` Since ${he} is hard of hearing, the hustle and bustle of daily life in the penthouse <span class='green'>didn't disturb ${his} rest as much.</span>`;
			slave.health += 1;
		}
	}

	if (slave.fuckdoll == 0 && slave.fetish != "mindbroken") {
		if (slave.devotion > 20) {
			if (slave.trust <= 20) {
				t += ` Being allowed to rest <span class='mediumaquamarine'>reduces ${his} fear</span> of you.`;
				slave.trust += 4;
			} else if (slave.trust <= 50) {
				t += ` Being allowed to rest <span class='mediumaquamarine'>builds ${his} trust</span> in you.`;
				slave.trust += 2;
			} else {
				t += ` Being allowed to rest <span class='mediumaquamarine'>confirms ${his} trust</span> in you.`;
				slave.trust += 2;
			}
		} else {
			if (slave.trust < -20) {
				t += ` Being allowed to rest <span class='mediumaquamarine'>reduces ${his} fear</span> of you.`;
				slave.trust += 4;
			}
		}
	}

	if (V.showVignettes == 1 && slave.assignment === Job.REST) {
		var _vignette = GetVignette(slave);
		t += ` __This week__ ${_vignette.text} `
		if (_vignette.type == "cash") {
			if (_vignette.effect > 0) {
				t += `<span class='yellowgreen'>making you an extra ${cashFormat(Math.trunc(V.FResult*_vignette.effect))}.</span>`;
			} else if (_vignette.effect < 0) {
				t += `<span class='red'>losing you ${cashFormat(Math.abs(Math.trunc(V.FResult*_vignette.effect)))}.</span>`;
			} else {
				t += `an incident without lasting effect.`;
			}
			V.cash += Math.trunc(V.FResult*_vignette.effect);
		} else if (_vignette.type == "devotion") {
			if (_vignette.effect > 0) {
				if (slave.devotion > 50) {
					t += `<span class='hotpink'>increasing ${his} devotion to you.</span>`;
				} else if (slave.devotion >= -20) {
					t += `<span class='hotpink'>increasing ${his} acceptance of you.</span>`;
				} else if (slave.devotion > -10) {
					t += `<span class='hotpink'>reducing ${his} dislike of you.</span>`;
				} else {
					t += `<span class='hotpink'>reducing ${his} hatred of you.</span>`;
				}
			} else if (_vignette.effect < 0) {
				if (slave.devotion > 50) {
					t += `<span class='mediumorchid'>reducing ${his} devotion to you.</span>`;
				} else if (slave.devotion >= -20) {
					t += `<span class='mediumorchid'>reducing ${his} acceptance of you.</span>`;
				} else if (slave.devotion > -10) {
					t += `<span class='mediumorchid'>increasing ${his} dislike of you.</span>`;
				} else {
					t += `<span class='mediumorchid'>increasing ${his} hatred of you.</span>`;
				}
			} else {
				t += `an incident without lasting effect.`;
			}
			slave.devotion += (1*_vignette.effect);
		} else if (_vignette.type == "trust") {
			if (_vignette.effect > 0) {
				if (slave.trust > 20) {
					t += `<span class='mediumaquamarine'>increasing ${his} trust in you.</span>`;
				} else if (slave.trust > -10) {
					t += `<span class='mediumaquamarine'>reducing ${his} fear of you.</span>`;
				} else {
					t += `<span class='mediumaquamarine'>reducing ${his} terror of you.</span>`;
				}
			} else if (_vignette.effect < 0) {
				if (slave.trust > 20) {
					t += `<span class='gold'>reducing ${his} trust in you.</span>`;
				} else if (slave.trust >= -20) {
					t += `<span class='gold'>increasing ${his} fear of you.</span>`;
				} else {
					t += `<span class='gold'>increasing ${his} terror of you.</span>`;
				}
			} else {
				t += `an incident without lasting effect.`;
			}
			slave.trust += (1*_vignette.effect);
		} else if (_vignette.type == "health") {
			if (_vignette.effect > 0) {
				t += `<span class='green'>improving ${his} health.</span>`;
			} else if (_vignette.effect < 0) {
				t += `<span class='red'>affecting ${his} health.</span>`;
			} else {
				t += `an incident without lasting effect.`;
			}
			slave.health += (2*_vignette.effect);
		} else {
			if (_vignette.effect > 0) {
				t += `<span class='green'>gaining you a bit of reputation.</span>`;
			} else if (_vignette.effect < 0) {
				t += `<span class='red'>losing you a bit of reputation.</span>`;
			} else {
				t += `an incident without lasting effect.`;
			}
			V.rep += Math.trunc(V.FResult*_vignette.effect*0.1);
		}
	}

	return t;
}