:: Next Week [nobr]

<<if $rivalOwner != 0>>
	<<set _rival = $arcologies.find(function(s) { return s.rival == 1; })>>
	<<if def _rival>>
		<<set $rivalOwner = _rival.prosperity>>
	<</if>>
<</if>>

<<if $playerAging != 0>>
	<<set $PC.birthWeek += 1>>
	<<if $PC.ovaryAge >= 55 && ($PC.preg == -1 || $PC.preg == 0)>>
		<<set $PC.preg = -2>>
	<</if>>
	<<if $PC.birthWeek >= 52>>
		<<set $PC.birthWeek = 0>>
		<<if $playerAging == 2>>
			<<set $PC.physicalAge++, $PC.actualAge++, $PC.visualAge++, $PC.ovaryAge++>>
			<<AgePCEffects>>
		<</if>>
	<</if>>
<</if>>

<<set $averageTrust = 0, $averageDevotion = 0, _slavesContributing = 0, _OldHG = -1, _NewHG = -1, _SL = $slaves.length>>
<<if $studio == 1>>
	<<set $pornStars = 0, $pornStarFuckdolls = 0, $pornStarRapees = 0, $pornStarPreggos = 0,
	$pornStarBBWs = 0, $pornStarGainers = 0, $pornStarStuds = 0, $pornStarLolis = 0,
	$pornStarDeepThroats = 0, $pornStarStruggleFucks = 0, $pornStarTeases = 0,
	$pornStarRomantics = 0, $pornStarPerverts = 0, $pornStarCarings = 0, $pornStarUnflinchings = 0,
	$pornStarSizeQueens = 0, $pornStarNeglectfuls = 0, $pornStarCumAddicts = 0, $pornStarAnalAddicts = 0,
	$pornStarAttentionWhores = 0, $pornStarBreastGrowths = 0, $pornStarAbusives = 0, $pornStarMalicious = 0, $pornStarSelfHatings = 0, $pornStarBreeders = 0, $pornStarSubs = 0, $pornStarCumSluts = 0,
	$pornStarAnals = 0, $pornStarHumiliations = 0, $pornStarBoobs = 0, $pornStarDoms = 0,
	$pornStarSadists = 0, $pornStarMasochists = 0, $pornStarPregnancySluts = 0>>
