/*
	Deprecated. Use templates instead.
*/

setup.getGenericAction = function(id){
	let rawAction = Object.assign({id:id},setup.genericActions[id] ?? {});
	if(rawAction.inherit){
		let inheritedAction;
		if(typeof rawAction.inherit == "string")
			inheritedAction = setup.getGenericAction(rawAction.inherit);
		else
		{
			inheritedAction = setup.getGenericAction(rawAction.inherit.id);
			if(rawAction.inherit.effectByInhibition){
				let newEffectByInhibition = {};
				for(const [requiredInhibition,inhibitionEffect] of Object.entries(inheritedAction.effectByInhibition ?? {})){
					let requiredInhibitionAsInt = parseInt(requiredInhibition);
					newEffectByInhibition[requiredInhibitionAsInt + rawAction.inherit.effectByInhibition] = inhibitionEffect;
				}
				inheritedAction.effectByInhibition = newEffectByInhibition;
			}
		}
		delete rawAction.inherit;
		rawAction = Object.assign({},inheritedAction,rawAction);
	}
	return rawAction;
}

setup.getGenericActionApplied = function(id){
	const pc = State.variables.pc;
	let result = setup.getGenericAction(id);

	if(result.effectByInhibition){
		let effectInEffect = {};
		const inhibitionKeys = Object.keys(result.effectByInhibition).map(key=>parseInt(key)).sort((a,b)=>a-b);
		for(const requiredInhibition of inhibitionKeys){
			if(requiredInhibition > pc.pcs_inhib)
				break;
			effectInEffect = result.effectByInhibition[requiredInhibition];
		}
		result = Object.assign({},result,effectInEffect);
		delete result.effectByInhibition;
	}
	return result;
}

setup.genericActions ??= {};

// ----- Indecent Actions -----
/*
	Indecent actions have any of these publicities:
		- publicMany: Performed with a broader audience (3+) of strangers
		- privateMany:Performed with an audience (3+) of (mostly) familiar people
		- public: Performed with 1 or 2 strangers observing
		- private: Performed with 1 or 2 familiar people observing
		- publicRisk: Performed when nobody is observing but there's a risk that a stranger can see you
		- privateRisk: Performed when nobody is observing but there's a risk that a familiar person can see you
*/

setup.genericActions.expose_generic = {
	mood: 50,
	effectByInhibition:{
		"-1000":{
			hidden:true
		},
		20: {
			willpower: 20,
			moodlet: 'embarrassed'
		},
		30: {
			willpower: 10,
		},
		40: {
		},
		100:{}
	}
}

setup.genericActions.exposeBreasts_private = {
	mood: 50,
	effectByInhibition:{
		0:{
			hidden:true
		},
		20: {
			willpower: 20,
			moodlet: 'embarrassed'
		},
		30: {
			willpower: 10,
		},
		40: {
		},
		100:{}
	},
	fame:{'.sex':'small'}
}

setup.genericActions.exposePanties_generic = {
	inherit: {
		id: 'expose_generic',
		effectByInhibition: -10
	}
}

setup.genericActions.exposePanties_private = {
	inherit: {
		id: 'exposePanties_generic',
		effectByInhibition: 0
	},
	fame:{'.sex':'tiny'}
}

setup.genericActions.exposePussy_generic = {
	inherit: {
		id: 'expose_generic',
		effectByInhibition: 10
	}
}

setup.genericActions.exposePussy_private = {
	inherit: {
		id: 'exposePussy_generic',
		effectByInhibition: 0
	},
	fame:{'.sex':'medium'}
}