code:
:: overlayReplace [widget]

<<widget "overlayReplace">>
	<<if $args[0]>>
		<<if $currentOverlay isnot $args[0]>>
			<<set $currentOverlay to $args[0]>>
			<<run $(".customOverlay").attr("data-overlay",$currentOverlay)>>
			<<switch $args[0]>>
			<<case "characteristics">>
				<<replace #customOverlayTitle>><<OverlayTitle "colorCodes">><</replace>>
				<<replace #customOverlayContent>><<characteristics>><</replace>>
			<<case "traits">>
				<<replace #customOverlayTitle>><<OverlayTitle>><</replace>>
				<<replace #customOverlayContent>><<traits>><</replace>>
			<<case "social">>
				<<replace #customOverlayTitle>><<OverlayTitle "colorCodes">><</replace>>
				<<replace #customOverlayContent>><<social>><</replace>>
			<<case "journal">>
				<<replace #customOverlayTitle>><<OverlayTitle>><</replace>>
				<<replace #customOverlayContent>><<journal>><</replace>>
			<<case "statistics">>
				<<replace #customOverlayTitle>><<OverlayTitle "statistics">><</replace>>
				<<replace #customOverlayContent>><<statistics>><</replace>>
			<<case "extraStatistics">>
				<<replace #customOverlayTitle>><<OverlayTitle "extraStatistics">><</replace>>
				<<replace #customOverlayContent>><<extraStatistics>><</replace>>
			<<case "extraStatisticsWarning">>
				<<replace #customOverlayTitle>><<OverlayTitle "extraStatisticsWarning">><</replace>>
				<<replace #customOverlayContent>><<extraStatisticsWarning>><</replace>>
			<<case "gameFeats">>
				<<replace #customOverlayTitle>><<OverlayTitle "feats">><</replace>>
				<<replace #customOverlayContent>><<feats>><</replace>>
			<<case "startFeats">>
				<<replace #customOverlayTitle>><<OverlayTitle>><</replace>>
				<<replace #customOverlayContent>><<feats>><</replace>>
			<<case "options">>
				<<replace #customOverlayTitle>><<OverlayTitle "options">><</replace>>
				<<replace #customOverlayContent>><<options>><</replace>>
			<<case "saves">>
				<<replace #customOverlayTitle>><<OverlayTitle "saves">><</replace>>
				<<replace #customOverlayContent>>

Saves

						<<saveList>>

				<</replace>>
			<<case "optionsExportImport">>
				<<replace #customOverlayTitle>><<OverlayTitle "optionsExportImport">><</replace>>
				<<replace #customOverlayContent>><<optionsExportImport>><</replace>>
			<<case "cheats">>
				<<replace #customOverlayTitle>><<OverlayTitle "cheats">><</replace>>
				<<replace #customOverlayContent>><<cheats>><</replace>>
			<<case "canvasLayers">>
				<<replace #customOverlayTitle>><<OverlayTitle "canvasLayers">><</replace>>
				<<replace #customOverlayContent>><<canvasLayersEditor>><</replace>>
			<<case "canvasColours">>
				<<replace #customOverlayTitle>><<OverlayTitle "canvasColours">><</replace>>
				<<replace #customOverlayContent>><<canvasColoursEditor `$cheatdisable is "f"`>><</replace>>
			<<case "canvasModel">>
				<<replace #customOverlayTitle>><<OverlayTitle "canvasModel">><</replace>>
				<<replace #customOverlayContent>><<canvasModelEditor>><</replace>>
			<<case "blackjackHelp">>
				<<replace #customOverlayTitle>><<OverlayTitle>><</replace>>
				<<replace #customOverlayContent>><<blackjackHelp>><</replace>>
			<<case "eventExtraInfo">>
				<<replace #customOverlayTitle>><<OverlayTitle>><</replace>>
				<<replace #customOverlayContent>><<eventExtraInfo>><</replace>>
			<<case "outfitEditor">>
				<<replace #customOverlayTitle>><<OverlayTitle>><</replace>>
				<<replace #customOverlayContent>><<outfitEditor>><</replace>>
			<</switch>>
			<<removeclass "#customOverlay" "hidden">>
			<<run document.getElementById("customOverlay").scrollTop = 0>>
		<<else>>
			<<set $currentOverlay to null>>
			<<addclass "#customOverlay" "hidden">>
		<</if>>
	<</if>>
<</widget>>

<<widget "OverlayTitle">>
<<button Close>>
	<<addclass "#customOverlay" "hidden">>
	<<set $currentOverlay to null>>
<</button>>
<<if $args[0] is "saves">>
	<<button "Export/Import Save">>
		<<overlayReplace "optionsExportImport">>
		<<set $currentOverlay to null>>
	<</button>>
<</if>>
<<if $args[0] is "optionsExportImport">>
	<<button "Return to Options">>
		<<overlayReplace "saves">>
		<<set $currentOverlay to "saves">>
	<</button>>
<</if>>
<<if $args[0] is "statistics">>
	<<button "Extra Stats (Spoilers)">>
		<<if $skipStatisticsConfirmation>>
			<<overlayReplace "extraStatistics">>
		<<else>>
			<<overlayReplace "extraStatisticsWarning">>
		<</if>>
		<<set $currentOverlay to null>>
	<</button>>
<</if>>
<<if $args[0] is "extraStatistics">>
	<<button "Statistics">>
		<<overlayReplace "statistics">>
		<<set $currentOverlay to null>>
	<</button>>
<</if>>
<<if $args[0] is "colorCodes">>
	<<button "Colour Codes">>
		<>
	<</button>>

		Excellent

		Good

		Decent

		Okay

		Poor

		Bad

		Terrible

<</if>>
<<if $args[0] && $args[0].indexOf("canvas") == 0>>
	<<if $args[0] is not "canvasLayers">>
		<<button "Layers">>
			<<overlayReplace "canvasLayers">>
		<</button>>
	<<else>>

Layers

	<</if>>
	<<if $args[0] is not "canvasColours">>
		<<button "Colours">>
			<<overlayReplace "canvasColours">>
		<</button>>
	<<else>>

Colours

	<</if>>
	<<if $args[0] is not "canvasModel">>
		<<button "Model">>
			<<overlayReplace "canvasModel">>
		<</button>>
	<<else>>

Model

	<</if>>

	<<if Renderer.lastAnimation>>
		<<button "Start/stop animation">>
			<>
		<</button>>
	<</if>>
	<<button "Refresh caches">>
		<>
	<</button>>

	<>
<</if>>

<</widget>>


code:
:: Widgets Parasites [widget]
<<widget "parasiteinit">>

<<set $parasite to {}>>
<<set $parasite.bodyparts to [
	"nipples",
	"bottom",
	"penis",
	"balls",
	"clit",
	"anus",
	"vagina",
	"labia",
	"left_thigh",
	"right_thigh",
	"left_foot",
	"right_foot",
	"left_arm",
	"right_arm",
	"left_hand",
	"right_hand",
	"tummy",
	"back",
	"face",
	"mouth",
	"left_ear",
	"right_ear",
	"hair"]>>
<<set $parasite.types to [
	"urchin",
	"slime",
	"maggot"]>>

<<for _part range $parasite.bodyparts>>
	<<set $parasite[_part] to {}>>
	/*<<set $parasite[_part].bodypart to _part.replace(/_/g, " ")>>*/
<</for>>

<<for _type range $parasite.types>>
	<<set $parasite[_type] to []>> /*This seems a bit redundant but not having to iterate through every body part every time StoryCaption updates seems worth it*/
<</for>>
<</widget>>

<<widget "parasite">>
/*First argument is the body part you want to attach a parasite to, second argument is the type of parasite*/
<<if $args[0] and $args[1]>>
	<<set _temp0 to $args[0]>>
	<<set _temp1 to $args[1]>>

	<<set $parasite[_temp0].name to _temp1>>
	<<set $parasitestat += 1>>

	<<if _temp0 isnot "left_ear" and _temp0 isnot "right_ear">> /*Keeps ears from 'sucking and massaging' in the StoryCaption*/
		<<set _temp0 to _temp0.replace(/_/g, " ")>>/*Replaces underscores with spaces to make sidebar description more presentable.*/
		<<set $parasite[_temp1].push(_temp0)>>
	<</if>>
<</if>>
<</widget>>

<<widget "removeparasite">>
/*Argument is the body part you want to free from parasites*/
<<if $args[0]>>
	<<set _temp0 to $args[0]>>

	<<run delete $parasite[_temp0].name>>

	<<set _temp0 to _temp0.replace(/_/g, " ")>>/*Removes underscores from argument to match with the change made in the <<parasite>> widget.*/
	<<for _type range $parasite.types>>
		<<set $parasite[_type].delete(_temp0)>>
	<</for>>
	<<if $parasite.left_ear.name isnot "slime" and $parasite.right_ear.name isnot "slime">>
		<<set $corruption_slime to 0>>
	<</if>>
<</if>>
<</widget>>

repo_name: Area/degrees

license: mit


code:
:: Widgets Persistent NPCs [widget]
/*For saving generic NPC data so they can be loaded later*/
<<widget "saveNPC">>
/*First argument is the NPClist index of the NPC to be saved. Second argument is the string you want to save it under.*/
<<if $args[0] gte 0 and $args[1]>>
	<<set _temp1 to $args[1]>>
	<<set _temp0 to $args[0]>>
	<<set $per_npc[_temp1] to clone($NPCList[_temp0])>>
	/*Clears name from name pool */
	<<if $NPCList[$args[0]].pronoun is "f">>
		<<set $NPC_names_f.delete($NPCList[$args[0]].name)>>
	<<else>>
		<<set $NPC_names_m.delete($NPCList[$args[0]].name)>>
	<</if>>
<</if>>
<</widget>>

<<widget "loadNPC">>
<!-- Checks if endevent was properly used after the last event -->
<<checkEventNPC $args[0]>>
/*First argument is the NPClist you want the NPC to fill. Second argument is the string you want to load, as saved with saveNPC.*/
<<if $args[0] gte 0 and $args[1]>>
	<<set _temp1 to $args[1]>>
	<<set _temp0 to $args[0]>>
	<<set $NPCList[_temp0] to clone($per_npc[_temp1])>>
	<<if $enemyno lt 6>><<set $enemyno += 1>><</if>>
	<<if $NPCList[_temp0].monster is "monster">>
		<<set $monster to 1>>
	<<else>>
		<<set $monster to 0>>
	<</if>>
	<<run EventSystem.Push($passage, $args[0], $time)>>
<</if>>
<</widget>>

<<widget "clearNPC">>
/*Clears persistent NPC data for a single NPC. Argument is the string the NPC was saved under.*/
<<if $args[0]>>
	<<set _temp0 to $args[0]>>
	/*Adds name back into name pool */
	<<if $per_npc[_temp0].name>>
		<<if $per_npc[_temp0].pronoun is "f">>
			<<set $NPC_names_f.pushUnique($per_npc[_temp0].name)>>
		<<else>>
			<<set $NPC_names_m.pushUnique($per_npc[_temp0].name)>>
		<</if>>
	<</if>>
	<<run delete $per_npc[_temp0]>>
<</if>>
<</widget>>

