class Sex{

	npcId = '';
	history = [];
	scenarioId = '';

	arousals = {};

	reaction(reactionId){
		return Object.assign({id:reactionId},setup.sexReactions[reactionId]);
	}

	reactions(scenarioId=undefined){
		scenarioId ??= this.scenarioId;
		return this.scenario(scenarioId).reactions.map(reactionId=>this.reaction(reactionId));
	}

	scenario(scenarioId=undefined){
		scenarioId ??= this.scenarioId;
		return setup.sexScenarios[scenarioId];
	}

	situationNext(scenarioId){
		scenarioId ??= this.scenarioId;
		return this.situations(scenarioId).getRandomWeighted();
	}

	situation(situationId){
		return Object.assign({id:situationId},setup.sexSituations[situationId]);
	}

	situations(scenarioId=undefined){
		scenarioId ??= this.scenarioId;
		return this.scenario(scenarioId).situations.map(situationId=>this.situation(situationId));
	}

	constructor(data=undefined){
		if(data)
			this._init(data);
	}

	_init(sex){
		Object.keys(sex).forEach(function (pn) {
			this[pn] = clone(sex[pn]);
		}, this);

		return this;
	}

	clone = function () {
		return (new setup.Sex())._init(this);
	};

	toJSON = function () {
		var ownData = {};
		Object.keys(this).forEach(function (pn) {
			if(typeof this[pn] !== "function")
				ownData[pn] = clone(this[pn]);
		}, this);
		return JSON.reviveWrapper('(new setup.Sex())._init($ReviveData$)', ownData);
	};
}

setup.Sex = Sex;