:: pirsingsalon_widgets[widget]
	<<widget 'piercingImage'>>
		<<set _tattooImage_position = _args[0]>>
		<<set _tattooImage_index = _args[1]>>
		<<image setup.getDeco('piercing',_tattooImage_position,_tattooImage_index).image>>
	<</widget>>
	<<widget 'tattooImage'>>
		<<set _tattooImage_position = _args[0]>>
		<<set _tattooImage_index = _args[1]>>
		<<image setup.getDeco('tattoo',_tattooImage_position,_tattooImage_index).image>>
	<</widget>>

:: pirsingsalon[indoors public]

<!-- !! Piercings variables:-->
<!-- !! pirsX: Which piercing is worn at position X-->
<!-- !! X=-->
<!-- !! A: Tongue-->
<!-- !! B: Lip-->
<!-- !! C: Ear-->
<!-- !! D: Nose-->
<!-- !! E: Eyebrow-->
<!-- !! F: Nipple-->
<!-- !! G: Pussy-->
<!-- !! N: Navel-->
<!-- !! pirsX = 10000: the body is pieced at X but no piercing is currently worn there-->

	<<ConnectedLocation 'Leave' 'city_industrial' '' 'locations/city/industrial/nord.jpg' 5>>
	<h2>Tattoo & Piercing Salon</h2>
	<<image 'locations/city/industrial/salon/pirsingstudia.webp'>>
	<p>
		A small studio with just one artist doing the tattoos and piercings.
		He greets you with a smirk and explains his services and prices to you.
	</p>
	<<act 'Piercing'>>
		<<gt 'pirsingsalon_piercing'>>
	<</act>>
	<<act 'Tattoo'>>
		<<gt 'pirsingsalon_tattoo'>>
	<</act>>

:: pirsingsalon_piercing[indoors public]
	<<ConnectedLocation 'Leave' 'city_industrial' '' 'locations/city/industrial/nord.jpg' 5>>
	<h2>Piercings</h2>
	<<image 'locations/city/industrial/salon/pirsingstudia.webp'>>

	<table>
		<tr><th>Type</th><th>Price</th></tr>
		<<for _position range setup.getDecoPositions('piercing')>>
			<<set _data = setup.getDecoPosition('piercing',_position)>>
			<tr><td>_data.label</td><td><<money _data.price>></td></tr>
			<<act `_data.label+' Piercing'` undefined `{capture:['_position']}`>><<gt 'pirsingsalon_piercing_list' _position>><</act>>
		<</for>>
	</table>

	<<act 'Tattoos'>>
		<<gt 'pirsingsalon_tattoo'>>
	<</act>>

:: pirsingsalon_piercing_list[event]
	<<act 'Back'>><<gt 'pirsingsalon_piercing'>><</act>>
	<<set _type = $location_var[$here][0]>>
	<<set _price = setup.getDecoPosition('piercing',_type).price>>
	<<if (_currentPiercing = $pc.decoGet('piercing',_type))>>
		<p>You already have the necessary piercing.</p>
		<<if _currentPiercing == -1>>
			<p>It is currently empty. You could buy some jewelry for it from the list below:</p>
		<<else>>
			<p>You are currently wearing:</p>
			<<piercingImage _type $pc.decoGet('piercing',_type)>>
			<p>You could replace it by buying a new piercing from the list below:</p>
		<</if>>
	<<else>>
		<p>You need to get the piercing first. You can purchase it with jewelry to fill it:</p>
		<<set _onlyPiercingPrice = Math.round(_price/2)>>
		<<act 'Piercing without jewelry' undefined `{cost:{cash:_onlyPiercingPrice}}`>>
			<<gt 'pirsingsalon_piercing_get' _type -1>>
		<</act>>
	<</if>>

	<<set _otherDecosOwned = []>>
	<div class="squargrid" style="--itemWidth:10em">
		<<for _i = 1; _i <= setup.getDecoPosition('piercing',_type).count; _i += 1>>
			<<if !$pc.decoHas('piercing',_type,_i)>>
				<div class="linkedImage">
					<<piercingImage _type _i>>
					<<capture _i>>
						<<link "">><<gt 'pirsingsalon_piercing_details' _type _i>><</link>>
					<</capture>>
				</div>
			<<elseif _currentPiercing != _i>>
				<<run _otherDecosOwned.push(_i)>>
			<</if>>
		<</for>>
	</div>
	<<if _otherDecosOwned.length > 0>>
		<p>You also own the following piercings. You can switch them here and at every bathroom.</p>
		<div class="squargrid" style="--itemWidth:10em">
			<<for _i  range _otherDecosOwned>>
				<div class="linkedImage">
					<<piercingImage _type _i>>
					<<capture _i>>
						<<link "">>
							<<run $pc.decoSet('piercing',_type,_i)>>
							<<refresh>>
						<</link>>
					<</capture>>
				</div>
			<</for>>
		</div>
	<</if>>