<<widget "updatePersistentNPCs">>
<<if $passage isnot "start" and $per_npc and Object.keys($per_npc).length gt 0>>
	<<for $_i, $_value range $per_npc>>
		<!-- Set Pronoun -->
		<<if $per_npc[$_i].pronoun is "none" or $args[0] is "genders">>
			<<if $malechance lt random(1, 100)>>
				<<set $per_npc[$_i].pronoun to "f">><<set $test to $per_npc[$_i].pronoun>>
			<<else>>
				<<set $per_npc[$_i].pronoun to "m">>
			<</if>>
		<</if>>
		<!-- Set Gender -->
		<<if $per_npc[$_i].gender is "none" or $args[0] is "genders">>
			<<if $per_npc[$_i].pronoun is "m">>
				<<if random(0, 99) gte $cbchance>>
					<<set $per_npc[$_i].gender to "m">>
				<<else>>
					<<set $per_npc[$_i].gender to "f">>
				<</if>>
			<<elseif $per_npc[$_i].pronoun is "f">>
				<<if random(0, 99) gte $dgchance>>
					<<set $per_npc[$_i].gender to "f">>
				<<else>>
					<<set $per_npc[$_i].gender to "m">>
				<</if>>
			<</if>>
		<</if>>

		<!-- Set Genital Existence -->
		<<if $per_npc[$_i].type isnot "human">>
			<<set $per_npc[$_i].penis to  ($per_npc[$_i].gender !== "f" ? 0 : "none")>>
			<<set $per_npc[$_i].vagina to ($per_npc[$_i].gender !== "m" ? 0 : "none")>>
		<<else>>
			<<set $per_npc[$_i].penis to  ($per_npc[$_i].gender !== "f" ? "clothed" : "none")>>
			<<set $per_npc[$_i].vagina to ($per_npc[$_i].gender !== "m" ? "clothed" : "none")>>
		<</if>>

		<!-- Set breast defaults-->

		<<set _b_mod_lower to Math.clamp($breast_mod, 0, 12)>>
		<<set _b_mod_upper to Math.clamp($breast_mod + 12, 0, 12)>>

		<!-- can't use breastsize, since that would either break the numberslider
		or make one of the sizes always be randomized,
		but can use breastdesc not being changed from 0 as a substitute -->
		<<if $per_npc[$_i].breastdesc is 0 or $args[0] is "breasts">>
			<<if $per_npc[$_i].pronoun is "m">>
				<<set $per_npc[$_i].breastsize to 0>>
			<<else>>
				<<set $per_npc[$_i].breastsize to random (_b_mod_lower, _b_mod_upper)>>
			<</if>>
		<</if>>
		<<if $per_npc[$_i].breastsize gt 0>>
			<<set _brdes to ["nipple","budding","tiny","small","pert","modest","full","large","ample","massive","huge","gigantic","enormous"]>>
			<<set $per_npc[$_i].breastdesc to _brdes[$per_npc[$_i].breastsize]+" breast">>
		<<else>>
			<<set $per_npc[$_i].breastdesc to "nipple">>
		<</if>>
		<<set $per_npc[$_i].breastsdesc to $per_npc[$_i].breastdesc + "s">>

		<!-- Set pp to defaults-->

		/* New way to set upper and lower bounds.
		* This method makes use of all other slider positions, but does nothing when slider is between -1 and 1,
		* for a total of 15 unique positions vs the current method's 9. (max would be 17)
		* Changing the penis_mod slider to range from -7 to 7 would work to make every slider position unique here, but potentially affects unnamed npc generation.
		*/

		/*
		<<set _p_mod_upper to 8>><<set _p_mod_lower to 1>>
		<<if $penis_mod gt 0>>
			<<set _p_mod_lower += $penis_mod - 1>>
		<<elseif $penis_mod lt 0>>
			<<set _p_mod_upper += $penis_mod + 1>>
		<</if>>

		alternative way to write that:
		<<set _p_mod_lower to ($penis_mod > 0 ? $penis_mod : 1)>>
		<<set _p_mod_upper to ($penis_mod < 0 ? 9 + $penis_mod : 8)>>
		*/

		<<if $penis_mod is 8>>
			<<set _p_mod_upper to 8>><<set _p_mod_lower to 8>>
		<<elseif $penis_mod gte 6>>
			<<set _p_mod_upper to 8>><<set _p_mod_lower to 7>>
		<<elseif $penis_mod gte 4>>
			<<set _p_mod_upper to 8>><<set _p_mod_lower to 5>>
		<<elseif $penis_mod gte 2>>
			<<set _p_mod_upper to 8>><<set _p_mod_lower to 3>>
		<<elseif $penis_mod gte 0>>
			<<set _p_mod_upper to 8>><<set _p_mod_lower to 1>>
		<<elseif $penis_mod gte -2>>
			<<set _p_mod_upper to 7>><<set _p_mod_lower to 1>>
		<<elseif $penis_mod gte -4>>
			<<set _p_mod_upper to 5>><<set _p_mod_lower to 1>>
		<<elseif $penis_mod gte -6>>
			<<set _p_mod_upper to 3>><<set _p_mod_lower to 1>>
		<<else>>
			<<set _p_mod_upper to 1>><<set _p_mod_lower to 1>>
		<</if>>

		<<if $per_npc[$_i].penissize is 0 or $args[0] is "penis">>
			<<if $per_npc[$_i].gender is "f">>
				<<set $per_npc[$_i].penissize to 0>>
				<<set $per_npc[$_i].penisdesc to "none">>
			<<else>>
				<<switch random (_p_mod_lower, _p_mod_upper)>>
				<<case 8>>
					<<set $per_npc[$_i].penisdesc to either("massive cock","huge cock","humongous cock","immense cock","gigantic cock","enormous cock")>>
					<<set $per_npc[$_i].penissize to 4>>
				<<case 5 6 7>>
					<<set $per_npc[$_i].penisdesc to either("thick cock","hefty cock","big cock","large cock","veiny cock","meaty cock")>>
					<<set $per_npc[$_i].penissize to 3>>
				<<case 2 3 4>>
					<<set $per_npc[$_i].penisdesc to "penis">>
					<<set $per_npc[$_i].penissize to 2>>
				<<default>>
					<<set $per_npc[$_i].penisdesc to either("tiny penis","pathetic cock","little penis","small penis","mini penis","micro penis")>>
					<<set $per_npc[$_i].penissize to 1>>
				<</switch>>
			<</if>>
		<</if>>
		<!-- Set pp to size in case PC selected it-->
		<<if $per_npc[$_i].penissize isnot 0>>
			<<switch $per_npc[$_i].penissize>>
			<<case 4>>
				<<set $per_npc[$_i].penisdesc to either("massive cock","huge cock","humongous cock","immense cock","gigantic cock","enormous cock")>>
			<<case 3>>
				<<set $per_npc[$_i].penisdesc to either("thick cock","hefty cock","big cock","large cock","veiny cock","meaty cock")>>
			<<case 1>>
				<<set $per_npc[$_i].penisdesc to either("tiny penis","pathetic cock","little penis","small penis","mini penis","micro penis")>>
			<<default>>
				<<set $per_npc[$_i].penisdesc to "penis">>
			<</switch>>
		<</if>>
		<<generatePronouns $per_npc[$_i]>>
	<</for>>
<</if>>
<</widget>>

<<widget "updateNPCsFirst">>/*Adds new variables to saved NPCs.*/
<<for _per_keys range Object.keys($per_npc)>>
	<<set $per_npc[_per_keys][$args[0]] to $args[1]>>
<</for>>
<</widget>>

<<widget "updateNPCsSecond">>
<<for _per_keys range Object.keys($per_npc)>>
	<<set $per_npc[_per_keys][$args[0]][$args[1]] to $args[2]>>
<</for>>
<</widget>>


code:
:: Widgets physicalAdjustmentsInit [widget]
<<widget "physicalAdjustmentsInit">>

<<if $sexStats is undefined>>
	<<set $sexStats to {
		"breasts": {
			"playedWith": 0
		},
		"creampie": {
			"self": {
				"anus":0,
				"mouth":0,
				"vagina":0
			},
			"npc":{
				"anus":0,
				"mouth":0,
				"vagina":0,
				"tentacle":0
			}
		},
		"pills":{
			"type": ["penis", "breast", "bottom"],
			"penis": {
				"type": null,
				"doseTaken": null,
				"autoTake": null,
				"overdose": {
					"growth":0,
					"reduction":0},
				"owned": {
					"growth": 0,
					"reduction": 0,
					"blocker": 0,
				}
			},
			"breast": {
				"type": null,
				"doseTaken": null,
				"autoTake": null,
				"overdose": {},
				"owned": {
					"growth": 0,
					"reduction": 0,
					"blocker": 0,
				}
			},
			"bottom": {
				"type": null,
				"doseTaken": null,
				"autoTake": null,
				"overdose": {},
				"owned": {
					"growth": 0,
					"reduction": 0,
					"blocker": 0,
				}
			},
			"boughtOnce": false,
		}
	}>>
<</if>>

<<if $sexStats.anus is undefined>>
	<<set $sexStats.anus to {
		"pregnancy": {
			0: null,
			1: null,
			2: null,
			3: null,
			"count": 0,
			"maxCount": 1,
			"fertile": false,
			"fertilised": false,
			"lowestDaysLeft": null,
			"lowestTimeLeft": null,
			"givenBirth": 0,
			"motherStatus": 0,
			"seenDoctor": 0,
			"feltMovement": false,
			"namesChildren": false,
			"autoRepairDone":1,
		}
	}>>
<</if>>

<<if $sexStats.pills.type is undefined or $sexStats.pills.type.length lt 3>>
	<<set _quantity to [0,0,0,0,0,0,0,0,0]>>
	<<if $sexStats.pills.breastOwned isnot undefined and $sexStats.pills.boughtOnce is true>>
		<<set _quantity[0] to Math.floor($sexStats.pills.penisOwned[5] + ($sexStats.pills.penisOwned[4] / 2))>>
		<<set _quantity[1] to Math.floor($sexStats.pills.penisOwned[0] + ($sexStats.pills.penisOwned[1] / 2))>>
		<<set _quantity[2] to clone($sexStats.pills.penisOwned[2])>>
		<<set _quantity[3] to Math.floor($sexStats.pills.breastOwned[5] + ($sexStats.pills.breastOwned[4] / 2))>>
		<<set _quantity[4] to Math.floor($sexStats.pills.breastOwned[0] + ($sexStats.pills.breastOwned[1] / 2))>>
		<<set _quantity[5] to clone($sexStats.pills.breastOwned[2])>>
	<<elseif $sexStats.pills.breast isnot undefined and $sexStats.pills.boughtOnce is true>>
		<<set _quantity[0] to clone($sexStats.pills.penis.owned.growth)>>
		<<set _quantity[1] to clone($sexStats.pills.penis.owned.reduction)>>
		<<set _quantity[2] to clone($sexStats.pills.penis.owned.blocker)>>
		<<set _quantity[3] to clone($sexStats.pills.breast.owned.growth)>>
		<<set _quantity[4] to clone($sexStats.pills.breast.owned.reduction)>>
		<<set _quantity[5] to clone($sexStats.pills.breast.owned.blocker)>>
	<</if>>
	<<if $sexStats.pills.boughtOnce is true>>
		<<set _boughtOnce to true>>
	<<else>>
		<<set _boughtOnce to false>>
	<</if>>

	<<set $sexStats.pills to {
		"type": ["penis", "breast", "bottom"],
		"penis": {
			"type": null,
			"doseTaken": null,
			"autoTake": null,
			"overdose": {
				"growth":0,
				"reduction":0
			},
			"owned": {
				"growth": clone(_quantity[0]),
				"reduction": clone(_quantity[1]),
				"blocker": clone(_quantity[2]),
			}
		},
		"breast": {
			"type": null,
			"doseTaken": null,
			"autoTake": null,
			"overdose": {},
			"owned": {
				"growth": clone(_quantity[3]),
				"reduction": clone(_quantity[4]),
				"blocker": clone(_quantity[5]),
			}
		},
		"bottom": {
			"type": null,
			"doseTaken": null,
			"autoTake": null,
			"overdose": {},
			"owned": {
				"growth": clone(_quantity[6]),
				"reduction": clone(_quantity[7]),
				"blocker": clone(_quantity[8]),
			}
		},
		"boughtOnce": _boughtOnce
	}>>
<</if>>
<<if $sexStats.pills.pregnancy is undefined>>
	<<set $sexStats.pills.pregnancy to {
			"type": null,
			"doseTaken": null,
			"autoTake": null,
			"overdose": false,
			"owned": {
				"fertility": 0,
				"contraceptive": 0,
			}
	}>>
	<<run $sexStats.pills.type.pushUnique("pregnancy")>>
<</if>>
<<if $sexStats.pills.penis.overdose is false>>
	<<set $sexStats.pills.penis.overdose to {
		"growth":0,
		"reduction":0
	}>>
<</if>>
<<set _pills to $sexStats.pills>>
<<set _pills.penis.owned.growth to Math.clamp(_pills.penis.owned.growth, 0, 1000)>>
<<set _pills.penis.owned.reduction to Math.clamp(_pills.penis.owned.reduction, 0, 1000)>>
<<set _pills.penis.owned.blocker to Math.clamp(_pills.penis.owned.blocker, 0, 1000)>>
<<set _pills.breast.owned.growth to Math.clamp(_pills.breast.owned.growth, 0, 1000)>>
<<set _pills.breast.owned.reduction to Math.clamp(_pills.breast.owned.reduction, 0, 1000)>>
<<set _pills.breast.owned.blocker to Math.clamp(_pills.breast.owned.blocker, 0, 1000)>>
<<set _pills.bottom.owned.growth to Math.clamp(_pills.bottom.owned.growth, 0, 1000)>>
<<set _pills.bottom.owned.reduction to Math.clamp(_pills.bottom.owned.reduction, 0, 1000)>>
<<set _pills.bottom.owned.blocker to Math.clamp(_pills.bottom.owned.blocker, 0, 1000)>>
<<set _pills.pregnancy.owned.fertility to Math.clamp(_pills.pregnancy.owned.fertility, 0, 1000)>>
<<set _pills.pregnancy.owned.contraceptive to Math.clamp(_pills.pregnancy.owned.contraceptive, 0, 1000)>>

