:: arousal_widgets[widget]
<<widget 'arouse'>>
	<<set _act = _args[0]>>
	<<set _duration = _args[1] ?? 10>>
	<<set _fetishes = _args[2] ?? []>>
	<<set _npcID = _args[3]>>
	<<set _flags = _args[4] ?? {}>>

	<<addtime _duration>>

	<<run console.warn('Usage of "<<arouse>>" is deprecated. Use "<<aroursal>> instead."',_args)>>

	<<set _flags = Object.assign({time:_duration,npc:_npcID,fetishes:_fetishes},_flags)>>
	<<arousal _act _flags>>

<</widget>>

<<widget 'arousal'>>
	/*
		Flags:
			fetishes	Array<string>
	 */

	<<set [_arousalId, _arousalFlags] = _args>>
	<<set _arousalFlags ??= {}>>

	<<set _actData = setup.arousal[_arousalId]>>
	<<if !_actData>>
		<<warn `'Stimulation data not found for "'+_act+'"'`>>
		<<set _actData = {}>>
	<</if>>

	<<if _actData.deprecated>>
		<<warn `'Arousal-Act is deprecated: "'+_act+'"'`>>
	<</if>>
	
	/*<<set _stimulation_act = _actData.stimulation ?? 20>>
	<<set _magnitude += _actData.magnitude ?? 0>>
	<<set _orgasm_flags = _actData.orgasm_flag ?? []>>

	<<if _insertion = _actData.insertion>>


		<<if _actData.npcIsToy>>
			<<set _toyData = $inventory.metadata(_npcID)>>
			<<set _length = _toyData.length ?? 10>>
			<<set _girth = _toyData.girth ?? _length / 5>>
		<<elseif _actData.isFist>>
			<<set _length = 30>>
			<<set _girth = 10>>
		<<else>>
			<<set _length = $npcs.get(_npcID,'dick',10)>>
			<<set _girth = $npcs.get(_npcID,'dick_girth',_length / 5)>>
		<</if>>

		<<switch _insertion>>
			<<case 'anal'>>
				<<set _stimulation_act = 40>>
				
			<<case 'vaginal'>>
				<<set _stimulation_act = 80>>
		<</switch>>
	<</if>>


	<<set _stimulation_kink = 100>>
	<<set _stimulation_preference = 1>>



	<<set _stimulation_total = ((_magnitude * _stimulation_act * _stimulation_kink/100) + _stimulation_preference) * _duration / 120>>

	<<run console.log('Arouse',{
		act: _act,
		stimulation_total:_stimulation_total,
		magnitude: _magnitude,
		stimulation_act: _stimulation_act,
		stimulation_kink: _stimulation_kink,
		stimulation_preference: _stimulation_preference,
		duration: _duration,
		orgasm_flags: _orgasm_flags
	})>>*/

	<<set _stimulation_total = _actData.stimulation>>
	<<set _arousalDesc = ''>>

	<<set _cycleArousalModificator = $pc.cycleArousalModificator>>
	<<set _fetishModificator = $pc.fetishes(_arousalFlags.fetishes ?? [])>>

	<<if _fetishModificator > 0>>
		<<set _stimulation_total *= _cycleArousalModificator.factor * _fetishModificator>>
	<<elseif _fetishModificator == 0>>
		<<set _stimulation_total = 0>>
	<<else>>
		<<set _stimulation_total *= _fetishModificator>>
	<</if>>

	<<set _orgasm_flags = _actData.orgasm ?? []>>
	<<set _orgasmEnabled = (_orgasm_flags.length > 0)>>

	<<set $pc.horny += _stimulation_total>>

	<<set _orgasm = false>>
	<<if $pc.horny >= 100 && _orgasmEnabled>>
		<<set _orgasm = true>>
	<</if>>

	<<if 'orgasm' in _arousalFlags>>
		<<if _arousalFlags.orgasm == 'force'>>
			<<set _orgasm = true>>
		<<elseif !_arousalFlags.orgasm>>
			<<set _orgasm = false>>
		<</if>>
	<</if>>


    <<set _arousalStyleClass = 'arouse'>>

	<<if _stimulation_total < 0>>
		<<set _arousalStyleClass += ' appall'>>
	<</if>>

    <<set _arousalTitle = _actData.caption ?? _arousalId.toLocaleUpperFirst()>>

	<div @class="_arousalStyleClass">
		<span class="effect"><<if _stimulation_total > 0>>+<</if>><<=Math.round(_stimulation_total)>></span>
		<span class="title">
			_arousalTitle
		</span>
		<span class="description">_arousalDesc</span>
		<span class="symbols">
			<<textWithTooltip "❤️">>
				<h3>Arouse</h3>
				This is a arousal-effect.
				<p></p>
			<</textWithTooltip>>

			<<if _orgasmEnabled>>
				<<textWithTooltip "😍">>
					<h3>Orgasm</h3>
					This effect has the potential of letting you experience an orgasm.
					This is usually limited to direct interactions with your genitals.
				<</textWithTooltip>>
			<</if>>

			<<if false>>
				<<textWithTooltip "👩‍❤️‍👨">>
					<h3>Attraction</h3>
					This effect is increased because a NPC you are attracted to is involved.
				<</textWithTooltip>>
			<</if>>

			<<if _cycleArousalModificator.factor > 1>>
				<<textWithTooltip "💓">>
					<h3>High Fertility</h3>
					<p>You are currently easier to arouse because you are close to ovulation.</p>
					<p>Your chance of getting pregnant is at its' maximum.</p>
				<</textWithTooltip>>
			<<elseif _cycleArousalModificator.factor < 1>>
				<<textWithTooltip "🤍">>
					<h3>Low Fertility</h3>
					<p>You are currently harder to arouse because of your ovulation cycle.</p>
					<p>The risk of getting pregnant is minimal but not zero now.</p>
				<</textWithTooltip>>
			<</if>>
			
		</span>
	</div>

	<<if _orgasm>>
		<<mood 'orgasm'>>
		<<set $pc.horny = 0>>
	<</if>>

<</widget>>

:: arouse_test[private indoors]

<<arousal 'clit_finger'>>