:: Rules Autosurgery [nobr]
 
<<set $surgeries = []>>

<<for _r to $defaultRules.length-1; _r >= 0; _r-->>
	<<set _currentRule to $defaultRules[_r]>>
	<<if (def _currentRule) && (_currentRule.autoSurgery != 0)>>
		<<set $thisSurgery to _currentRule.surgery>>
		<<set _temp to lastLactationSurgeryRule($slaves[$i], $defaultRules)>>
		<<if _temp != null>>
			<<set $thisSurgery.lactation = _temp.surgery.lactation>>
		<</if>>
		<<set _temp to lastLipSurgeryRule($slaves[$i], $defaultRules)>>
		<<if _temp != null>>
			<<set $thisSurgery.lips = _temp.surgery.lips>>
		<</if>>
		<<set _temp to lastButtSurgeryRule($slaves[$i], $defaultRules)>>
		<<if _temp != null>>
			<<set $thisSurgery.butt = _temp.surgery.butt>>
		<</if>>
		<<set _temp to lastBoobSurgeryRule($slaves[$i], $defaultRules)>>
		<<if _temp != null>>
			<<set $thisSurgery.boobs = _temp.surgery.boobs>>
		<</if>>
		<<if ($thisSurgery.hips isnot "no default setting") && ($thisSurgery.butt isnot "no default setting")>>
			<<if $slaves[$i].hips < -1>>
				<<if $thisSurgery.butt > 2>>
					<<set $thisSurgery.butt to 2>>
				<</if>>
			<<elseif $slaves[$i].hips < 0>>
				<<if $thisSurgery.butt > 4>>
					<<set $thisSurgery.butt to 4>>
				<</if>>
			<<elseif $slaves[$i].hips > 0>>
				<<if $thisSurgery.butt > 8>>
					<<set $thisSurgery.butt to 8>>
				<</if>>
			<<elseif $slaves[$i].hips > 1>>
			<<else>>
				<<if $thisSurgery.butt > 6>>
					<<set $thisSurgery.butt to 6>>
				<</if>>
			<</if>>
		<</if>>
		<<break>>
	<</if>>
<</for>>
<<if ndef $thisSurgery>>
	<<set $thisSurgery to {lactation: "no default setting", cosmetic: 0, accent: "no default setting", shoulders: "no default setting", shouldersImplant: "no default setting", boobs: "no default setting", hips: "no default setting", hipsImplant: "no default setting", butt: "no default setting", faceShape: "no default setting", lips: "no default setting", holes: 0}>>
<</if>>

<<set $seed to 0>>
<<for $seed == 0>>

<<if ($slaves[$i].health <= 20)>>
	<<set $seed = 1>>