<<if $sexStats.vagina is undefined>>
	<<set _baseDays to random(24,38)>>
	<<if _baseDays lt 26>>
		<<set _baseDaysRng to random(0,4)>>
	<<elseif _baseDays gte 30>>
		<<set _baseDaysRng to random(-4,0)>>
	<<else>>
		<<set _baseDaysRng to random(-2,2)>>
	<</if>>
	/*To change after every cycle*/
	<<set _currentDaysMax to _baseDays + random(0, _baseDaysRng)>>
	/*
		- pregnancy has multiple slots, but pregnancy should only occur when none are taken
		- "baseDays", "baseDaysRng", "lastDaysMax", "currentDaysMax" values should not be changed by multipliers, but by percent if you want a faster/slower cycle during calculations only, do not modifier the values themselves
		- Sperm Template -
		"sperm":{
			"Robin":{"type":"npc", "count":[[daysTillRemoval,cummed inside],[4,3],[3,2]]},
			"Avery":{"type":"npc", "count":[[daysTillRemoval,cummed inside],[5,1]]},
			"slender man":{"type":"npc", "count":[[daysTillRemoval,cummed inside],[5,1]]},
			"Beast":{"type":"dog", "count":[[daysTillRemoval,cummed inside],[5,1]]},
		}
		- Sperm data should be deleted after 3-5 days worth of the base, the entire named object after it is cleared.
		- "CurrentDay" should never be above "lastDaysMax" or "currentDaysMax", "lastDaysMax" should be set to "currentDaysMax" on releasing the egg
		- "recoveryTime" and "recoveryTimeStart" are to track how long the player needs to recover before they can get pregnant again. "recoveryTime" is reduced faster by taking fertility pills and when "totalBirthEvents" is more than 2.
		- "recoveryStage" ranges from 0 to 4, to help with any story text regarding how the player is feeling after giving birth
		- "periodEnabled" is only to prevent the first period based events after recovering from giving birth
	*/
	<<set $sexStats.vagina to {
		"pregnancy": {
			0: null,
			1: null,
			2: null,
			3: null,
			4: null,
			5: null,
			6: null,
			7: null,
			"currentCount": 0,
			"givenBirth": 0,
			"totalBirthEvents": 0,
			"motherStatus": 0,
			"beastMotherStatus": 0,
			"morningSicknessWaking":0,
			"morningSicknessGeneral":0,
			"waterBreaking": false,
			"type": null,
			"bellySize": 0,
			"timer": null,
			"timerStart": null,
			"awareOf": null,
			"potentialFathers": [],
			"ultrasoundDone": false,
		},
		"menstruation":{
			"baseDays": _baseDays,
			"baseDaysRng": _baseDaysRng,
			"currentDay": random(0, _baseDays + random(0,_baseDaysRng)),
			"lastDaysMax": _currentDaysMax,
			"currentDaysMax": _currentDaysMax,
			"currentState": "normal",
			"recoveryTime": null,
			"recoveryTimeStart": null,
			"recoveryStage": null,
			"periodEnabled": true,
			"running": false,
			"stages": [0, 0, 0, 0],
		},
		"sperm":{}
	}>>
	<<set _menstruation to $sexStats.vagina.menstruation>>
	<<set _stage2 to Math.round(_menstruation.currentDaysMax * 0.17)>>
	<<if _stage2 gte 4>>
		<<set _stage2-->>
	<</if>>
	<<set _stage3 to Math.round(_menstruation.currentDaysMax * 0.5)>>
	<<if _stage3 lt 13>>
		<<set _stage3++>>
	<<elseif _stage3 gte 18>>
		<<set _stage3-->>
	<</if>>
	<<set _menstruation.stages to [0, _stage2, _stage3, _stage3 + random(1,2) * 0.5]>>

	<<if $player.vaginaExist>>
		<<set $sexStats.vagina.menstruation.running = true>>
	<</if>>
<</if>>
<</widget>>

:: Widgets physicalAdjustments [widget]
<<widget "physicalAdjustments">>

/*Breasts*/
<<switch $sexStats.pills.breast.type>>
	<<case "growth">>
		<<set _breastMulti to 1 + (2.25 * $sexStats.pills.breast.doseTaken)>>
	<<case "reduction">>
		<<set _breastMulti to -1 + (-2.25 * $sexStats.pills.breast.doseTaken)>>
	<<case "blocker">>
		<<set _breastMulti to 0>>
	<<default>>
		<<set _breastMulti to 1>>
<</switch>>

<<if _breastMulti isnot 0>>
	<<switch $player.gender>>
	<<case "m">>
		<<set _breastMulti -= 1>>
	<<case "f" "h">>
		<<set _breastMulti += (Math.clamp($sexStats.creampie.self.vagina * 2, 0, 50) / 100)>>
	<</switch>>

	<<set _breastMulti += (Math.clamp($sexStats.breasts.playedWith, 0, 500) / 250)>>

	<<set _breastMulti += $sexStats.anus.pregnancy.count / 0.5>>

	<<if $purity gte 990>>
		<<set _breastMulti -= 1>>
	<</if>>

	<<if $cow gte 1>>
		<<set _breastMulti += 1>>
	<</if>>

	<<set _purityBoost to (_breastMulti lt 0 ? 1 + ($purity / 1000) : 1 + ((1000 - $purity) / 1000))>>
	<<set $breastgrowthtimer -= _breastMulti * 25 * _purityBoost>>

	<<if $parasite.nipples.name is "urchin">>
		<<set $breastgrowthtimer -= 300>>
	<</if>>
	<<if $parasite.nipples.name is "slime">>
		<<set $breastgrowthtimer += 300>>
	<</if>>

	<<if $breastgrowthtimer lte 0 and $breastsize lt $breastsizemax>>
		<<set $breastsize += 1>>
		<<set $breastgrowthtimer += 700>>
		<<set $breastgrowthmessage to $breastsize>><<set $effectsmessage to 1>>
	<<elseif $breastgrowthtimer gte 1000 and $breastsize gt $breastsizemin>>
		<<set $breastsize -= 1>>
		<<set $breastgrowthtimer -= 700>>
		<<set $breastshrinkmessage to $breastsize>><<set $effectsmessage to 1>>
	<</if>>

	<<set $breastgrowthtimer to Math.clamp($breastgrowthtimer, 0, 1000)>>

<</if>>

/*Penis*/
<<if $sexStats.pills.penis.overdose.growth gt 0>>
	<<set $sexStats.pills.penis.overdose.growth to Math.clamp($sexStats.pills.penis.overdose.growth - 1, 0, 100)>>
<</if>>
<<if $sexStats.pills.penis.overdose.reduction gt 0>>
	<<set $sexStats.pills.penis.overdose.reduction to Math.clamp($sexStats.pills.penis.overdose.reduction - 1, 0, 100)>>
<</if>>

<<switch $sexStats.pills.penis.type>>
	<<case "growth">>
		<<set _penisMulti to 1 + (2.25 * $sexStats.pills.penis.doseTaken)>>
		<<set $sexStats.pills.penis.overdose.growth += $sexStats.pills.penis.doseTaken>>
	<<case "reduction">>
		<<set _penisMulti to -1 + (-2.25 * $sexStats.pills.penis.doseTaken)>>
		<<set $sexStats.pills.penis.overdose.reduction += $sexStats.pills.penis.doseTaken>>
	<<case "blocker">>
		<<set _penisMulti to 0>>
	<<default>>
		<<set _penisMulti to 1>>
<</switch>>
<<if $player.penisExist and _penisMulti isnot 0>>
	<<set _totalReduction to ($sexStats.creampie.self.anus + $sexStats.creampie.self.mouth) * 2>>
	<<set _totalIncrease to ($sexStats.creampie.npc.anus + $sexStats.creampie.npc.mouth + $sexStats.creampie.npc.vagina) * 2>>

	<<if $cow gte 6>>
		<<set _penisMulti += 1>>
	<</if>>

	<<if _penisMulti gt 1>>
		<<set _totalIncrease += 10>>
		<<set _totalIncrease *= _penisMulti>>
	<<elseif _penisMulti lt 0>>
		<<set _totalReduction += 10>>
		<<set _totalReduction *= _penisMulti * -1>>
	<</if>>
	<<set _totalChange to _totalIncrease - _totalReduction>>
	<<set _purityBoost to (_totalChange lt 0 ? 2 + ($purity / 500) : 2 + ((1000 - $purity) / 500))>>
	<<set $penisgrowthtimer -= _purityBoost * _totalChange>>

	<<set $penisgrowthtimer -= $sexStats.pills.penis.overdose.growth>>
	<<set $penisgrowthtimer += $sexStats.pills.penis.overdose.reduction>>

	<<if $penissize lt 0>>
		<<set $penisgrowthtimer -= 50>>
	<</if>>

	<<if $parasite.penis.name is "urchin">>
		<<set $penisgrowthtimer -= 250>>
		<<set $sexStats.pills.penis.overdose.growth += random(1,2)>>
	<</if>>
	<<if $parasite.penis.name is "slime">>
		<<set $penisgrowthtimer += 250>>
		<<set $sexStats.pills.penis.overdose.reduction += random(1,2)>>
	<</if>>
	<<set _overdose to $sexStats.pills.penis.overdose.growth - $sexStats.pills.penis.overdose.reduction>>
	<<if $penisgrowthtimer lte 0 and $penissize lt $penissizemax and $penissize gte -1>>
		<<set $penissize += 1>>
		<<set $penisgrowthtimer += 700>>
		<<set $penisgrowthmessage to $penissize>><<set $effectsmessage to 1>>
	<<elseif $penisgrowthtimer lte -400 and $penissize lt $penissizemax and $penissize is -2 and _overdose gte 20>>
		<<set $penissize += 1>>
		<<set $penisgrowthtimer += 1100>>
		<<set $penisgrowthmessage to $penissize>><<set $effectsmessage to 1>>
	<<elseif $penisgrowthtimer gte 1000 and $penissize gt 0>>
		<<set $penissize -= 1>>
		<<set $penisgrowthtimer -= 700>>
		<<set $penisshrinkmessage to $penissize>><<set $effectsmessage to 1>>
	<<elseif $penisgrowthtimer gte 1200 and $penissize is 0 and $penissize gt $penissizemin>>
		<<set $penissize -= 1>>
		<<set $penisgrowthtimer -= 1000>>
		<<set $penisshrinkmessage to $penissize>><<set $effectsmessage to 1>>
	<<elseif $penisgrowthtimer gte 1500 and $penissize is -1 and $penissize gt $penissizemin and _overdose lte -20>>
		<<set $penissize -= 1>>
		<<set $penisgrowthtimer -= 1300>>
		<<set $penisshrinkmessage to $penissize>><<set $effectsmessage to 1>>
	<</if>>
	<<set $penisgrowthtimer to Math.clamp($penisgrowthtimer, 0, 1000)>>

<</if>>

/*Bottom*/
<<switch $sexStats.pills.bottom.type>>
	<<case "growth">>
		<<set _bottomMulti to 1 + (2.25 * $sexStats.pills.bottom.doseTaken)>>
	<<case "reduction">>
		<<set _bottomMulti to -1 + (-2.25 * $sexStats.pills.bottom.doseTaken)>>
	<<case "blocker">>
		<<set _bottomMulti to 0>>
	<<default>>
		<<set _bottomMulti to 1>>
<</switch>>

<<if _bottomMulti isnot 0>>
	<<set _totalReduction to $workouts /2>>
	<<set _totalIncrease to $sexStats.creampie.self.anus * 2>>

	<<set _bottomMulti += (500 - $purity) / 500>>

	<<if $cow gte 6>>
		<<set _bottomMulti += 1>>
	<</if>>

	<<if _bottomMulti gt 1>>
		<<set _totalIncrease += 10>>
		<<set _totalIncrease *= _bottomMulti>>
	<<elseif _bottomMulti lt 0>>
		<<set _totalReduction += 10>>
		<<set _totalReduction *= _bottomMulti * -1>>
	<</if>>
	<<set _totalChange to _totalIncrease - _totalReduction>>
	<<set _purityBoost to (_totalChange lt 0 ? 2 + ($purity / 500) : 2 + ((1000 - $purity) / 500))>>
	<<set $bottomgrowthtimer -= _purityBoost * _totalChange>>

	<<if $parasite.bottom.name is "urchin">>
		<<set $bottomgrowthtimer -= 300>>
	<</if>>
	<<if $parasite.bottom.name is "slime">>
		<<set $bottomgrowthtimer += 300>>
	<</if>>
	<<if $bottomgrowthtimer lte 0 and $bottomsize lt $bottomsizemax>>
		<<set $bottomsize += 1>>
		<<set $bottomgrowthtimer += 700>>
		<<set $bottomgrowthmessage to $bottomsize>><<set $effectsmessage to 1>>
	<<elseif $bottomgrowthtimer gte 1000 and $bottomsize gt 0>>
		<<set $bottomsize -= 1>>
		<<set $bottomgrowthtimer -= 700>>
		<<set $bottomshrinkmessage to $bottomsize>><<set $effectsmessage to 1>>
	<<elseif $bottomgrowthtimer gte 1200 and $bottomsize lte 0 and $bottomsize gt $bottomsizemin>>
		<<set $bottomsize -= 1>>
		<<set $bottomgrowthtimer -= 1000>>
		<<set $bottomshrinkmessage to $bottomsize>><<set $effectsmessage to 1>>
	<</if>>
	<<set $bottomgrowthtimer to Math.clamp($bottomgrowthtimer, 0, 1000)>>
<</if>>

/*Resetting of values*/