<</if>>
<<for _i = 0; _i < _SL; _i++>>
	<<if $seeAge != 0>>
	<<set $slaves[_i].birthWeek++>>
		<<if $slaves[_i].birthWeek >= 52>>
			<<set $slaves[_i].birthWeek = 0>>
			<<if $seeAge == 1>>
				<<set $slaves[_i].physicalAge += 1, $slaves[_i].actualAge += 1>>
				/* Note Induced NCS completely takes over visual aging, so the increment from pre-existing code simply is trapped behind a !NCS test. Additionally, because of the neotony aspects of NCS, ovaries don't age quite as fast. */
				<<if $slaves[_i].inducedNCS == 0>>
					<<set $slaves[_i].visualAge += 1>>
					/* (prev comment) Hopefully this works. It is intended, over a slave's lifetime, to cause her menopause to shift. */
					<<set $slaves[_i].ovaryAge += either(.8, .9, .9, 1, 1, 1, 1.1)>>
				<<else>>
					<<set $slaves[_i].ovaryAge += either(.5, .6, .7, .7, .8, .9, 1)>>
				<</if>>
				<<if $slaves[_i].broodmother == 1>>
					<<set $slaves[_i].ovaryAge += .2>>
				<</if>>
				<<if $slaves[_i].physicalAge <= 18 && $loliGrow == 0>>
					<<PhysicalDevelopment $slaves[_i]>>
				<</if>>
			<</if>>
		<</if>>
	<</if>>
	<<if $slaves[_i].indenture > 0>>
		<<set $slaves[_i].indenture -= 1>>
	<</if>>
	<<set $slaves[_i].trust = Number($slaves[_i].trust.toFixed(1)), $slaves[_i].devotion = Number($slaves[_i].devotion.toFixed(1))>>
	<<set $slaves[_i].oldDevotion = $slaves[_i].devotion, $slaves[_i].oldTrust = $slaves[_i].trust, $slaves[_i].tired = 0, $slaves[_i].minorInjury = 0>>
	<<if $slaves[_i].sentence > 1>>
		<<set $slaves[_i].sentence -= 1>>
	<<elseif $slaves[_i].sentence == 1>>
		<<= removeJob($slaves[_i], $slaves[_i].assignment)>>
	<</if>>
	<<if $slaves[_i].weekAcquired < 0>>
		<<set $slaves[_i].weekAcquired = 0>>
	<</if>>
	<<if $slaves[_i].relation == 0>>
		<<set $slaves[_i].relationTarget = 0>>
	<</if>>
	<<if $slaves[_i].relationship == 0>>
		<<set $slaves[_i].relationshipTarget = 0>>
	<</if>>
	<<if $slaves[_i].rivalry == 0>>
		<<set $slaves[_i].rivalryTarget = 0>>
	<<elseif $slaves[_i].rivalry < 0>>
		<<set $slaves[_i].rivalryTarget = 0, $slaves[_i].rivalry = 0>>
	<</if>>
	<<if $slaves[_i].vagina < 0 && $slaves[_i].vaginalAccessory != "none">>
		<<set $slaves[_i].vaginalAccessory = "none">>
	<</if>>
	<<if $slaves[_i].dick == 0 && $slaves[_i].dickAccessory != "none">>
		<<set $slaves[_i].dickAccessory = "none">>
	<</if>>
	/% Fix some possible floating point rounding errors, and bring precision to one decimal place. %/
	<<run SlaveStatClamp($slaves[_i])>>
	<<set $slaves[_i].energy = Math.clamp($slaves[_i].energy.toFixed(1), 0, 100)>>
	<<if $slaves[_i].fetishStrength > 95>>
		<<set $slaves[_i].fetishStrength = 100>>
	<<else>>
		<<set $slaves[_i].fetishStrength = Math.clamp($slaves[_i].fetishStrength.toFixed(1), 0, 100)>>
	<</if>>
	<<set $slaves[_i].weight = Math.clamp($slaves[_i].weight.toFixed(1), -100, 200)>>
	<<set $slaves[_i].health = Number($slaves[_i].health.toFixed(1))>>
	<<set $slaves[_i].butt = Number($slaves[_i].butt.toFixed(1))>>
	<<set $slaves[_i].muscles = Math.clamp($slaves[_i].muscles.toFixed(1), -100, 100)>>
	<<set $slaves[_i].lips = Math.clamp($slaves[_i].lips.toFixed(1), 0, 100)>>
	<<set $slaves[_i].oralSkill = Math.clamp($slaves[_i].oralSkill.toFixed(1), 0, 100)>>
	<<set $slaves[_i].vaginalSkill = Math.clamp($slaves[_i].vaginalSkill.toFixed(1), 0, 100)>>
	<<set $slaves[_i].analSkill = Math.clamp($slaves[_i].analSkill.toFixed(1), 0, 100)>>
	<<set $slaves[_i].whoreSkill = Math.clamp($slaves[_i].whoreSkill.toFixed(1), 0, 100)>>
	<<set $slaves[_i].entertainSkill = Math.clamp($slaves[_i].entertainSkill.toFixed(1), 0, 100)>>
	<<set $slaves[_i].lactationAdaptation = Math.clamp($slaves[_i].lactationAdaptation.toFixed(1), 0, 100)>>
	<<set $slaves[_i].intelligenceImplant = Number($slaves[_i].intelligenceImplant.toFixed(1), 0, 30)>>
	<<if ($HGSuiteEquality == 1) && ($HeadGirl != 0) && ($slaves[_i].devotion > 50)>>
		<<if ($slaves[_i].assignment == "live with your Head Girl")>>
			<<set _NewHG = _i>>
		<<elseif ($slaves[_i].ID == $HeadGirl.ID)>>
			<<set _OldHG = _i>>
		<</if>>
	<</if>>
	/* AVERAGE VALUES UPDATE */
	<<if $slaves[_i].assignmentVisible == 1>>
		<<set $averageTrust += $slaves[_i].trust, $averageDevotion += $slaves[_i].devotion, _slavesContributing++>>
	<<elseif ($slaves[_i].assignment != "be confined in the cellblock") && ($slaves[_i].assignment != "be confined in the arcade") && (($slaves[_i].assignment != "work in the dairy") || ($dairyRestraintsSetting < 2)) && $slaves[_i].assignment != "labor in the production line">>
		<<set $averageTrust += $slaves[_i].trust*0.5, $averageDevotion += $slaves[_i].devotion*0.5, _slavesContributing += 0.5>>
	<</if>>
	<<if $studio == 1>>
		<<if $slaves[_i].pornTypeGeneral > 0>><<set $pornStars++>><</if>>
		<<if $slaves[_i].pornTypeFuckdoll > 0>><<set $pornStarFuckdolls++>><</if>>
		<<if $slaves[_i].pornTypeRape > 0>><<set $pornStarRapees++>><</if>>
		<<if $slaves[_i].pornTypePreggo > 0>><<set $pornStarPreggos++>><</if>>
		<<if $slaves[_i].pornTypeBBW > 0>><<set $pornStarBBWs++>><</if>>
		<<if $slaves[_i].pornTypeGainer > 0>><<set $pornStarGainers++>><</if>>
		<<if $slaves[_i].pornTypeStud > 0>><<set $pornStarStuds++>><</if>>
		<<if $slaves[_i].pornTypeLoli > 0>><<set $pornStarLolis++>><</if>>
		<<if $slaves[_i].pornTypeDeepThroat > 0>><<set $pornStarDeepThroats++>><</if>>
		<<if $slaves[_i].pornTypeStruggleFuck > 0>><<set $pornStarStruggleFucks++>><</if>>
		<<if $slaves[_i].pornTypePainal > 0>><<set $pornStarPainals++>><</if>>
		<<if $slaves[_i].pornTypeTease > 0>><<set $pornStarTeases++>><</if>>
		<<if $slaves[_i].pornTypeRomantic > 0>><<set $pornStarRomantics++>><</if>>
		<<if $slaves[_i].pornTypePervert > 0>><<set $pornStarPerverts++>><</if>>
		<<if $slaves[_i].pornTypeCaring > 0>><<set $pornStarCarings++>><</if>>
		<<if $slaves[_i].pornTypeUnflinching > 0>><<set $pornStarUnflinchings++>><</if>>
		<<if $slaves[_i].pornTypeSizeQueen > 0>><<set $pornStarSizeQueens++>><</if>>
		<<if $slaves[_i].pornTypeNeglectful > 0>><<set $pornStarNeglectfuls++>><</if>>
		<<if $slaves[_i].pornTypeCumAddict > 0>><<set $pornStarCumAddicts++>><</if>>
		<<if $slaves[_i].pornTypeAnalAddict > 0>><<set $pornStarAnalAddicts++>><</if>>
		<<if $slaves[_i].pornTypeAttentionWhore > 0>><<set $pornStarAttentionWhores++>><</if>>
		<<if $slaves[_i].pornTypeBreastGrowth > 0>><<set $pornStarBreastGrowths++>><</if>>
		<<if $slaves[_i].pornTypeAbusive > 0>><<set $pornStarAbusives++>><</if>>
		<<if $slaves[_i].pornTypeMalicious > 0>><<set $pornStarMalicious++>><</if>>
		<<if $slaves[_i].pornTypeSelfHating > 0>><<set $pornStarSelfHatings++>><</if>>
		<<if $slaves[_i].pornTypeBreeder > 0>><<set $pornStarBreeders++>><</if>>
		<<if $slaves[_i].pornTypeSub > 0>><<set $pornStarSubs++>><</if>>
		<<if $slaves[_i].pornTypeCumSlut > 0>><<set $pornStarCumSluts++>><</if>>
		<<if $slaves[_i].pornTypeAnal > 0>><<set $pornStarAnals++>><</if>>
		<<if $slaves[_i].pornTypeHumiliation > 0>><<set $pornStarHumiliations++>><</if>>
		<<if $slaves[_i].pornTypeBoobs > 0>><<set $pornStarBoobs++>><</if>>
		<<if $slaves[_i].pornTypeDom > 0>><<set $pornStarDoms++>><</if>>
		<<if $slaves[_i].pornTypeSadist > 0>><<set $pornStarSadists++>><</if>>
		<<if $slaves[_i].pornTypeMasochist > 0>><<set $pornStarMasochists++>><</if>>
		<<if $slaves[_i].pornTypePregnancy > 0>><<set $pornStarPregnancySluts++>><</if>>
	<</if>>
