package loot

// Loot tier constants based on EQ2 item quality system
const (
	LootTierTrash      int8 = 0  // Gray items
	LootTierCommon     int8 = 1  // White items
	LootTierUncommon   int8 = 2  // Green items
	LootTierTreasured  int8 = 3  // Blue items
	LootTierRare       int8 = 4  // Purple items
	LootTierLegendary  int8 = 5  // Orange items
	LootTierFabled     int8 = 6  // Yellow items
	LootTierMythical   int8 = 7  // Red items
	LootTierArtifact   int8 = 8  // Artifact items
	LootTierRelic      int8 = 9  // Relic items
	LootTierUltimate   int8 = 10 // Ultimate items
)

// Chest appearance IDs from the C++ implementation
const (
	ChestAppearanceSmall     int32 = 4034 // Small chest for common+ items
	ChestAppearanceTreasure  int32 = 5864 // Treasure chest for treasured+ items
	ChestAppearanceOrnate    int32 = 5865 // Ornate chest for legendary+ items
	ChestAppearanceExquisite int32 = 4015 // Exquisite chest for fabled+ items
)

// Loot generation constants
const (
	DefaultMaxLootItems        int16   = 6     // Default maximum items per loot
	DefaultLootDropProbability float32 = 100.0 // Default probability for loot to drop
	DefaultCoinProbability     float32 = 50.0  // Default probability for coin drops
	MaxGlobalLootTables        int     = 1000  // Maximum number of global loot tables
)

// Database table names
const (
	TableLootTable     = "loottable"
	TableLootDrop      = "lootdrop"
	TableSpawnLoot     = "spawn_loot"
	TableLootGlobal    = "loot_global"
	TableLootTables    = "loot_tables"          // Alternative name
	TableLootDrops     = "loot_drops"           // Alternative name
	TableSpawnLootList = "spawn_loot_list"      // Alternative name
)

// Database column names for loot tables
const (
	ColLootTableID          = "id"
	ColLootTableName        = "name"
	ColLootTableMinCoin     = "mincoin"
	ColLootTableMaxCoin     = "maxcoin"
	ColLootTableMaxItems    = "maxlootitems"
	ColLootTableDropProb    = "lootdrop_probability"
	ColLootTableCoinProb    = "coin_probability"
)

// Database column names for loot drops
const (
	ColLootDropTableID    = "loot_table_id"
	ColLootDropItemID     = "item_id"
	ColLootDropCharges    = "item_charges"
	ColLootDropEquip      = "equip_item"
	ColLootDropProb       = "probability"
	ColLootDropQuestID    = "no_drop_quest_completed_id"
)

// Database column names for spawn loot
const (
	ColSpawnLootSpawnID = "spawn_id"
	ColSpawnLootTableID = "loottable_id"
)

// Database column names for global loot
const (
	ColGlobalLootType   = "type"
	ColGlobalLootTable  = "loot_table"
	ColGlobalLootValue1 = "value1"
	ColGlobalLootValue2 = "value2"
	ColGlobalLootValue3 = "value3"
	ColGlobalLootValue4 = "value4"
)

// Loot flags and special values
const (
	LootFlagNoTrade       uint32 = 1 << 0  // Item cannot be traded
	LootFlagHeirloom      uint32 = 1 << 1  // Item is heirloom (account bound)
	LootFlagTemporary     uint32 = 1 << 2  // Item is temporary
	LootFlagNoValue       uint32 = 1 << 3  // Item has no coin value
	LootFlagNoZone        uint32 = 1 << 4  // Item cannot leave zone
	LootFlagNoDestroy     uint32 = 1 << 5  // Item cannot be destroyed
	LootFlagCrafted       uint32 = 1 << 6  // Item is crafted
	LootFlagArtisan       uint32 = 1 << 7  // Item requires artisan skill
	LootFlagAntique       uint32 = 1 << 8  // Item is antique
	LootFlagMagic         uint32 = 1 << 9  // Item is magic
	LootFlagLegendary     uint32 = 1 << 10 // Item is legendary
	LootFlagDroppable     uint32 = 1 << 11 // Item can be dropped
	LootFlagEquipped      uint32 = 1 << 12 // Item starts equipped
	LootFlagVisible       uint32 = 1 << 13 // Item is visible
	LootFlagUnique        uint32 = 1 << 14 // Only one can be owned
	LootFlagLore          uint32 = 1 << 15 // Item has lore restrictions
)