<<set $sexStats.creampie.npc.anus to 0>>
<<set $sexStats.creampie.npc.mouth to 0>>
<<set $sexStats.creampie.npc.vagina to 0>>
<<set $sexStats.creampie.npc.tentacle to 0>>
<<set $sexStats.creampie.self.anus to 0>>
<<set $sexStats.creampie.self.mouth to 0>>
<<set $sexStats.creampie.self.vagina to 0>>
<<set $sexStats.breasts.playedWith to 0>>
<<set $workouts to 0>>

<<set _pills to $sexStats.pills>>
<<if $location is "home" or $location is "alex_cottage" or $location is "cabin">>
	<<for _i to 0; _i lt _pills.type.length; _i++>>
		<<set _type to _pills.type[_i]>>
		<<set _autoTake to _pills[_type].autoTake>>
		<<if _autoTake isnot null and _pills[_type].owned[_autoTake] gt 0>>
			<<set _pills[_type].owned[_autoTake]-->>
			<<set _pills[_type].type to clone(_autoTake)>>
			<<set _pills[_type].doseTaken to 1>>
			<<set $pillsTaken to true>><<set $effectsmessage to 1>>
			<<if _pills[_type].owned[_autoTake] is 0>>
				<<set _pills[_type].autoTake to null>>
				<<set $pillsTakenLast to true>>
			<</if>>
		<<else>>
			<<set _pills[_type].autoTake to null>>
			<<set _pills[_type].type to null>>
			<<set _pills[_type].doseTaken to 0>>
		<</if>>
	<</for>>
<<else>>
	<<set _pills.penis.type to null>>
	<<set _pills.penis.doseTaken to 0>>
	<<set _pills.breast.type to null>>
	<<set _pills.breast.doseTaken to 0>>
	<<set _pills.bottom.type to null>>
	<<set _pills.bottom.doseTaken to 0>>
<</if>>
<</widget>>

/*<<playWithBreasts>>*/
:: Widgets playWithBreasts [widget]
<<widget "playWithBreasts">>
<<if $args[0]>>
	<<set $sexStats.breasts.playedWith += $args[0]>>
<<else>>
	<<set $sexStats.breasts.playedWith++>>
<</if>>
<</widget>>

/*<<creampie "npc" "anus" >> -- <<set $sexStats.creampie.npc.anus++>>*/
/*<<creampie "self" "mouth">> -- <<set $sexStats.creampie.self.mouth++>>*/
:: Widgets creampie [widget]
<<widget "creampie">>
<<if $args[0] and $args[1]>>
	<<set $sexStats.creampie[$args[0]][$args[1]]++>>
<</if>>
<<set $internalejac to 1>>
<</widget>>


code:
:: Widgets Plant Objects [widget]
<<widget "init_plant_objects">>

