// @ts-check

/**
 * Configuration for the Undead Golem behavior
 * Contains probability constants for anger increases and thresholds for actions
 */

/**
 * Probabilities for the golem to increase its anger level in different situations
 * Values range from 0 to 1 (0% to 100% chance)
 */
export const ANGER_PROBABILITIES = {
	// Chance to increase anger when the golem takes damage
	DAMAGE_TAKEN: 0.2,

	// Chance to increase anger when the golem is seen or approached by players
	ENTITY_SEEN: 0.9,

	// Chance to increase anger when the golem despawns
	DESPAWNING: 0.6,

	// Chance to increase anger when a player kills an undead villager. This chance only
	// applies if previous roll of spawning the golem was successful and when the player
	// was already being stalked by a golem.
	VILLAGER_KILLED: 1.0,
};

/**
 * Anger level ranges for different golem actions
 * These determine what the golem can do at each anger level range
 */
export const ANGER_RANGES = {
	// Anger level range for being creepy but harmless
	CREEPY: { min: 0, max: 4 },

	// Anger level range for attacking pets
	ATTACK_PETS: { min: 3, max: 7 },

	// Anger level range for attacking the player once
	ATTACK_PLAYER_ONCE: { min: 4, max: 10 },

	// Anger level range for killing the player
	KILL_PLAYER: { min: 6, max: Number.MAX_SAFE_INTEGER },
};

/**
 * Maximum age in seconds before the golem despawns based on its state
 */
export const DESPAWN_AGE = {
	// Maximum age for a golem in creepy state before despawning
	CREEPY_STATE: 45,

	// Maximum age for a golem in default state before despawning
	DEFAULT_STATE: 120,
};

/**
 * Random encounter timing configuration
 */
export const ENCOUNTER_TIMING = {
	// How often (in seconds) the system checks for potential random encounters. Should
	// divide evenly into REFERENCE_PERIOD
	CHECK_PERIOD: 10,

	// The target probability (0-1) of a random encounter occurring within the reference period
	TARGET_PROBABILITY: 0.6,

	// The reference time period (in seconds) for the TARGET_PROBABILITY
	// For example, if REFERENCE_PERIOD is 60 and TARGET_PROBABILITY is 0.6,
	// there's a 60% chance of an encounter happening within 60 seconds
	REFERENCE_PERIOD: 60,
};

/**
 * Health thresholds that trigger minimum anger levels when the golem despawns
 * If the golem's health is below a threshold, its anger level will be set to at least
 * the corresponding minimum anger level
 */
export const HEALTH_ANGER_THRESHOLDS = {
	// Health percentage thresholds (0.0 to 1.0) mapped to minimum anger levels
	// When the golem despawns, if its health percentage is below a threshold,
	// its anger level will be set to at least the corresponding value
	THRESHOLDS: [
		{ healthPercentage: 0.75, minAngerLevel: 3 },
		{ healthPercentage: 0.5, minAngerLevel: 4 },
		{ healthPercentage: 0.25, minAngerLevel: 6 },
	],
};