:: pirsingsalon_piercing_details[event]
	<<set _type = $location_var[$here][0]>>
	<<set _index = $location_var[$here][1]>>
	<<set _price = setup.getDecoPosition('piercing',_type).price>>
	<<set _buyOnlyPrice = Math.round(_price/2)>>
	<<set _bodyPart = setup.getDecoPosition('piercing',_type).bodyPart>>
	<<piercingImage _type _index>>
	<<set _currentPiercing = $pc.decoGet('piercing',_type)>>

	<<if !_currentPiercing>>
		<p>You need the piercing before you can wear this.</p>

		<<if $pc.pain(_bodyPart) >= 5>>
			<p>But your _bodyPart hurt too much already. You don't feel like making it worse.</p>
			<<set _disabled = true>>
		<</if>>

		<<if !_disabled>>
			<<act 'Get the piercing' undefined `{cost:{cash:_price}}`>>
				<<gt 'pirsingsalon_piercing_get' _type _index>>
			<</act>>
		<</if>>
	<<elseif _currentPiercing == _index>>
		<p>You are already wearing this. There is no sense in buying it again.</p>
	<<else>>
		<<if _currentPiercing == -1>>
			<p>You have the required piercing and it is currently empty.</p>
		<<else>>
			<p>You have the required piercing and you are currently wearing other jewelry in it.</p>
		<</if>>
		<<act 'Buy and wear' undefined `{cost:{cash:_buyOnlyPrice}}`>>
			<<run $pc.decoAdd('piercing',_type,_index)>>
			<<run $pc.decoSet('piercing',_type,_index)>>
			<<gt 'pirsingsalon_piercing_list' _type>>
		<</act>>
	<</if>>


	<<act 'Back'>><<gt 'pirsingsalon_piercing_list' _type>><</act>>

:: pirsingsalon_piercing_get[event]
	<<set _type = $location_var[$here][0]>>
	<<set _index = $location_var[$here][1]>>

	<<set _getTime = setup.getDecoPosition('piercing',_type).getTime ?? 60>>
	<<set _getImage = setup.getDecoPosition('piercing',_type).getImage>>
	<<set _bodyPart = setup.getDecoPosition('piercing',_type).bodyPart>>
	<<set _pain = setup.getDecoPosition('piercing',_type).pain ?? 40>>

	<<image _getImage>>
	<<addtime _getTime>>
	<<run $pc.painInc(_bodyPart,'piercing',_pain)>>
	<<run $pc.decoSet('piercing',_type,_index)>>
	<<if _index > 0>>
		<<run $pc.decoAdd('piercing',_type,_index)>>
	<</if>>

	<p>
		It takes a while, but after<<duration _getTime>> your new piercing is finally done.
	</p>

	<<act 'Back'>><<gt 'pirsingsalon_piercing_list' _type>><</act>>

