package ru.dbotthepony.kstarbound.defs.actor

import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
import com.google.gson.JsonObject
import ru.dbotthepony.kstarbound.defs.AssetPath
import ru.dbotthepony.kstarbound.defs.AssetReference
import ru.dbotthepony.kstarbound.json.builder.JsonFactory

@JsonFactory
data class StatusControllerConfig(
	val statusProperties: JsonObject = JsonObject(),
	val minimumLiquidStatusEffectPercentage: Double,
	val appliesEnvironmentStatusEffects: Boolean,
	val appliesWeatherStatusEffects: Boolean,
	val environmentStatusEffectUpdateTimer: Double = 0.15,
	val primaryAnimationConfig: AssetPath? = null,
	val primaryScriptSources: ImmutableList<AssetPath> = ImmutableList.of(),
	val primaryScriptDelta: Int = 1,
	val keepDamageNotificationSteps: Int = 120,
	val stats: ImmutableMap<String, Stat> = ImmutableMap.of(),
	val resources: ImmutableMap<String, Resource> = ImmutableMap.of(),
) {
	init {
		require(primaryScriptDelta >= 1) { "Non-positive primaryScriptDelta: $primaryScriptDelta" }
		require(keepDamageNotificationSteps >= 1) { "Non-positive keepDamageNotificationSteps: $keepDamageNotificationSteps" }
	}

	@JsonFactory
	data class Stat(
		val baseValue: Double = 0.0,
	)

	@JsonFactory
	data class Resource(
		val maxStat: String? = null,
		val deltaStat: String? = null,
		val maxValue: Double? = null,
		val deltaValue: Double? = null,
		val initialValue: Double? = null,
		val initialPercentage: Double? = null,
	)
}