<<else>>
<<if ($slaves[$i].lactation == 2) && ($thisSurgery.lactation == 0)>>
	<<set $surgeries.push("surgery to remove her lactation implants")>>
	<<set $slaves[$i].lactation to 0>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].lactation != 2) && ($thisSurgery.lactation == 1)>>
	<<set $surgeries.push("lactation inducing implanted drugs")>>
	<<set $slaves[$i].lactation to 2>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].anus > 3) && ($thisSurgery.cosmetic > 0)>>
	<<set $surgeries.push("a restored anus")>>
	<<set $slaves[$i].anus to 3>>
	<<if $slaves[$i].analSkill > 10>>
		<<set $slaves[$i].analSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].vagina > 3) && ($thisSurgery.cosmetic > 0)>>
	<<set $surgeries.push("a restored pussy")>>
	<<set $slaves[$i].vagina to 3>>
	<<if $slaves[$i].vaginalSkill > 10>>
		<<set $slaves[$i].vaginalSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].faceImplant == 0) && ($slaves[$i].face < 3) && ($thisSurgery.cosmetic != 0)>>
	<<set $surgeries.push("a nicer face")>>
	<<if $slaves[$i].faceShape is "masculine">><<set $slaves[$i].faceShape to "androgynous">><</if>>
	<<set $slaves[$i].faceImplant to 1>>
	<<set $slaves[$i].face += 1>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].ageImplant != 1) && ($slaves[$i].physicalAge >= 25) && ($thisSurgery.cosmetic != 0)>>
	<<set $surgeries.push("an age lift")>>
	<<set $slaves[$i].ageImplant to 1>>
	<<if $slaves[$i].visualAge > 80>>
		<<set $slaves[$i].visualAge -= 40>>
	<<elseif $slaves[$i].visualAge >= 70>>
		<<set $slaves[$i].visualAge -= 30>>
	<<elseif $slaves[$i].visualAge > 50>>
		<<set $slaves[$i].visualAge -= 20>>
	<<elseif $slaves[$i].visualAge > 36>>
		<<set $slaves[$i].visualAge -= 10>>
	<<else>>
		<<set $slaves[$i].visualAge -= 5>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].voice == 1) && ($slaves[$i].voiceImplant == 0) && ($thisSurgery.cosmetic != 0)>>
	<<set $surgeries.push("a feminine voice")>>
	<<set $slaves[$i].voice += 1>>
	<<set $slaves[$i].voiceImplant += 1>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].waist == 0) && ($thisSurgery.cosmetic != 0)>>
	<<set $surgeries.push("a narrower waist")>>
	<<set $slaves[$i].waist to 1>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif (($slaves[$i].boobShape == "saggy") || ($slaves[$i].boobShape == "downward-facing")) && ($thisSurgery.cosmetic != 0)>>
	<<set $surgeries.push("a breast lift")>>
	<<set $slaves[$i].boobShape = "normal">>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif (($slaves[$i].boobShape == "normal") || ($slaves[$i].boobShape == "wide-set")) && ($thisSurgery.cosmetic != 0)>>
	<<if $slaves[$i].boobs > 800>>
		<<set $slaves[$i].boobShape = "torpedo-shaped">>
	<<else>>
		<<set $slaves[$i].boobShape = "perky">>
	<</if>>
	<<set $surgeries.push("more interestingly shaped breasts")>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($thisSurgery.lips == 0) && ($slaves[$i].lipsImplant > 0)>>
	<<set $surgeries.push("surgery to remove her lip implants")>>
	<<set $slaves[$i].lips -= $slaves[$i].lipsImplant>>
	<<set $slaves[$i].lipsImplant = 0>>
	<<if $slaves[$i].oralSkill > 10>>
		<<set $slaves[$i].oralSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].lips <= 95) && ($slaves[$i].lips < $thisSurgery.lips)>>
	<<if $thisSurgery.lips isnot "no default setting">>
		<<set $surgeries.push("bigger lips")>>
		<<set $slaves[$i].lipsImplant += 10>>
		<<set $slaves[$i].lips += 10>>
		<<if $slaves[$i].oralSkill > 10>>
			<<set $slaves[$i].oralSkill -= 10>>
		<</if>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].faceImplant == 1) && ($slaves[$i].face < 3) && ($thisSurgery.cosmetic is 2)>>
	<<set $surgeries.push("a nicer face")>>
	<<if $slaves[$i].faceShape is "masculine">><<set $slaves[$i].faceShape to "androgynous">><</if>>
	<<set $slaves[$i].faceImplant to 2>>
	<<set $slaves[$i].face += 1>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].faceImplant > 0) && ($slaves[$i].face < 3) && ($surgeryUpgrade == 1) && ($thisSurgery.cosmetic is 2)>>
	<<set $surgeries.push("a nicer face")>>
	<<if $slaves[$i].faceShape is "masculine">><<set $slaves[$i].faceShape to "androgynous">><</if>>
	<<set $slaves[$i].faceImplant to 2>>
	<<set $slaves[$i].face += 1>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].waist == 1) && ($thisSurgery.cosmetic is 2) && ($seeExtreme == 1)>>
	<<set $surgeries.push("a narrower waist")>>
	<<set $slaves[$i].waist to 2>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 30.5>><<else>><<set $slaves[$i].health -= 4>><</if>>