<</for>>
<<set $averageTrust = $averageTrust/_slavesContributing>>
<<set $averageDevotion = $averageDevotion/_slavesContributing>>
<<set $enduringTrust = ($averageTrust+($enduringTrust*3))/4>>
<<set $enduringDevotion = ($averageDevotion+($enduringDevotion*3))/4>>

<<if (_OldHG != -1) && (_NewHG != -1)>>
	<<= removeJob($slaves[_NewHG], "live with your Head Girl")>>
	<<= assignJob($slaves[_OldHG], "live with your Head Girl")>>
	<<set $HeadGirl = $slaves[_NewHG], $slaves[_NewHG].assignment = "be your Head Girl", $slaves[_NewHG].diet = "healthy">>
<</if>>

<<if WombBirthReady($PC, 38) > 0 && random(1,100) > 50>>
	<<set $PC.labor = 1>>
<<elseif WombBirthReady($PC, 43) > 0>>
	<<set $PC.labor = 1>>
<</if>>

<<set _toSearch = $PC.refreshment.toLowerCase()>>
<<if _toSearch.indexOf("fertility") != -1>>
	<<set $PC.forcedFertDrugs = 1>>
<<elseif $PC.forcedFertDrugs > 0>>
	<<set $PC.forcedFertDrugs-->>