// Special loot table IDs
const (
	LootTableIDNone     int32 = 0   // No loot table
	LootTableIDGlobal   int32 = -1  // Global loot table marker
	LootTableIDLevel    int32 = -2  // Level-based global loot
	LootTableIDRace     int32 = -3  // Race-based global loot
	LootTableIDZone     int32 = -4  // Zone-based global loot
)

// Loot command types
const (
	LootCommandView      = "view"      // View chest contents
	LootCommandTake      = "take"      // Take specific item
	LootCommandTakeAll   = "take_all"  // Take all items
	LootCommandClose     = "close"     // Close loot window
	LootCommandDisarm    = "disarm"    // Disarm chest trap
	LootCommandLockpick  = "lockpick"  // Pick chest lock
)

// Chest interaction results
const (
	ChestResultSuccess     = 0  // Operation successful
	ChestResultLocked      = 1  // Chest is locked
	ChestResultTrapped     = 2  // Chest is trapped
	ChestResultNoRights    = 3  // No loot rights
	ChestResultEmpty       = 4  // Chest is empty
	ChestResultFailed      = 5  // Operation failed
	ChestResultCantCarry   = 6  // Cannot carry more items
	ChestResultTooFar      = 7  // Too far from chest
	ChestResultInCombat    = 8  // Cannot loot while in combat
)

// Loot distribution methods
const (
	LootDistributionNone        = 0  // No automatic distribution
	LootDistributionFreeForAll  = 1  // Anyone can loot
	LootDistributionRoundRobin  = 2  // Round robin distribution
	LootDistributionMasterLoot  = 3  // Master looter decides
	LootDistributionNeedGreed   = 4  // Need before greed system
	LootDistributionLotto       = 5  // Random lotto system
)

// Loot quality thresholds for different distribution methods
const (
	NeedGreedThreshold   int8 = LootTierTreasured  // Blue+ items use need/greed
	MasterLootThreshold  int8 = LootTierRare       // Purple+ items go to master looter
	LottoThreshold       int8 = LootTierLegendary  // Orange+ items use lotto system
)

// Chest spawn duration and cleanup
const (
	ChestDespawnTime    = 300 // Seconds before chest despawns (5 minutes)
	ChestCleanupTime    = 600 // Seconds before chest is force-cleaned (10 minutes)
	MaxChestsPerZone    = 100 // Maximum number of chests per zone
	MaxChestsPerPlayer  = 10  // Maximum number of chests a player can have loot rights to
)

// Probability calculation constants
const (
	ProbabilityMax     float32 = 100.0 // Maximum probability percentage
	ProbabilityMin     float32 = 0.0   // Minimum probability percentage
	ProbabilityDefault float32 = 50.0  // Default probability for items
)

// Error messages
const (
	ErrLootTableNotFound  = "loot table not found"
	ErrNoLootRights       = "no loot rights for this chest"
	ErrChestLocked        = "chest is locked"
	ErrChestTrapped       = "chest is trapped"
	ErrInventoryFull      = "inventory is full"
	ErrTooFarFromChest    = "too far from chest"
	ErrInCombat           = "cannot loot while in combat"
	ErrInvalidLootTable   = "invalid loot table"
	ErrInvalidItem        = "invalid item in loot table"
	ErrDatabaseError      = "database error during loot operation"
)

// Logging prefixes
const (
	LogPrefixLoot     = "[LOOT]"
	LogPrefixChest    = "[CHEST]"
	LogPrefixDatabase = "[LOOT-DB]"
	LogPrefixGeneration = "[LOOT-GEN]"
)

// Configuration keys for loot system
const (
	ConfigTreasureChestEnabled     = "treasure_chest_enabled"
	ConfigGlobalLootEnabled        = "global_loot_enabled"
	ConfigLootStatisticsEnabled    = "loot_statistics_enabled"
	ConfigChestDespawnTime         = "chest_despawn_time"
	ConfigMaxChestsPerZone         = "max_chests_per_zone"
	ConfigDefaultLootProbability   = "default_loot_probability"
	ConfigDefaultCoinProbability   = "default_coin_probability"
	ConfigLootDistanceCheck        = "loot_distance_check"
	ConfigLootCombatCheck          = "loot_combat_check"
)