<<elseif ($slaves[$i].voice < 3) && ($slaves[$i].voiceImplant == 0) && ($thisSurgery.cosmetic is 2)>>
	<<set $surgeries.push("a bimbo's voice")>>
	<<set $slaves[$i].voice += 1>>
	<<set $slaves[$i].voiceImplant += 1>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($thisSurgery.butt == 0) && ($slaves[$i].buttImplant > 0)>>
	<<set $surgeries.push("surgery to remove her butt implants")>>
	<<set $slaves[$i].butt -= $slaves[$i].buttImplant>>	
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($thisSurgery.boobs == 0) && ($slaves[$i].boobsImplant > 0)>>
	<<set $surgeries.push("surgery to remove her boob implants")>>
	<<set $slaves[$i].boobs -= $slaves[$i].boobsImplant>>
	<<set $slaves[$i].boobsImplant = 0>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].butt <= 3) && ($slaves[$i].butt < $thisSurgery.butt)>>
	<<if $thisSurgery.butt isnot "no default setting">>
		<<set $surgeries.push("a bigger butt")>>
		<<set $slaves[$i].buttImplant to 1>>
		<<set $slaves[$i].butt += 1>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].boobs <= 600) && ($slaves[$i].lactation < 2) && ($slaves[$i].boobs+400 <= $thisSurgery.boobs)>>
	<<if $thisSurgery.boobs isnot "no default setting">>
		<<set $surgeries.push("bigger boobs")>>
		<<set $slaves[$i].boobsImplant += 400>>
		<<set $slaves[$i].boobs += 400>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">>
		<<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].boobs <= 600) && ($slaves[$i].lactation < 2) && ($slaves[$i].boobs+200 <= $thisSurgery.boobs)>>
	<<if $thisSurgery.boobs isnot "no default setting">>
		<<set $surgeries.push("modestly bigger boobs")>>
		<<set $slaves[$i].boobsImplant += 200>>
		<<set $slaves[$i].boobs += 200>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].butt <= 5) && ($slaves[$i].butt < $thisSurgery.butt)>>
	<<if $thisSurgery.butt isnot "no default setting">>
		<<set $surgeries.push("a bigger butt")>>
		<<set $slaves[$i].buttImplant to 1>>
		<<set $slaves[$i].butt += 1>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].boobs <= 2000) && ($slaves[$i].lactation < 2) && ($slaves[$i].boobs+400 < $thisSurgery.boobs)>>
	<<if $thisSurgery.boobs isnot "no default setting">>
		<<set $surgeries.push("bigger boobs")>>
		<<set $slaves[$i].boobsImplant += 400>>
		<<set $slaves[$i].boobs += 400>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].anus > 0) && ($surgeryUpgrade == 1) && ($thisSurgery.holes is 2)>>
	<<set $surgeries.push("a virgin anus")>>
	<<set $slaves[$i].anus to 0>>
	<<if $slaves[$i].analSkill > 10>>
		<<set $slaves[$i].analSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].vagina > 0) && ($surgeryUpgrade == 1) && ($thisSurgery.holes == 2)>>
	<<set $surgeries.push("a virgin pussy")>>
	<<set $slaves[$i].vagina to 0>>
	<<if $slaves[$i].vaginalSkill > 10>>
		<<set $slaves[$i].vaginalSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].anus > 1) && ($thisSurgery.holes == 1)>>
	<<set $surgeries.push("a tighter anus")>>
	<<set $slaves[$i].anus to 1>>
	<<if $slaves[$i].analSkill > 10>>
		<<set $slaves[$i].analSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].vagina > 1) && ($thisSurgery.holes == 1)>>
	<<set $surgeries.push("a tighter pussy")>>
	<<set $slaves[$i].vagina to 1>>
	<<if $slaves[$i].vaginalSkill > 10>>
		<<set $slaves[$i].vaginalSkill -= 10>>
	<</if>>
	<<set $cash -= $surgeryCost>>
	<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
<<elseif ($slaves[$i].butt <= 8) && ($slaves[$i].butt < $thisSurgery.butt)>>
	<<if $thisSurgery.butt isnot "no default setting">>
		<<set $surgeries.push("a bigger butt")>>
		<<set $slaves[$i].buttImplant to 1>>
		<<set $slaves[$i].butt += 1>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<elseif ($slaves[$i].boobs <= 9000) && ($slaves[$i].lactation < 2) && ($slaves[$i].boobs < $thisSurgery.boobs)>>
	<<if $thisSurgery.boobs isnot "no default setting">>
		<<set $surgeries.push("bigger boobs")>>
		<<set $slaves[$i].boobsImplant += 200>>
		<<set $slaves[$i].boobs += 200>>
		<<set $cash -= $surgeryCost>>
		<<if $PC.career is "medicine">><<set $slaves[$i].health -= 5>><<else>><<set $slaves[$i].health -= 10>><</if>>
	<</if>>
<<else>>

<<set $seed = 1>>
<</if>>
<</if>>

<</for>>

<<if $surgeries.length > 0>>
	<<set $surgeriesDisplay to "">>
	<<for $j to 0; $j < $surgeries.length; $j++>>
		<<set $seed to $surgeries[$j]>>
		<<set $surgeriesDisplay to ($surgeriesDisplay + $seed)>>
		<<if $j < $surgeries.length-2>>
		<<set $surgeriesDisplay to ($surgeriesDisplay + ", ")>>
		<<elseif $j < $surgeries.length-1>>
		<<if $surgeries.length > 2>>
			<<set $surgeriesDisplay to ($surgeriesDisplay + ", and ")>>
		<<else>>
			<<set $surgeriesDisplay to ($surgeriesDisplay + " and ")>>
		<</if>>
		<</if>>
	<</for>>
	<<if $assistantName is "your personal assistant">>Your personal assistant<<else>>$assistantName<</if>>, ordered to apply surgery, gives $slaves[$i].slaveName @@color:lime;$surgeriesDisplay.@@
<</if>>