<<set _plants to {
	red_rose: {
		index: 0,
		name: "red_rose",
		plural: "red roses",
		plant_cost: 400,
		difficulty: 1,
		bed: "earth",
		type: "flower",
		days: 14,
		multiplier: 1,
		special: [],
		season: ["spring","autumn"]
		},

	white_rose: {
		index: 1,
		name: "white_rose",
		plural: "white roses",
		plant_cost: 400,
		difficulty: 1,
		bed: "earth",
		type: "flower",
		days: 14,
		multiplier: 1,
		special: [],
		season: ["spring","autumn"]
		},

	orchid: {
		index: 2,
		name: "orchid",
		plural: "orchids",
		plant_cost: 1000,
		difficulty: 2,
		bed: "earth",
		type: "flower",
		days: 28,
		multiplier: 1,
		special: [],
		season: ["summer"]
		},

	daisy: {
		index: 3,
		name: "daisy",
		plural: "daisies",
		plant_cost: 100,
		difficulty: 1,
		bed: "earth",
		type: "flower",
		days: 7,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn"]
		},

	tulip: {
		index: 4,
		name: "tulip",
		plural: "tulips",
		plant_cost: 200,
		difficulty: 1,
		bed: "earth",
		type: "flower",
		days: 12,
		multiplier: 1,
		special: [],
		season: ["autumn"]
		},

	lotus: {
		index: 5,
		name: "lotus",
		plural: "lotus",
		plant_cost: 300,
		difficulty: 2,
		bed: "water",
		type: "flower",
		days: 5,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	lily: {
		index: 6,
		name: "lily",
		plural: "lilies",
		plant_cost: 200,
		difficulty: 1,
		bed: "earth",
		type: "flower",
		days: 10,
		multiplier: 1,
		special: [],
		season: ["spring","autumn"]
		},

	poppy: {
		index: 7,
		name: "poppy",
		plural: "poppies",
		plant_cost: 200,
		difficulty: 2,
		bed: "earth",
		type: "flower",
		days: 8,
		multiplier: 1,
		special: [],
		season: ["spring","autumn"]
		},

	apple: {
		index: 8,
		name: "apple",
		plural: "apples",
		plant_cost: 50,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 7,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	orange: {
		index: 9,
		name: "orange",
		plural: "oranges",
		plant_cost: 45,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 6,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	banana: {
		index: 10,
		name: "banana",
		plural: "bananas",
		plant_cost: 70,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 9,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	lemon: {
		index: 11,
		name: "lemon",
		plural: "lemons",
		plant_cost: 120,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 12,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	blood_lemon: {
		index: 12,
		name: "blood_lemon",
		plural: "blood lemons",
		plant_cost: 400,
		difficulty: 2,
		bed: "earth",
		type: "fruit",
		days: 20,
		multiplier: 1,
		special: ["aphrodisiac"],
		season: ["spring","summer","autumn","winter"]
		},

	pear: {
		index: 13,
		name: "pear",
		plural: "pears",
		plant_cost: 80,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 10,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	strawberry: {
		index: 14,
		name: "strawberry",
		plural: "strawberries",
		plant_cost: 180,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 14,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	peach: {
		index: 15,
		name: "peach",
		plural: "peaches",
		plant_cost: 65,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 8,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	plum: {
		index: 16,
		name: "plum",
		plural: "plums",
		plant_cost: 80,
		difficulty: 1,
		bed: "earth",
		type: "fruit",
		days: 10,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	mushroom: {
		index: 17,
		name: "mushroom",
		plural: "mushrooms",
		plant_cost: 100,
		difficulty: 1,
		bed: "wood",
		type: "shroom",
		days: 14,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	wolfshroom: {
		index: 18,
		name: "wolfshroom",
		plural: "wolfshrooms",
		plant_cost: 300,
		difficulty: 1,
		bed: "wood",
		type: "shroom",
		days: 21,
		multiplier: 1,
		special: ["aphrodisiac"],
		season: ["spring","summer","autumn","winter"]
		},

	wild_honeycomb: {
		index: 19,
		name: "wild_honeycomb",
		plural: "wild honeycombs",
		plant_cost: 12000,
		difficulty: 3,
		bed: "hive",
		type: "produce",
		days: 7,
		multiplier: 1,
		special: ["large"],
		season: ["spring","summer","autumn","winter"]
		},

	wild_carrot: {
		index: 20,
		name: "wild_carrot",
		plural: "carrots",
		plant_cost: 40,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 10,
		multiplier: 3,
		special: [],
		season: ["spring","summer","autumn"]
		},

	onion: {
		index: 21,
		name: "onion",
		plural: "onions",
		plant_cost: 120,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 12,
		multiplier: 3,
		special: [],
		season: ["spring","autumn"]
		},

	garlic_bulb: {
		index: 22,
		name: "garlic_bulb",
		plural: "garlic bulbs",
		plant_cost: 100,
		difficulty: 2,
		bed: "earth",
		type: "vegetable",
		days: 8,
		multiplier: 3,
		special: [],
		season: ["autumn"]
		},

	potato: {
		index: 23,
		name: "potato",
		plural: "potatoes",
		plant_cost: 20,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 7,
		multiplier: 4,
		special: [],
		season: ["spring","autumn","winter"]
		},

	strange_flower: {
		index: 24,
		name: "strange_flower",
		plural: "strange flowers",
		plant_cost: 1000,
		difficulty: 3,
		bed: "earth",
		type: "flower",
		days: 28,
		multiplier: 1,
		special: ["aphrodisiac"],
		season: ["spring","summer","autumn","winter"]
		},

	truffle: {
		index: 25,
		name: "truffle",
		plural: "truffles",
		plant_cost: 800,
		difficulty: 4,
		bed: "earth",
		type: "shroom",
		days: 28,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	bottle_of_milk: {
		index: 26,
		name: "bottle_of_milk",
		plural: "bottles of milk",
		plant_cost: 100,
		difficulty: 1,
		bed: "cow",
		type: "produce",
		days: 1,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	egg: {
		index: 27,
		name: "egg",
		plural: "eggs",
		plant_cost: 40,
		difficulty: 1,
		bed: "chicken",
		type: "produce",
		days: 1,
		multiplier: 1,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	bottle_of_breast_milk: {
		index: 28,
		name: "bottle_of_breast_milk",
		plural: "bottles of breast milk",
		plant_cost: 3000,
		difficulty: 1,
		bed: "human",
		type: "produce",
		days: 1,
		multiplier: 1,
		special: ["large"],
		season: ["spring","summer","autumn","winter"]
		},

	bottle_of_semen: {
		index: 29,
		name: "bottle_of_semen",
		plural: "bottles of semen",
		plant_cost: 3000,
		difficulty: 1,
		bed: "human",
		type: "produce",
		days: 1,
		multiplier: 1,
		special: ["large"],
		season: ["spring","summer","autumn","winter"]
		},

	cabbage: {
		index: 30,
		name: "cabbage",
		plural: "cabbages",
		plant_cost: 50,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 8,
		multiplier: 3,
		special: [],
		season: ["spring","winter"]
		},

	turnip: {
		index: 31,
		name: "turnip",
		plural: "turnips",
		plant_cost: 80,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 12,
		multiplier: 2,
		special: [],
		season: ["spring","summer","autumn","winter"]
		},

	broccoli: {
		index: 32,
		name: "broccoli",
		plural: "broccoli",
		plant_cost: 50,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 10,
		multiplier: 3,
		special: [],
		season: ["spring","autumn"]
		},

	belladonna: {
		index: 33,
		name: "belladonna",
		plural: "belladonnas",
		plant_cost: 500,
		difficulty: 3,
		bed: "earth",
		type: "flower",
		days: 21,
		multiplier: 1,
		special: ["aphrodisiac"],
		season: ["summer","autumn"]
		},
	tomato: {
		index: 34,
		name: "tomato",
		plural: "tomatoes",
		plant_cost: 50,
		difficulty: 1,
		bed: "earth",
		type: "vegetable",
		days: 18,
		multiplier: 2,
		special: [],
		season: ["spring","summer","autumn"]
		},
	bamboo: {
		index: 35,
		name: "bamboo",
		plural: "bamboo",
		plant_cost: 20,
		difficulty: 1,
		bed: "earth",
		type: "flower",
		days: 6,
		multiplier: 3,
		special: [],
		season: ["spring","summer","autumn","winter"]
		}
}>>

<!-- Jimmy: Sorts all plants alphabetically after their initialisation into _plants.
			This is so Object.values/keys will read them based on their alphabetical key order.
			Yet allows extras to be added easily based on .index being available and ordered above.
-->
<<run
	let sorted = Object.keys(_plants).sort();
	setup.plants = {};
	sorted.forEach(s => {
		setup.plants[s] = _plants[s];
	});
	delete _plants;
>>

<<set setup.plot_base to {

	plant: "none",
	stage: 0,
	days: 0,
	water: 0,
	till: 0,

}>>
<</widget>>


code:
:: Widgets children [widget]
<<widget "childrenSetup">>
<<if $children is undefined>>
	<<set $children to {}>>
<</if>>
<</widget>>

<<widget "getUsedChildrenNames">>
<<set _usedChildrenNames to []>>
<<for $_label, $_value range $children>>
	<<run _usedChildrenNames.pushUnique($_value.name)>>
<</for>>
<</widget>>

/*args[0] - location, args[1] - "both" to include unrelated children or "only" to exclude the player children*/
<<widget "getChildrenIds">>
<<set _childrenIds to []>>
<<for $_label, $_value range $children>>
	<<if $_value.mother isnot "pc" and $_value.father isnot "pc">>
		<<if $args[1] isnot "both" and $args[1] isnot "only">>
			<<continue>>
		<</if>>
	<<elseif $args[1] is "only">>
		<<continue>>
	<</if>>
	<<if $args[0] is undefined or $_value.location is $args[0]>>
		<<run _childrenIds.push($_label)>>
	<</if>>
<</for>>
<</widget>>

/*args[0] - location, args[1] - min length requirement, args[2] - max length requirement,
args[3] - "both" to include unrelated children or "only" to exclude the player children*/
<<widget "getSameBirthChildrenIds">>
<<set _birthChildrenIds to {}>>
<<for $_label, $_value range $children>>
	<<if $_value.mother isnot "pc" and $_value.father isnot "pc">>
		<<if $args[3] isnot "both" and $args[3] isnot "only">>
			<<continue>>
		<</if>>
	<<elseif $args[3] is "only">>
		<<continue>>
	<</if>>
	<<if $args[0] is undefined or $_value.location is $args[0]>>
		<<if _birthChildrenIds[$_value.birthId] is undefined>>
			<<set _birthChildrenIds[$_value.birthId] to []>>
		<</if>>
		<<run _birthChildrenIds[$_value.birthId].push($_value.childId)>>
	<</if>>
<</for>>
<<if $args[1]>>
	<<for $_label, $_value range _birthChildrenIds>>
		<<if $_value.length lt $args[1] or $_value.length gt $args[2]>>
			<<run delete _birthChildrenIds[$_label]>>
		<</if>>
	<</for>>
<</if>>
<</widget>>

/*args[0] - location, args[1] - birthId, args[2] - new location*/
<<widget "moveChildren">>
<<if $args[0] and $args[1]>>
	<<getSameBirthChildrenIds $args[0]>>
	<<if _birthChildrenIds[$args[1]] isnot undefined>>
		<<for $_i to 0; $_i lt _birthChildrenIds[$args[1]].length; $_i++>>
			<<set $children[_birthChildrenIds[$args[1]][$_i]].location to $args[2]>>
		<</for>>
	<</if>>
<</if>>
<</widget>>

/*args[0] - childId, args[1] - new name*/
<<widget "childRename">>
<<if $args[0]>>
	<<getUsedChildrenNames>>
	<<set $children[$args[0]].name to generateBabyName($args[1], $children[$args[0]].gender, _usedChildrenNames)>>
<</if>>
<</widget>>

/*args[0] - childId, args[1] - clothes*/
<<widget "childChangeClothes">>
<<if $args[0]>>
	<<if $children[$args[0]].features.clothes isnot null>>
		<<if $args[1]>>
			<<set _clothes to $args[1]>>
		<<else>>
			<<set _clothes to "naked">>
		<</if>>
		<<set $children[$args[0]].features.clothes to _clothes>>
	<</if>>
<</if>>
<</widget>>

/*args[0] - childId, args[1] - set to display specific text output*/
<<widget "childAge">><<silently>>
<<if $args[0]>>
	<<set _date1 to $children[$args[0]].born.day + " " + $children[$args[0]].born.month + " " + $children[$args[0]].born.year>>
	<<set _date2 to $monthday + " " + $month + " " + $year>>
	<<set $_calc to Math.abs(Date.parse(_date2) - Date.parse(_date1))>>
	<<set _childTotalDays to Math.ceil($_calc / (1000 * 60 * 60 * 24))>>
	<<set _childYears to Math.floor(_childTotalDays / 360)>>
	<<set _childDays to Math.floor(_childTotalDays % 360)>>
	<<switch $args[1]>>
		<<case "full">>
			<<set $_text_output to _childYears + " year" + (_childYears isnot 1 ? "s, " : ", ") + _childDays + " day" + (_childDays isnot 1 ? "s " : " ") + "old">>
		<<case "year">>
			<<set $_text_output to _childYears + " year" + (_childYears isnot 1 ? "s" : "")>>
		<<case "day">>
			<<set $_text_output to _childDays + " day" + (_childDays isnot 1 ? "s" : " ")>>
		<<case "totalDays">>
			<<set $_text_output to _childTotalDays>>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*:: Widgets children2 [widget]*/

/*args[0] - childId*/
<<widget "childSelect">>
<<if $args[0] isnot undefined>>
	<<set $childSelected to $children[$args[0]]>>
<</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childname">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<set $_text_output to $children[_id].name>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId in an array*/
<<widget "childrenNames">><<silently>>
<<if $args[0] isnot undefined>>
	<<set $_text_output to "">>
	<<for $_i to 0; $_i lt $args[0].length; $_i++>>
		<<set $_text_output += $children[$args[0][$_i]].name>>
		<<if $_i is $args[0].length - 1>>
		<<elseif $_i is $args[0].length - 2>>
			<<set $_text_output += " and ">>
		<<else>>
			<<set $_text_output += ", ">>
		<</if>>
	<</for>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childHe">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "He">>
		<<case "f" "h">><<set $_text_output to "She">>
		<<case "h">><<set $_text_output to "They">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhe">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "he">>
		<<case "f" "h">><<set $_text_output to "she">>
		<<case "h">><<set $_text_output to "they">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childHis">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "His">>
		<<case "f" "h">><<set $_text_output to "Her">>
		<<case "h">><<set $_text_output to "Their">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhis">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "his">>
		<<case "f" "h">><<set $_text_output to "her">>
		<<case "h">><<set $_text_output to "their">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childHim">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "Him">>
		<<case "f" "h">><<set $_text_output to "Her">>
		<<case "h">><<set $_text_output to "Their">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhim">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "him">>
		<<case "f" "h">><<set $_text_output to "her">>
		<<case "h">><<set $_text_output to "their">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childHers">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "His">>
		<<case "f" "h">><<set $_text_output to "Hers">>
		<<case "h">><<set $_text_output to "Theirs">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhers">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].gender>>
		<<case "m">><<set $_text_output to "his">>
		<<case "f" "h">><<set $_text_output to "hers">>
		<<case "h">><<set $_text_output to "theirs">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhand">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].type>>
		<<case "human">><<set $_text_output to "hand">>
		<<case "wolf" "wolfboy" "wolfgirl">><<set $_text_output to "paw">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhands">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].type>>
		<<case "human">><<set $_text_output to "hands">>
		<<case "wolf" "wolfboy" "wolfgirl">><<set $_text_output to "paws">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childgiggles">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].type>>
		<<case "human">><<set $_text_output to "giggles">>
		<<case "wolf" "wolfboy" "wolfgirl">><<set $_text_output to "wags <<childhis $args[0]>> tail">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childhair">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].type>>
		<<case "human">><<set $_text_output to "hair">>
		<<case "wolf" "wolfboy" "wolfgirl">><<set $_text_output to "fur">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - cry type, args[1] - childId */
<<widget "childcry">><<silently>>
<<if $args[1] isnot undefined>>
	<<set _id to $args[1]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<if between($args[0], 1, 4)>>
		<<set _cry to $args[0]>>
	<<else>>
		<<set _cry to 1>>
	<</if>>
	<<switch $children[_id].type>>
		<<case "human">>
			<<switch _cry>>
				<<case 1>><<set $_text_output to "sniffling">>
				<<case 2>><<set $_text_output to "weeping">>
				<<case 3>><<set $_text_output to "sobbing">>
				<<case 4>><<set $_text_output to "wailing">>
			<</switch>>
		<<case "wolf" "wolfboy" "wolfgirl">>
			<<switch _cry>>
				<<case 1>><<set $_text_output to "whining">>
				<<case 2>><<set $_text_output to "whimpering">>
				<<case 3>><<set $_text_output to "crying">>
				<<case 4>><<set $_text_output to "howling">>
			<</switch>>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - cry type, args[1] - childId */
<<widget "childCry">><<silently>>
<<if $args[1] isnot undefined>>
	<<set _id to $args[1]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<if between($args[0], 1, 4)>>
		<<set _cry to $args[0]>>
	<<else>>
		<<set _cry to 1>>
	<</if>>
	<<switch $children[_id].type>>
		<<case "human">>
			<<switch _cry>>
				<<case 1>><<set $_text_output to "Sniffling">>
				<<case 2>><<set $_text_output to "Weeping">>
				<<case 3>><<set $_text_output to "Sobbing">>
				<<case 4>><<set $_text_output to "Wailing">>
			<</switch>>
		<<case "wolf" "wolfboy" "wolfgirl">>
			<<switch _cry>>
				<<case 1>><<set $_text_output to "Whining">>
				<<case 2>><<set $_text_output to "Whimpering">>
				<<case 3>><<set $_text_output to "Crying">>
				<<case 4>><<set $_text_output to "Howling">>
			<</switch>>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - childId*/
<<widget "childtype">><<silently>>
<<if $args[0] isnot undefined>>
	<<set _id to $args[0]>>
<<elseif $childSelected isnot undefined>>
	<<set _id to $childSelected.childId>>
<</if>>
<<if _id isnot undefined>>
	<<switch $children[_id].type>>
		<<case "human">><<set $_text_output to "child">>
		<<case "wolf" "wolfboy" "wolfgirl">><<set $_text_output to "pup">>
	<</switch>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

/*args[0] - location, args[1] - toyid, toy set or toy name, args[2] - option of either "notext" or "lowercase"*/
<<widget "childtoy">><<silently>>
<<set _toys to $storedToys[$args[0]]>>
<<if _toys>>
	<<if between($args[1], 0, _toys.length - 1)>>
		<<set _toy to _toys[$args[1]]>>
	<<elseif $args[1]>>
		<<set _toySelect to []>>
		<<for $_i to 0; $_i lt _toys.length; $_i++>>
			<<if _toys[$_i].set is $args[1] or _toys[$_i].name is $args[1]>>
				<<run _toySelect.push($_i)>>
			<</if>>
		<</for>>
		<<if _toySelect.length gt 0>>
			<<set _toyid to _toySelect[random(0,_toySelect.length - 1)]>>
			<<set _toy to _toys[_toyid]>>
		<</if>>
	<<else>>
		<<set _toyid to random(0,_toys.length - 1)>>
		<<set _toy to _toys[_toyid]>>
	<</if>>
	<<if _toy>>
		<<switch $args[2]>>
			<<case "notext">>
			<<case "lowercase">>
				<<set $_text_output to clone(_toy.name_lower)>>
				<<set _toyName to clone(_toy.name_lower)>>
			<<default>>
				<<set $_text_output to clone(_toy.name)>>
				<<set _toyName to clone(_toy.name)>>
		<</switch>>
	<</if>>
<</if>>
<</silently>><<if $_text_output>><<print $_text_output>><</if>>
<</widget>>

<<widget "childViewerDisplay">>
<<set _idList to $args[0]>>
<<set _listMaxItems to 10>>
<<set _listPage to 1>>
<<set _listPageMax to Math.ceil(_idList.length / _listMaxItems)>>
<<set _childStart to 0>>
<<set _childEnd to (_childStart + _listMaxItems gt _idList.length ? _idList.length : _childStart + _listMaxItems)>>

	<<childViewerDisplayElements>>

<</widget>>

<<widget "childViewerPageUpdate">>
<<set _childStart to _listMaxItems * (_listPage - 1)>>
<<set _childEnd to (_childStart + _listMaxItems lte _idList.length ? _childStart + _listMaxItems : _idList.length)>>
<<replace '#childViewer'>>
	<<childViewerDisplayElements>>
<</replace>>
<</widget>>

<<widget "childViewerDisplayElements">>
<<for $_i to _childStart; $_i lt _childEnd; $_i++>>
	<<capture $_i>>

			<<childViewerElement `_childrenIds[$_i]`>>

	<</capture>>
<</for>>

	<<set _disabled = _listPage > 1 ? "" : "disabled">>

		<<link "Previous">>
			<<if _listPage > 1>>
				<<set _listPage -= 1>>
				<<childViewerPageUpdate>>
			<</if>>
		<</link>>

<

		<<print (_listPage) + " out of " + _listPageMax>>

	<<set _disabled = _listPage < _listPageMax ? "" : "disabled">>

		<<link "Next">>
			<<if _listPage < _listPageMax>>
				<<set _listPage += 1>>
				<<childViewerPageUpdate>>
			<</if>>
		<</link>>

>

<<run linkifyDivs('#childViewer')>>
<</widget>>

<<widget "childViewerElement">>
<<if _children is undefined>>
	<<set _children to {}>>
<</if>>
<<capture $args>>
	<<if $children[$args[0]].type isnot "human">>
		Type: <<print $children[$args[0]].type[0].toUpperCase() + $children[$args[0]].type.substring(1)>> |
	<</if>>
	Gender:
	<<switch $children[$args[0]].gender>>
		<<case "m">>Male
		<<case "f">>Female
		<<case "h">>Hermaphrodite
	<</switch>>

	<<print '<<textbox "_children['+$args[0]+']" $children['+$args[0]+'].name>>'>>

	<<childActivity $args[0]>>
	<<childViewerHiddenElements $args[0]>>
<</capture>>
<</widget>>

<<widget "childViewerHiddenElements">>
<<if $args[0]>>

		Mother:
		<<if $children[$args[0]].motherKnown>>
			<<print $children[$args[0]].mother>>
		<<else>>
			????
		<</if>>
		| Father:
		<<if $children[$args[0]].fatherKnown>>
			<<print $children[$args[0]].father>>
		<<else>>
			????
		<</if>>

		Born: <<print $children[$args[0]].born.day + " " + $children[$args[0]].born.month + " " + $children[$args[0]].born.year>> |
		Age: <<childAge $args[0] "full">>

		Size: <<print $children[$args[0]].features.size>> | Hair Colour: <<print $children[$args[0]].features.hairColour>>
		<<if $children[$args[0]].features.skinColour isnot null>>
			| Skin Colour: <<print $children[$args[0]].features.skinColour>>
		<</if>>

		<<if $children[$args[0]].features.identical isnot null>>
			Identical: <<print $children[$args[0]].features.identical>>

		<</if>>

		<<link "Re-name">>
			<<getUsedChildrenNames>>
			<<set $children[$args[0]].name to generateBabyName(_children[$args[0]], $children[$args[0]].gender, _usedChildrenNames)>>
			<<replace `"#child-" + $args[0]`>><<birthChildElement $args[0]>><</replace>>
		<</link>> |
		<<link "Random Name">>
			<<getUsedChildrenNames>>
			<<set $children[$args[0]].name to generateBabyName(undefined, $children[$args[0]].gender, _usedChildrenNames)>>
			<<replace `"#child-" + $args[0]`>><<birthChildElement $args[0]>><</replace>>
		<</link>>

			saveId: <<print $saveId>>
			<<if $saveName isnot "">>
				| name: <<print $saveName>>
			<</if>>

<</if>>
<</widget>>

<<widget "childViewerHiddenElementsUnhide">>
<<capture $args>>
	<<if $args[0]>>
		<<toggleclass `'#childViewerHidden-'+$args[0]` "hidden">>
	<</if>>
<</capture>>
<</widget>>

<<widget "childActivityUpdate">>
<<if $args[0]>>
	<<childAge $args[0]>>
	<<childSelect $args[0]>>
	<<if $children[$args[0]].localVariables.activityDay is undefined>>
		<<set $children[$args[0]].localVariables.activityDay to $days - 1>>
		<<set $children[$args[0]].localVariables.activityHour to $hour>>
		<<set $children[$args[0]].localVariables.crawling to 0>>
		<<set $children[$args[0]].localVariables.talking to 0>>
	<</if>>
	<<if $children[$args[0]].localVariables.activityDay is $days and ($children[$args[0]].localVariables.activityHour + 4) gt $hour>>
	<<else>>
		<<set $children[$args[0]].localVariables.activityDay to $days>>
		<<set $children[$args[0]].localVariables.activityHour to $hour>>
	<</if>>
<</if>>
<</widget>>

<<widget "childActivity">>
<<if $args[0]>>
	<<childAge $args[0]>>
	<<childSelect $args[0]>>
	<<if $children[$args[0]].localVariables.activityDay is undefined>>
		<<set $children[$args[0]].localVariables.activityDay to $days - 1>>
		<<set $children[$args[0]].localVariables.activityHour to $hour>>
		<<set $children[$args[0]].localVariables.crawling to 0>>
		<<set $children[$args[0]].localVariables.talking to 0>>
	<</if>>
	<<switch $children[$args[0]].type>>
		<<case "human">><<humanChildActivity $args[0]>>
		<<case "wolf" "wolfboy" "wolfgirl">><<wolfChildActivity $args[0]>>
	<</switch>>
	<<if $children[$args[0]].localVariables.activityDay is $days and ($children[$args[0]].localVariables.activityHour + 4) gt $hour>>
	<<else>>
		<<set $children[$args[0]].localVariables.activityDay to $days>>
		<<set $children[$args[0]].localVariables.activityHour to $hour>>
	<</if>>

		<<if $children[$args[0]].localVariables.event is false>>

			<<link "View Details">><<childViewerHiddenElementsUnhide $args[0]>><</link>>
		<</if>>

<</if>>
<</widget>>

<<widget "humanChildActivity">><<silently>>
	<<if $children[$args[0]].localVariables.activityDay is $days and ($children[$args[0]].localVariables.activityHour + 4) gt $hour>>
	<<else>>
		<<set _toySets to []>>
		<<set _toyNames to []>>
		<<for $_i to 0; $_i lt $storedToys[$location].length; $_i++>>
			<<run _toySets.pushUnique($storedToys[$location][$_i].set)>>
			<<run _toyNames.pushUnique($storedToys[$location][$_i].name)>>
		<</for>>
		<<if between(_childTotalDays, 0, 100)>>
			<<if $daystate is "night">>
				<<set _activity to ["sleeping", "sleeping", "sleeping", "sleeping", "sleeping", "restlessSleep", "restlessSleep", "crying","nappyChange"]>>
			<<else>>
				<<set _activity to ["sleeping", "sleeping", "sleeping", "crying", "crying", "crying", "happy", "nappyChange", "thumbSucking", "grumpyChild"]>>
				<<if _toySets.includes("baby rattles")>>
					<<run _activity.push("babyRattle")>>
				<</if>>
				<<if _toySets.includes("teddy bears")>>
					<<run _activity.push("teddyBear")>>
				<</if>>
				<<if _toySets.includes("toy cars")>>
					<<run _activity.push("toyCar")>>
				<</if>>
				<<if _toySets.includes("dummies")>>
					<<run _activity.push("dummy")>>
				<<else>>
					<<run _activity.push("crying")>>
				<</if>>
				<<if _toyNames.includes("clown")>>
					<<run _activity.push("clown")>>
				<</if>>
			<</if>>
		<<elseif between(_childTotalDays, 101, 200)>>
			<<if $daystate is "night">>
				<<set _activity to ["sleeping", "sleeping", "sleeping", "sleeping", "sleeping", "restlessSleep", "restlessSleep", "crying","nappyChange"]>>
			<<else>>
				<<set _activity to ["sleeping", "sleeping", "sleeping", "crying", "happy", "nappyChange", "thumbSucking", "talking", "grumpyChild","readingAttempt"]>>
				<<if _toySets.includes("baby rattles")>>
					<<run _activity.push("babyRattle")>>
				<</if>>
				<<if _toySets.includes("teddy bears")>>
					<<run _activity.push("teddyBear")>>
				<</if>>
				<<if _toySets.includes("toy cars")>>
					<<run _activity.push("toyCar")>>
				<</if>>
				<<if _toySets.includes("dummies")>>
					<<run _activity.push("dummy")>>
				<</if>>
				<<if _toyNames.includes("clown")>>
					<<run _activity.push("clown")>>
				<</if>>
				<<if $children[$args[0]].localVariables.crawling gte 5>>
					<<run _activity.push("crawlingAttempt")>>
				<<else>>
					<<run _activity.push("crawlingAttempt2")>>
				<</if>>
				<<if $children[$args[0]].localVariables.talking gte 10>>
					<<run _activity.push("talking2")>>
				<</if>>
			<</if>>
		<</if>>
		<<set $children[$args[0]].localVariables.activity to _activity[random(0,_activity.length - 1)]>>
		<<set $children[$args[0]].localVariables.event to true>>
	<</if>>
	<<set _childid to clone($args[0])>>
<</silently>>
<<switch $children[$args[0]].localVariables.activity>>
	<<case "sleeping">>
		<<childHe>>'s sleeping soundly.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Watch them (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"shiverInCot", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "restlessSleep">>
		<<childHe>>'s moving restlessly in <<childhis>> sleep.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Calm them down (0:30)|Children Activity Events]]>><<pass 30>><<set $childActivityEvent to {event:"restlessSleep", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "crying">>
		<<childHe>>'s distressed and crying.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Confort (0:20)|Children Activity Events]]>><<pass 20>><<set $childActivityEvent to {event:"rockToSleep", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "happy">>
		<<childHe>>'s smiling and happily cooing.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Smile and laugh (0:20)|Children Activity Events]]>><<pass 20>><<set $childActivityEvent to {event:"smilesAndLaughs", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "talking">>
		<<childHe>>'s gurgling and babbling to <<childhimself>>.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Join in the babbling (0:10)|Children Activity Events]]>><<pass 10>><<set $childActivityEvent to {event:"talking", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "talking2">>
		<<childHe>>'s gurgling and attempting to make sounds to <<childhimself>>.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Join in the talking (0:10)|Children Activity Events]]>><<pass 10>><<set $childActivityEvent to {event:"talking2", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "nappyChange">>
		<<childHe>>'s looking uncomfortable and smells.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Clean up (0:10)|Children Activity Events]]>><<pass 10>><<set $childActivityEvent to {event:"nappyChange", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "thumbSucking">>
		<<childHe>>'s happily sucking on <<childhis>> thumb.
	<<case "grumpyChild">>
		<<childHe>>'s being irritable.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Tickle (0:10)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"grumpyChild", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "crawlingAttempt">>
		<<childHe>>'s Laying on <<childhis>> belly and flailing about.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Help them out (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"crawlingAttempt", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "crawlingAttempt2">>
		<<childHe>>'s slowly crawling about the room.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Help them out (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"crawlingAttempt2", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "readingAttempt">>
		<<childHe>>'s looking at a children's book upside down.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Flip the book (0:10)|Children Activity Events]]>><<pass 10>><<set $childActivityEvent to {event:"readingAttempt", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "readingCorrected">>
		<<childHe>>'s looking at a children's book.
	<<case "babyRattle">>
		<<childtoy $location "baby rattles" "notext">>
		<<if _toyid>>
			<<childHe>>'s staring at a <<childtoy $location _toyid "lowercase">>.
			<<if $children[$args[0]].localVariables.event is true>>

				<<capture _childid _toyid>><<link [[Shake it (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"babyRattle", childid:_childid, toyid:_toyid}>><</link>><</capture>> |
			<</if>>
		<<else>>
			<<humanChildActivityNoToy>>
		<</if>>
	<<case "teddyBear">>
		<<childtoy $location "teddy bears" "notext">>
		<<if _toyid>>
			<<childHe>>'s turning and tossing in <<childhis>> sleep by a <<childtoy $location _toyid "lowercase">>.
			<<if $children[$args[0]].localVariables.event is true>>

				<<capture _childid _toyid>><<link [["Give " + _toyName + " (0:05)"|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"teddyBear", childid:_childid, toyid:_toyid}>><</link>><</capture>> |
			<</if>>
		<<else>>
			<<humanChildActivityNoToy>>
		<</if>>
	<<case "teddyBear2">>
		<<childHe>>'s sleeping soundly by <<childhis>> <<print $children[$args[0]].localVariables.toy>>.
	<<case "toyCar">>
		<<childtoy $location "toy cars" "notext">>
		<<if _toyid>>
			<<childHe>>'s waving a <<childtoy $location _toyid "lowercase">> in the air.
			<<if $children[$args[0]].localVariables.event is true>>

				<<capture _childid _toyid>><<link [[Play with (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"toyCar", childid:_childid, toyid:_toyid}>><</link>><</capture>> |
			<</if>>
		<<else>>
			<<humanChildActivityNoToy>>
		<</if>>
	<<case "dummy">>
		<<childtoy $location "dummies" "notext">>
		<<if _toyid>>
			<<set _rng to random(1,4)>>
			<<childHe>>'s <<childcry _rng>>. There's a <<childtoy $location _toyid "lowercase">> on the floor nearby.
			<<if $children[$args[0]].localVariables.event is true>>

				<<capture _childid _toyid _rng>><<link [[Pacify (0:15)|Children Activity Events]]>><<pass 15>><<set $childActivityEvent to {event:"dummy", childid:_childid, toyid:_toyid, childCry:_rng}>><</link>><</capture>> |
			<</if>>
		<<else>>
			<<humanChildActivityNoToy>>
		<</if>>
	<<case "dummySucking">>
		<<childHe>>'s suckling loudly on <<childhis>> dummy.
	<<case "clown">>
		<<childtoy $location "clown" "notext">>
		<<if _toyid>>
			<<childHe>>'s looking at a <<childtoy $location _toyid "lowercase">> with an unsure expression.
			<<if $children[$args[0]].localVariables.event is true>>

				<<capture _childid _toyid>><<link [[Play with (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"clown", childid:_childid, toyid:_toyid}>><</link>><</capture>> |
			<</if>>
		<<else>>
			<<humanChildActivityNoToy>>
		<</if>>
	<<case "clownHappy">>
		<<childHe>>'s playing happily with the clown, pullings it's cord and making it chuckle every now and then.
	<<default>>
		<<childHe>>'s has figured out that they're in a video game (This is an error, please report).
		<<print $children[$args[0]].localVariables.activity>>
<</switch>>
<</widget>>

<<widget "humanChildActivityNoToy">>
<<childHe>>'s sleeping soundly.
<<if $children[$args[0]].localVariables.event is true>>

	<<capture _childid>><<link [[Watch them (0:05)|Children Activity Events]]>><<pass 5>><<set $childActivityEvent to {event:"shiverInCot", childid:_childid}>><</link>><</capture>> |
<</if>>
<</widget>>

<<widget "wolfChildActivity">><<silently>>
	<<if $children[$args[0]].localVariables.activityDay is $days and ($children[$args[0]].localVariables.activityHour + 4) gt $hour>>
	<<else>>
		<<if between(_childTotalDays, 0, 100)>>
			<<set $children[$args[0]].localVariables.event to true>>
			<<if $daystate is "night">>
				<<set _activity to ["sleepingWithWolf", "sleepingWithWolf", "sleepingWithWolf", "sleeping"]>>
			<<else>>
				<<set _activity to ["sleepingWithWolf", "sleeping", "sleeping", "sleeping", "crying", "playing","watchingCurious", "watchingLonging", "staringOutside", "hungeryWolf", "grumpyWolf"]>>
			<</if>>
		<<elseif between(_childTotalDays, 101, 200)>>
			<<set $children[$args[0]].localVariables.event to true>>
			<<if $daystate is "night">>
				<<set _activity to ["sleepingWithWolf", "sleepingWithWolf", "sleepingWithWolf", "sleeping"]>>
			<<else>>
				<<set _activity to ["sleepingWithWolf", "sleeping", "sleeping", "sleeping", "crying", "playing","watchingCurious", "watchingLonging", "playFighting", "staringOutside", "staringOutside", "hungeryWolf", "grumpyWolf"]>>
			<</if>>
		<</if>>
		<<set $children[$args[0]].localVariables.activity to _activity[random(0,_activity.length - 1)]>>
		<<set $children[$args[0]].localVariables.event to true>>
	<</if>>
	<<set _childid to clone($args[0])>>
<</silently>>
<<switch $children[$args[0]].localVariables.activity>>
	<<case "sleeping">>
		<<childHe>>'s sleeping on <<childhis>> own.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Stroke head (0:10)|Children Activity Events]]>><<pass 10>><<set $childActivityEvent to {event:"sleepingStroke", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "sleepingWithWolf">>
		<<childHe>>'s sound asleep while cuddled up against another wolf.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Cuddle up to (0:30)|Children Activity Events]]>><<pass 30>><<set $childActivityEvent to {event:"cuddleAndNap", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "crying">>
		<<childHe>>'s distressed and <<childcry>>.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Comfort them (0:15)|Children Activity Events]]>><<pass 15>><<set $childActivityEvent to {event:"cryingWolf", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "playing">>
		<<childHe>>'s playing with some other pups.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Join in (0:15)|Children Activity Events]]>><<pass 15>><<set $childActivityEvent to {event:"playing", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "watchingCurious">>
		<<childHe>>'s watching you with a curious expression.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Sate curiosity (0:30)|Children Activity Events]]>><<pass 30>><<set $childActivityEvent to {event:"curiousGaze", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "watchingLonging">>
		<<childHe>>'s watching you with a longing expression.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Scratch ears (0:30)|Children Activity Events]]>><<pass 30>><<set $childActivityEvent to {event:"longingGaze", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "playFighting">>
		<<childHe>>'s play fighting with another pup.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Calm them (0:10)|Children Activity Events]]>><<pass 10>><<set $childActivityEvent to {event:"playFighting", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "staringOutside">>
		<<childHe>>'s staring out of the cave.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Go for a walk (0:30)|Children Activity Events]]>><<pass 30>><<set $childActivityEvent to {event:"fieldTrip", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "grumpyWolf">>
		<<childHe>>'s sitting alone and snapping at any who come near.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Cheer up (0:15)|Children Activity Events]]>><<pass 15>><<set $childActivityEvent to {event:"grumpyWolf", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<case "hungeryWolf">>
		<<childHe>>'s <<childcry>> in front of an overcrowded female wolf.
		<<if $children[$args[0]].localVariables.event is true>>

			<<capture _childid>><<link [[Help finding a nipple (0:15)|Children Activity Events]]>><<pass 15>><<set $childActivityEvent to {event:"hungeryWolf", childid:_childid}>><</link>><</capture>> |
		<</if>>
	<<default>>
		<<childHe>>'s has figured out that they're in a video game (This is an error, please report).
		<<print $children[$args[0]].localVariables.activity>>
<</switch>>
<</widget>>


code:
:: ChildrenEvents [widget]

/*args[0] - location, args[1] - passageExit*/
<<widget "childrenEvents">>
<<if $args[0]>>
	<<getChildrenIds $args[0]>>
	<<if _childrenIds.length gt 0>>
		<<set _singleEvents to true>>
	<</if>>
	<<getSameBirthChildrenIds $args[0] 2>>
	<<if Object.keys(_birthChildrenIds).length gt 0>>
		<<set _multipleEvents to true>>
	<</if>>
	<<set _keys to Object.keys(_birthChildrenIds)>>
	<<set $childPassageExit to $args[1]>>
	<<switch $args[0]>>
		<<case "test">>
			/*Examples of how to add events*/
			<<if _singleEvents is true and (_multipleEvents is false or random(0,100) gt 40)>>
				<<addevent `"testSingles " + _childrenIds[random(0,_childrenIds.length - 1)]`>>
			<<elseif _multipleEvents is true>>
				<<set _args to _birthChildrenIds[_keys[random(0,_keys.length - 1)]]>>
				<<addevent "testMultiple _args">>
			<</if>>
		<<case "wolf_cave">>
			<<if _singleEvents is true and (_multipleEvents is false or random(0,100) gt 40)>>
				<<addevent `"wolfCaveSingles " + _childrenIds[random(0,_childrenIds.length - 1)]`>>
			<<elseif _multipleEvents is true>>
				<<set _args to _birthChildrenIds[_keys[random(0,_keys.length - 1)]]>>
				/*<<addevent "wolfCaveMultiple _args">>*/
			<</if>>
	<</switch>>
<</if>>
<</widget>>

<<widget "testSingles">>
<<if $args[0]>>
	<<childSelect $args[0]>>
	<<switch random(0,0)>>
		<<case 0>>
			You spot your child <<childname>> on their back, looking at you with their <<childhands>> streched towards you.

			Picking <<childhim>> up, <<childhe>> <<childgiggles>> while rubbing your face.

			<<link [[Breast feed (0:30)|childBreastFeed]]>><<pass 30>><</link>><<lstress>><<ltrauma>>

			<<link [[Cuddle (0:30)|childCuddle]]>><<pass 30>><</link>><<lstress>><<ltrauma>>
	<</switch>>
<</if>>

<</widget>>

<<widget "testMultiple">>
<<if $args[0]>>
	<<set $childrenIds to $args[0]>>
	<<switch random(0,0)>>
		<<case 0>>
			You spot your children <<childrenNames $childrenIds>> sleeping together in their cot with a peaceful look on each face.

			<<link [[Watch (0:30)|childCotWatch]]>><<pass 30>><<set $phase to 1>><</link>><<lstress>><<ltrauma>>

			<<link [[Have a nap (0:30)|childCotWatch]]>><<pass 30>><<set $phase to 2>><</link>><<lstress>><<ltiredness>>
	<</switch>>
<</if>>

<</widget>>

<<widget "wolfCaveSingles">>
<<if $args[0]>>
	<<childSelect $args[0]>>
	<<switch random(0,0)>>
		<<case 0>>
			You spot your <<childtype>> <<childname>> lying on a sleeping wolf, looking at you with their <<childhands>> streched towards you.

			Picking <<childhim>> up, <<childhe>> <<childgiggles>> while rubbing your face.

			<<if $milk_amount gte 1>>
				<<link [[Breast feed (0:30)|childBreastFeed]]>><<pass 30>><</link>><<lstress>><<ltrauma>>

			<</if>>
			<<link [[Cuddle (0:30)|childCuddle]]>><<pass 30>><</link>><<lstress>><<ltrauma>>
	<</switch>>
<</if>>

<</widget>>

:: childBreastFeed

<<breastfeed>>
<<if $worn.over_upper.name isnot "naked" or $worn.upper.name isnot "naked" or $worn.upper.name isnot "naked">>
	You adjust your clothes to give <<childhim>> access to your <<breasts>>.
<</if>>

<<childHe>> seems to get the message and suckles your <<print ["left","right"].pluck()>> breast with closed eyes.

<<link [[Next|$childPassageExit]]>><<unset $childPassageExit>><<endevent>><</link>>

:: childCuddle

<<childHe>> seems to get the message and wraps <<childhis>> <<childhands>> around your neck while leaning on your shoulder.

<<link [[Next|$childPassageExit]]>><<unset $childPassageExit>><<endevent>><</link>>

:: childCotWatch
<<if $phase is 1>>

<<elseif $phase is 2>>
	<<childSelect `$childrenIds[random(0,$childrenIds.length - 1)]`>>
	You decide to have a nap and lie in the bed next to your children.

	You wake up sometime later with something wrapped round your finger. While still asleep, it seems that <<childname>>'s <<childhand>> was able to reach you.

<</if>>

<<link [[Next|$childPassageExit]]>><<unset $childPassageExit>><<endevent>><</link>>

:: Childrens Home
<<effects>>
<<getChildrenIds $location>>
<<switch $location>>
	<<case "wolf_cave">>
		You are in the wolf cave. The ceiling hangs low. There's a breeze blowing from the back.
<</switch>>
<<for _i to 0; _i lt _childrenIds.length; _i++>>
	<<childActivityUpdate `_childrenIds[_i]`>>
<</for>>

<<childViewerDisplay _childrenIds>>

<<link[[Store toys|Childrens Home Toys]]>><</link>>

<<link[[Back|$exitPassage]]>><<unset $exitPassage>><</link>>

:: Childrens Home Toys

<<switch $location>>
	<<case "wolf_cave">><<set _transferToys to "wolf">>
<</switch>>
<<set _selectedCurrentToy to 0>>
<<set _selectedLocationToy to 0>>

	<<childrenToysUI>>

<<link [[Back|Childrens Home]]>><<unset $childActivityEvent>><<endevent>><</link>>

:: Childrens Home Toys Widgets [widget]

<<widget "childrenToysUI">>
<<if $currentToys.length gt 0>>

Toys with you

		<<for _i to 0; _i lt $currentToys.length; _i++>>

				<<radiobutton "_selectedCurrentToy" _i autocheck>>
				<<print $currentToys[_i].name>>

		<</for>>

		<<link "Discard">>
			<<run $currentToys.deleteAt(_selectedCurrentToy)>>
			<<set _selectedCurrentToy to 0>>
			<<childrenToysUIReplace>>
		<</link>>

		<<if $storedToys[$location].length lt 10>>
			<<link "Leave toy">>
				<<run $storedToys[$location].push($currentToys[_selectedCurrentToy])>>
				<<run $currentToys.deleteAt(_selectedCurrentToy)>>
				<<set _selectedCurrentToy to 0>>
				<<childrenToysUIReplace>>
			<</link>>
		<<else>>
			You can't leave more than 10 toys at a time.
		<</if>>

<<else>>

You have no toys with you.

<</if>>

<<if $storedToys[$location].length gt 0>>

Toys your children can play with

		<<for _i to 0; _i lt $storedToys[$location].length; _i++>>

				<<radiobutton "_selectedLocationToy" _i autocheck>>
				<<print $storedToys[$location][_i].name>>

		<</for>>

		<<link "Discard">>
			<<run $storedToys[$location].deleteAt(_selectedLocationToy)>>
			<<set _selectedLocationToy to 0>>
			<<childrenToysUIReplace>>
		<</link>>

		<<if $currentToys.length lt 5>>
			<<link "Take Back">>
				<<run $currentToys.push($storedToys[$location][_selectedLocationToy])>>
				<<run $storedToys[$location].deleteAt(_selectedLocationToy)>>
				<<set _selectedLocationToy to 0>>
				<<childrenToysUIReplace>>
			<</link>>
		<<else>>
			You can't have more than 5 toys with you at a time.
		<</if>>

<<else>>

You havn't left any toys here.

<</if>>

<</widget>>

<<widget "childrenToysUIReplace">>
<<replace "#childrenToysUI">>
	<<childrenToysUI>>
<</replace>>
<</widget>>

:: Children Activity Events
<<effects>>
<<childSelect $childActivityEvent.childid>>
<<set $children[$childActivityEvent.childid].localVariables.event to false>>
<<switch $childActivityEvent.event>>
	/*Human Specific*/
	<<case "shiverInCot">>
		You see <<childname>> sleeping by <<childhimself>> when you notice <<childhe>> shivers with every unconscious breath. You go over to <<childname>> and tuck <<childhim>> in with a nearby baby blanket. In a few moments <<childhe>>'s again sleeping peacefully as you return to what you were doing. <<lstress>><<stress -5>>
	<<case "restlessSleep">>
		Noticing the <<childtype>>'s restless sleep you move over to <<childhim>> and lay down beside. You pull <<childname>> against your chest and hold <<childhim>> and soon enough <<childhe>> calms down. Before you can stand however you notice <<childhe>> has your finger gripped tightly in <<chilldhis>> small hands. You decide to spend a some time snuggling before easing <<childhis>> hold on you and getting to your feet. <<ltiredness>><<tiredness -6>><<llstress>><<stress -10>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "rockToSleep">>
		You scoop the <<childtype>> up in your arms and walk while gently rocking <<childhim>> side to side and humming softly. Soon <<childhe>> calms down and falls fast asleep in your arms. You gingerly lay <<childhim>> down in the cot to rest. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "smilesAndLaughs">>
		You walk over to <<childname>> and take <<childhim>> into your arms, hoisting <<childhim>> into the eye. The <<childtype>> is wide eyed at the change in <<childhis>> situation at first but then smiles and laughs. You repeat this several times and soon you have <<childname>> laughing endlessly and you cannot help but smile yourself. When you are done you return the <<childtype>>. <<llstress>><<stress -10>>
	<<case "talking">>
		You sit down next to <<childname>> and begin to converse with the talkative <<childtype>>. Although you can't understand one another <<childhe>> smiles at your presence and begins to make more excited noises as you talk to <<childhim>>. Soon enough however <<childhe>> becomes distracted by <<childhis>> own hands and falls silent while you get back on your feet. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "thumbSucking">>
		<<set $children[$childActivityEvent.childid].localVariables.talking++>>
	<<case "talking2">>
		You sit down next to <<childname>> and begin to converse with the talkative <<childtype>>. Although you can't understand one another <<childhe>> smiles at your presence and begins to attempt to make similar sounds as you talk to <<childhim>>. Soon enough however <<childhe>> becomes distracted by <<childhis>> own hands and falls silent while you get back on your feet. <<llstress>><<stress -10>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "thumbSucking">>
	<<case "nappyChange">>
		You notice <<childname>> looking uncomfortable and notice a telling stink coming from <<childhim>>. You fetch a spare nappy and go over to <<childhim>>, laying him flat and removing the old nappy. You clean the <<childtype>>'s bottom diligently and place the fresh nappy on <<childhim>>. Freshly cleaned and changed, <<childname>> looks up at you and smiles before you go to dispose of the dirty nappy. <<gstress>><<stress 5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "crawlingAttempt">>
		Walking over to <<childname>> you see that <<childhe>> is stuck on <<childhis>> belly and is trying to move <<childhimself>> forward. You sit down next to the <<childtype>> and take <<childhis>> hands in your, place them on the floor and hold them there to give <<childhim>> leverage. Soon enough <<childname>> is pulling <<childhimself>> across the floor with your help, bewildered and amused at <<childhis>> own mobility. After a while <<childhe>> seems to get the hang of it and you leave <<childhim>> clumsily crawling on <<childhis>> own. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
		<<set $children[$childActivityEvent.childid].localVariables.crawling++>>
	<<case "crawlingAttempt2">>
		Taking the <<childtype>>'s hands in yours you hoist <<childhim>> up by them, leaving only <<childhis>> feet on the ground. Confused at first <<childname>> flails <<childhis>> legs until <<childhe>> snags the ground with a kick and propels <<childhimself>> forward. <<childname's>> eyes go wide at the revelation and soon enough, with some effort and failed triesm, you have <<childhim>> moving with <<childhis>> own legs, and your help keeping him upright of course. After a while of this exercise <<childhe>> grows tired and you let <<childhim>> down again. <<llstress>><<stress -10>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "grumpyChild">>
		<<childname>> sits alone and wears a scowl on <<childhis>> infant face. You walk over and sit down next to <<childhim>> but <<childhe>> seems to ignore you. Unable to help but smile at the grumpy child's expression you begin to tickle <<childhim>>. While perhaps not ticklish at this age <<childname>> is still deeply amused by your teasing fingers and the silly noises you make as you playfully attack <<childhis>> sides. Soon enough the scowl is gone and the <<childtype>> is giggling and smiling. Mission accomplished, you stand back up. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "thumbSucking">>
	<<case "readingAttempt">>
		You walk over to <<childname>> and sit down before pulling <<childhim>> and the inverted book into your lap. Taking the book from the <<childtype>> you flip it about and begin to read it's simple words to <<childhim>>. <<childHe>> follows along with both your voice and the colorful pictures for some time but eventually becomes distracted by something else and rolls off of your lap to pursue it. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "readingCorrected">>
	<<case "babyRattle">>
		You go over to <<childname>> and sit down next to <<childhim>>. <<childHe>> is looking down at a <<childtoy $location $childActivityEvent.toyid "lowercase">>. You take the toy in hand and give it a shake causing a cacophony of rattles to emanate from it. The <<childtype>> looks bewildered and intrigued as <<childhe>> reaches  for the strange thing. You give the <<childtoy $location $childActivityEvent.toyid "lowercase">> one last shake before handing it over for the <<childtype>> to experiment with. <<lstress>><<stress -5>><<ltrauma>><<trauma -2>>
	<<case "teddyBear">>
		You go over to the restlessly sleeping <<childtype>> and tuck the <<childtoy $location $childActivityEvent.toyid "lowercase">> into <<childhis>> arms. <<childname>> grips the <<childtoy $location $childActivityEvent.toyid "lowercase">> tightly and nuzzles into it. Soon <<childhe>> is sleeping soundly again. You spend a few calming moments watching <<childhim>>. <<lstress>><<stress -5>><<ltrauma>><<trauma -2>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "teddyBear2">>
		<<set $children[$childActivityEvent.childid].localVariables.toy to clone(_toyName)>>
	<<case "toyCar">>
		You sit next to <<childname>> and take the <<childtoy $location $childActivityEvent.toyid "lowercase">> from <<childhis>> flailing hands. Placing it on the floor you roll it back and forth saying “Vroom! Vroom!” You do this several times as <<childname>> watches completely enraptured before you hand it to <<childhim>>. <<childHe>> looks at the toy with curiosity before mimicking your actions, making excited attempts to copy your sounds. You are left smiling as you climb to your feet again. <<lstress>><<stress -5>><<ltrauma>><<trauma -2>>
	<<case "dummy">>
		<<set _rng to random(0,100)>>
		Rushing over to <<childname>> you notice that <<childhis>> <<childtoy $location $childActivityEvent.toyid "lowercase">> is on the floor next to <<childhim>>.

		<<if $children[$childActivityEvent.childid].localVariables.acceptsDummy isnot false>>
			Picking up the dummy, you quickly clean it off with the hem of your <<top>> and lift the child into your arms before attempting to pacify the <<childtype>> with it.

		<</if>>

		<<if $childActivityEvent.childCry lt 4 and (_rng lt 75 or $children[$childActivityEvent.childid].localVariables.acceptsDummy is true)>>
			<<childname>> takes a few moments but latches onto the <<childtoy $location $childActivityEvent.toyid "lowercase">> and begins suckling loudly. In no time <<childhe>> is pacified once again and you deposit <<childhim>> on the floor. <<lstress>><<stress -6>>
			<<set $children[$childActivityEvent.childid].localVariables.activity to "dummySucking">>
			<<set $children[$childActivityEvent.childid].localVariables.acceptsDummy to true>>
		<<elseif $childActivityEvent.childCry is 4 and $children[$childActivityEvent.childid].localVariables.acceptsDummy isnot false>>
			Despite your attempts the <<childcry $childActivityEvent.childCry>> <<childname>> crying and wiggling around too much to take the <<childtoy $location $childActivityEvent.toyid "lowercase">>. You abandon the attempt and instead begin to rock and soothe the <<chiltdype>> with soft coos and gentle humming. It's exhausting, but eventually <<childhe>> calms down and nuzzles into your chest, the emotional distress and your tender parental attentions get the better of <<childhim>> and <<childhe>> falls asleep. <<gstress>><<stress 10>><<gtiredness>><<tiredness 5>>

			You gently lay <<childname>> down to take <<childhis>> nap in peace.
			<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
		<<elseif $childActivityEvent.childCry lt 4 and $children[$childActivityEvent.childid].localVariables.acceptsDummy isnot false>>
			Despite your attempts the <<childcry $childActivityEvent.childCry>> <<childname>> refuses to take the <<childtoy $location $childActivityEvent.toyid "lowercase">>. You abandon the attempt and instead begin to rock and soothe the <<chiltdype>> with soft coos and gentle humming. It's exhausting, but eventually <<childhe>> calms down and nuzzles into your chest, the emotional distress and your tender parental attentions get the better of <<childhim>> and <<childhe>> falls asleep. <<gstress>><<stress 10>><<gtiredness>><<tiredness 5>>

			You gently lay <<childname>> down to take <<childhis>> nap in peace.
			<<set $children[$childActivityEvent.childid].localVariables.acceptsDummy to false>>
			<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
		<<else>>
			Knowing that <<childname>> will refuse the dummy, you begin to rock and soothe the <<chiltdype>> with soft coos and gentle humming. It's exhausting, but eventually <<childhe>> calms down and nuzzles into your chest, the emotional distress and your tender parental attentions get the better of <<childhim>> and <<childhe>> falls asleep. <<gtiredness>><<tiredness 5>>

			You gently lay <<childname>> down to take <<childhis>> nap in peace.
			<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
		<</if>>
	<<case "clown">>
		<<set _rng to random(0,2)>>
		<<set _output to ["happy","quiet","terrifying"]>>
		Sitting down next to <<childname>> you pick up the toy <<childtoy $location $childActivityEvent.toyid "lowercase">> from the floor and show it to <<childhim>>. <<childHe>> stares at the <<childtoy $location $childActivityEvent.toyid "lowercase">> entirely unsure of what to make of it. Taking the string on the toy's back, you pull it, and the clown lets out a <<print _output[_rng]>> chuckle.

		<<if _rng lt 2>>
			The <<childtype>> bursts into a giggling fit and reaches for the <<childtoy $location $childActivityEvent.toyid "lowercase">>. You hand it over happily to get rid of the toy. Standing up, you leave <<childname>> playing happily. <<lstress>><<stress -3>><<ltrauma>><<trauma -3>>
			<<set $children[$childActivityEvent.childid].localVariables.activity to "clownHappy">>
		<<else>>
			The <<childtype>> bursts into tears and begins <<childcry 4>> and you can't blame <<childhim>>. <<gstress>><<stress 6>><<gtrauma>><<trauma 3>>
			<<set $children[$childActivityEvent.childid].localVariables.activity to "crying">>
		<</if>>
	/*Wolf Specific*/
	<<case "sleepingStroke">>
		You sit next to the slumbering <<childtype>> and stroke <<childhis>> fur. <<childHe>> snorts in <<childhis>> sleep and pushes back into your caressing hand. You spend a few moments together like this before you get back to your feet. <<lstress>><<stress -5>>
	<<case "cuddleAndNap">>
		The wolf looks at you as you lay down next to it and <<childname>>. The sleepy pair adjust for you to join their cuddling and soon all three of you are snuggled closely together. You enjoy this comfortable moment as long as you can before you have to get up again. <<ltiredness>><<tiredness -6>><<lstress>><<stress -5>>
	<<case "cryingWolf">>
		You sit by the <<childcry>> <<childtype>> and pull <<childhim>> into your lap. You hum soothingly and stroke the <<childtype>>'s fur and give the occasional soft scratch to <<childhis>> ears. <<childname>> slowly grows calm and begins to doze under your gentle attention and soon is asleep. You gingerly place the <<childtype>> down and stand again.
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "playing">>
		You get down on all fours and join <<childname>> and the playing pups with enthusiasm. You encourage excitement and activity in your <<childtype>> as well as the others but ensure to keep the playing friendly and safe. Exhausted the pups take a moment to rest and you kiss <<childname>> on the head before climbing to your feet again. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "curiousGaze">>
		You follow <<childname>>'s gaze until you realise it is watching your legs. You walk in a circle and <<childhis>> eyes never leave your feet. Amused, you take a quick walk around the cave and the <<childtype>> follows you as best it can, constantly transfixed on your movement. Eventually <<childname>> grows bored and tired of this and lays down to rest, <<childhis>> curiosity seemingly sated. <<llstress>><<stress -10>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case"longingGaze">>
		Noticing your <<childtype>>'s longing gaze you approach and reach between <<childhis>> ears and begin to gently scratch. <<childname>>'s tongue lolls from <<childhis>> mouth and <<childhe>> pants happily as you scritch <<childhis>> ears. <<childHe>> gives you a sad look as you finish and walk away.
	<<case"playFighting">>
		You keep a close eye on the two as they tussle playfully. Slowly the two grow tired of each other and playful nips and yips turn into snaps and growls. You go over and separate <<childname>> from <<childhis>> playmate before it can escalate any further, ensuring each has a break from the other and soon enough they are playing amiably again.
		<<set $children[$childActivityEvent.childid].localVariables.activity to "playing">>
	<<case "fieldTrip">>
		You see <<childname>> looking out of the cave curiously and walk over to <<childhim>>. <<childHis>> fascination with the outside world isn't even broken as you bend down and pick <<childhim>> up. You walk outside and take a quick tour of the surrounding area, the <<childtype>>'s eyes wide and scanning over anything and everything with great interest. You finish sating <<childname>>'s curiosity and deposit <<childhim>> back in the cave. <<llstress>><<stress -10>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
	<<case "grumpyWolf">>
		You go over to <<childname>> who growls at you as you approach. Having none of that you flip the grumpy <<childtype>> on <<childhis>> back and begin to rapidly rub <<childhis>> belly. The <<childtype>> resists at first but soon gives in and begins to pant and yip happily thanks to your attention. Finishing you stand up leaving the now cheeful <<childtype>> behind. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "playing">>
	<<case "hungeryWolf">>
		You move over to <<childname>> and see that <<childhe>>'s trying to find a way through the other pups to reach the female wolf's nipples to feed.

		You pick <<childhim>> up and pet him gently, keeping the poor <<childcry>> <<childtype>>'s attention off <<childhis>> hunger. Soon enough several of the feeding pups finish and you put down <<childname>> in front of the female wolf's belly, the <<childtype>> eagerly latching on to one of her nipples and sucking greedily. <<lstress>><<stress -5>>
		<<set $children[$childActivityEvent.childid].localVariables.activity to "sleeping">>
<</switch>>

<<link [[next|Childrens Home]]>><<unset $childActivityEvent>><<endevent>><</link>>