<</if>>

<<if $FCTVreceiver == 1>>
	<<set $FCTVcount += 1>>
	<<if $FCTVcount >= $FCTVrate && $FCTVrate != -1>>
		<<set $FCTVcount = 0>>
		<<set $FCTVshow = 1>>
	<</if>>
<</if>>

<<if $week == $oldWeek>>
	<<set $week += 1, $day += 7>>
	<<switch $month>>
	<<case "January">>
	<<if $day > 31>>
		<<set $day -= 31, $month = "February">>
	<</if>>
	<<case "February">>
	<<if $day > 28>>
		<<set $day -= 28, $month = "March">>
	<</if>>
	<<case "March">>
	<<if $day > 31>>
		<<set $day -= 31, $month = "April">>
	<</if>>
	<<case "April">>
	<<if $day > 30>>
		<<set $day -= 30, $month = "May">>
	<</if>>
	<<case "May">>
	<<if $day > 31>>
		<<set $day -= 31, $month = "June">>
	<</if>>
	<<case "June">>
	<<if $day > 30>>
		<<set $day -= 30, $month = "July">>
	<</if>>
	<<case "July">>
	<<if $day > 31>>
		<<set $day -= 31, $month = "August">>
	<</if>>
	<<case "August">>
	<<if $day > 31>>
		<<set $day -= 31, $month = "September">>
	<</if>>
	<<case "September">>
	<<if $day > 30>>
		<<set $day -= 30, $month = "October">>
	<</if>>
	<<case "October">>
	<<if $day > 31>>
		<<set $day -= 31, $month = "November">>
	<</if>>
	<<case "November">>
	<<if $day > 30>>
		<<set $day -= 30, $month = "December">>
	<</if>>
	<<default>>
	<<if $day > 31>>
		<<set $day -= 31, $month = "January", $year += 1>>
	<</if>>
	<</switch>>
<</if>>

<<if $playerSurgery > 0>>
	<<set $playerSurgery-->>
<</if>>

<<if $foughtThisWeek == 1>>
	<<set $foughtThisWeek = 0>>
<</if>>

<<if $sentUnitCooldown > 0>>
	<<set $sentUnitCooldown-->>
<</if>>

<<if $proclamationsCooldown > 0>>
	<<set $proclamationsCooldown-->>
<</if>>

<<set _seed = random(1,10)>>
<<if $week < 25>>
	<<if _seed > 4>>
		<<set $weatherToday = $niceWeather.random()>>
	<<else>>
		<<set $weatherToday = $lightWeather.random()>>
	<</if>>
<<elseif $week < 50>>
	<<if _seed > 4>>
		<<set $weatherToday = $niceWeather.random()>>
	<<elseif _seed > 2>>
		<<set $weatherToday = $lightWeather.random()>>
	<<else>>
		<<set $weatherToday = $heavyWeather.random()>>
	<</if>>
<<elseif $week < 75>>
	<<if _seed > 6>>
		<<set $weatherToday = $niceWeather.random()>>
	<<elseif _seed > 3>>
		<<set $weatherToday = $lightWeather.random()>>
	<<else>>
		<<set $weatherToday = $heavyWeather.random()>>
	<</if>>
<<else>>
	<<if _seed > 8>>
		<<set $weatherToday = $niceWeather.random()>>
	<<elseif _seed > 6>>
		<<set $weatherToday = $lightWeather.random()>>
	<<elseif _seed > 2>>
		<<set $weatherToday = $heavyWeather.random()>>
	<<else>>
		<<set $weatherToday = $extremeWeather.random()>>
	<</if>>
<</if>>