:: pirsingsalon_tattoo[indoors public]
	<<ConnectedLocation 'Leave' 'city_industrial' '' 'locations/city/industrial/nord.jpg' 5>>
	<h2>Tattoos</h2>
	<<image 'locations/city/industrial/salon/pirsingstudia.webp'>>

	<table>
		<tr><th>Type</th><th>Price</th></tr>
		<<for _type range setup.getDecoPositions('tattoo')>>
			<<set _data = setup.getDecoPosition('tattoo',_type)>>
			<tr><td>_data.label</td><td><<money _data.price>></td></tr>
			<<act `_data.label+' Tattoo'` undefined `{capture:['_type']}`>><<gt 'pirsingsalon_tattoo_list' _type>><</act>>
		<</for>>
	</table>

	<<act 'Piercings'>>
		<<gt 'pirsingsalon_piercing'>>
	<</act>>

:: pirsingsalon_tattoo_list[event]
	<<act 'Back'>><<gt 'pirsingsalon_tattoo'>><</act>>
	<p>The tattooist shows you a list of available options.</p>
	<<set _type = $location_var[$here][0]>>
	<div class="squargrid" style="--itemWidth:10em">
		<<for _i = 1; _i <= setup.getDecoPosition('tattoo',_type).count; _i += 1>>
			<div class="linkedImage">
				<<tattooImage _type _i>>
				<<capture _i>>
					<<link "">><<gt 'pirsingsalon_tattoo_details' _type _i>><</link>>
				<</capture>>
			</div>
		<</for>>
	</div>
	<<if $pc.decoGet('tattoo',_type)>>
		<hr/>
		<p>You already have a tattoo at this position. Overpainting and replacing it will be more expensive.</p>
		<p>Your current tattoo:</p>
		<<tattooImage _type $pc.decoGet('tattoo',_type)>>
	<</if>>

:: pirsingsalon_tattoo_details[event]
	<<set _type = $location_var[$here][0]>>
	<<set _index = $location_var[$here][1]>>
	<<set _price = setup.getDecoPosition('tattoo',_type).price>>
	<<set _bodyPart = setup.getDecoPosition('tattoo',_type).bodyPart>>
	<<tattooImage _type _index>>

	<<set _currentTattoo = $pc.decoGet('tattoo',_type)>>
	<<if _currentTattoo == _index>>
		<p>You already have this exact tattoo.</p>
		<<set _disabled = true>>
	<<elseif _currentTattoo>>
		<p>You already have tattoo at this location. Overpainting and replacing it will be twice as expensive.</p>
		<<set _price *= 2>>
	<</if>>

	<<if $pc.pain(_bodyPart) >= 5>>
		<p>Your _bodyPart hurt too much already. You don't feel like making it worse.</p>
		<<set _disabled = true>>
	<</if>>

	<<act 'Back'>><<gt 'pirsingsalon_tattoo_list' _type>><</act>>
	<<if !_disabled>>
		<<act 'Get this tattoo' undefined `{cost:{cash:_price}}`>>
			<<gt 'pirsingsalon_tattoo_get' _type _index>>
		<</act>>
	<</if>>


:: pirsingsalon_tattoo_get[event]
	<<set _type = $location_var[$here][0]>>
	<<set _index = $location_var[$here][1]>>

	<<set _getTime = setup.getDecoPosition('tattoo',_type).getTime ?? 60>>
	<<set _getImage = setup.getDecoPosition('tattoo',_type).getImage>>
	<<set _bodyPart = setup.getDecoPosition('tattoo',_type).bodyPart>>
	<<set _pain = setup.getDecoPosition('tattoo',_type).pain ?? 40>>

	<<image _getImage>>
	<<addtime _getTime>>
	<<run $pc.painInc(_bodyPart,'tattoo',_pain)>>
	<<run $pc.decoSet('tattoo',_type,_index)>>

	<p>
		It takes a while, but after<<duration _getTime>> your new tattoo is finally done.
	</p>

	<<act 'Back'>><<gt 'pirsingsalon_tattoo_list' _type>><</act>>