<<if $boomerangWeeks>><<set $boomerangWeeks++>><<else>><<set $boomerangSlave = 0>><</if>>

<<set $thisWeeksFSWares = $merchantFSWares.randomMany(2)>>
<<set $prisonCircuitIndex++>><<if $prisonCircuitIndex >= $prisonCircuit.length>><<set $prisonCircuitIndex = 0>><</if>>

<<set $coursed = 0, $eventDescription = 0, $pitFought = 0, $preOwnedViewed = 0, $prestigeAuctioned = 0, $eliteAuctioned = 0, $repGain = 0, $shelterSlave = 0, $shelterSlaveBought = 0, $slaveMarketLimit = 10 + ($rep / 1000), $slavesSeen = 0, $slavesSacrificedThisWeek = 0, $subSlaves = 0>>

/% These are variables that either should be made into _temp vars or should be Zeroed out once done with them instead of here. This can also interfere with debugging or hide NaN's as zeroing things out would clear a NaN. Also could stop from NaN's getting worse? %/
/% Integer and float variables. No real need to zero them out but doesn't hurt to have them in a known state, though this might mask variables NaN'ing out. Takes up the least amount of Memory besides a "" string. %/
<<set $averageProsperity = 0, $beauty = 0, $beautyMultiplier = 0, $boobsID = -1, $boobsInterestTargetID = -1, $brideSlave = -1, $buttslutID = -1, $buttslutInterestTargetID = -1, $cumslutID = -1, $FResult = 0, $groomSlave = -1, $humiliationID = -1, $humiliationInterestTargetID = -1, $i = 0, $individualCosts = 0, $influenceBonus = 0, $j = 0, $masochistID = -1, $masochistInterestTargetID = -1, $opinion = 0, $r = 0, $subID = -1, $submissiveInterestTargetID = -1, $weddingSlaveID = -1, $x = 0, $mother = -1, $daughter = -1, $devMother = -1, $devDaughter = -1, $alphaTwin = -1, $betaTwin = -1, $youngerSister = -1, $olderSister = -1, $recruiterSlave = -1>>

/% Other arrays %/
<<set $events = [], $RESSevent = [], $RESSTRevent = [], $RETSevent = [], $RECIevent = [], $RecETSevent = [], $REFIevent = [], $REFSevent = [], $PESSevent = [], $PETSevent = [], $FSAcquisitionEvents = [], $FSNonconformistEvents = [], $qualifiedNicknames = [], $REAnalCowgirlSubIDs = [], $REButtholeCheckinIDs = [], $recruit = [], $RETasteTestSubIDs = [], $devotedSlaves = [], $rebelSlaves = [], $REBoobCollisionSubIDs = [], $REIfYouEnjoyItSubIDs = [], $RESadisticDescriptionSubIDs = [], $REShowerForceSubIDs = [], $RESimpleAssaultIDs = [], $RECockmilkInterceptionIDs = [], $REInterslaveBeggingIDs = [], $bedSlaves = [], $qualifiedFS = [], $eligibleSlaves = [], $slavesInLine = []>>

/% Slave Objects using 0 instead of null. Second most memory eaten up. %/
<<set $activeSlave = 0, $eventSlave = 0, $slaveWithoutBonuses = 0, $subSlave = 0, $milkTap = 0, $relation = 0>>

/% Slave Objects that never get zeroed so null them here. Second most memory eaten up. %/
<<set $beforeGingering = null, $sibling = null>>

/% Strings Memory varies. %/
<<set $analSkinDesc = "", $applyDesc = "", $bellyAccessory = "", $buyer = "", $desc = "", $event = "", $goto = "", $malefactor = "", $nickname = "", $notApplyDesc = "", $oldName = "", $oldSurname = "", $situationDesc = "", $skinDesc = "", $k = "">>
/% Done with zeroing out, what should be for the most part Temps %/

<<run clearSummaryCache()>>

/*HACKY EVENT WORKAROUNDS*/
<<if $eventID != -1>>
	<<set $slaves[$eventID].devotion -= 50, $eventID = -1>>
<</if>>

<<if $autosave != 0>>
	<<script>>Save.autosave.save("Week Start Autosave")<</script>>
<</if>>

<<if $SF.Toggle && $SF.Active >= 1 && $SFTradeShow.CanAttend > -1 && $SFTradeShow.CanAttend > -2>>
	<<set $SFTradeShow.CanAttend = -1>>
<</if>>
<<set $NaNArray = findNaN()>>
<<goto "Main">>
