package alt_advancement

// AA tab/group constants based on group # from DB
const (
	AA_CLASS               = 0 // Class-specific advancement trees
	AA_SUBCLASS            = 1 // Subclass-specific advancement trees
	AA_SHADOW              = 2 // Shadows advancement (from Shadows of Luclin)
	AA_HEROIC              = 3 // Heroic advancement (from Destiny of Velious)
	AA_TRADESKILL          = 4 // Tradeskill advancement trees
	AA_PRESTIGE            = 5 // Prestige advancement (from Destiny of Velious)
	AA_TRADESKILL_PRESTIGE = 6 // Tradeskill prestige advancement
	AA_DRAGON              = 7 // Dragon advancement
	AA_DRAGONCLASS         = 8 // Dragon class-specific advancement
	AA_FARSEAS             = 9 // Far Seas advancement
)

// AA tab names for display
var AATabNames = map[int8]string{
	AA_CLASS:               "Class",
	AA_SUBCLASS:            "Subclass",
	AA_SHADOW:              "Shadows",
	AA_HEROIC:              "Heroic",
	AA_TRADESKILL:          "Tradeskill",
	AA_PRESTIGE:            "Prestige",
	AA_TRADESKILL_PRESTIGE: "Tradeskill Prestige",
	AA_DRAGON:              "Dragon",
	AA_DRAGONCLASS:         "Dragon Class",
	AA_FARSEAS:             "Far Seas",
}

// Maximum AA values per tab (from C++ packet data)
const (
	MAX_CLASS_AA               = 100 // 0x64
	MAX_SUBCLASS_AA            = 100 // 0x64
	MAX_SHADOWS_AA             = 70  // 0x46
	MAX_HEROIC_AA              = 50  // 0x32
	MAX_TRADESKILL_AA          = 40  // 0x28
	MAX_PRESTIGE_AA            = 25  // 0x19
	MAX_TRADESKILL_PRESTIGE_AA = 25  // 0x19
	MAX_DRAGON_AA              = 100 // Estimated
	MAX_DRAGONCLASS_AA         = 100 // Estimated
	MAX_FARSEAS_AA             = 100 // Estimated
)

// AA template constants
const (
	AA_TEMPLATE_PERSONAL_1 = 1 // Personal template 1
	AA_TEMPLATE_PERSONAL_2 = 2 // Personal template 2
	AA_TEMPLATE_PERSONAL_3 = 3 // Personal template 3
	AA_TEMPLATE_SERVER_1   = 4 // Server template 1
	AA_TEMPLATE_SERVER_2   = 5 // Server template 2
	AA_TEMPLATE_SERVER_3   = 6 // Server template 3
	AA_TEMPLATE_CURRENT    = 7 // Current active template
	MAX_AA_TEMPLATES       = 8 // Maximum number of templates
)

// AA template names
var AATemplateNames = map[int8]string{
	AA_TEMPLATE_PERSONAL_1: "Personal 1",
	AA_TEMPLATE_PERSONAL_2: "Personal 2",
	AA_TEMPLATE_PERSONAL_3: "Personal 3",
	AA_TEMPLATE_SERVER_1:   "Server 1",
	AA_TEMPLATE_SERVER_2:   "Server 2",
	AA_TEMPLATE_SERVER_3:   "Server 3",
	AA_TEMPLATE_CURRENT:    "Current",
}

// AA prerequisite constants
const (
	AA_PREREQ_NONE        = 0 // No prerequisite
	AA_PREREQ_EXPANSION   = 1 // Requires specific expansion
	AA_PREREQ_LEVEL       = 2 // Requires minimum level
	AA_PREREQ_CLASS       = 3 // Requires specific class
	AA_PREREQ_POINTS      = 4 // Requires points spent in tree
	AA_PREREQ_ACHIEVEMENT = 5 // Requires achievement completion
)

// Expansion requirement flags
const (
	EXPANSION_NONE = 0x00 // No expansion required
	EXPANSION_KOS  = 0x01 // Kingdom of Sky required
	EXPANSION_EOF  = 0x02 // Echoes of Faydwer required
	EXPANSION_ROK  = 0x04 // Rise of Kunark required
	EXPANSION_TSO  = 0x08 // The Shadow Odyssey required
	EXPANSION_SF   = 0x10 // Sentinel's Fate required
	EXPANSION_DOV  = 0x20 // Destiny of Velious required
	EXPANSION_COE  = 0x40 // Chains of Eternity required
	EXPANSION_TOV  = 0x80 // Tears of Veeshan required
)

// AA node positioning constants
const (
	MIN_AA_COL = 0  // Minimum column position
	MAX_AA_COL = 10 // Maximum column position
	MIN_AA_ROW = 0  // Minimum row position
	MAX_AA_ROW = 15 // Maximum row position
)

// AA cost and rank constants
const (
	MIN_RANK_COST   = 1   // Minimum cost per rank
	MAX_RANK_COST   = 10  // Maximum cost per rank
	MIN_MAX_RANK    = 1   // Minimum maximum rank
	MAX_MAX_RANK    = 20  // Maximum maximum rank
	MIN_TITLE_LEVEL = 1   // Minimum title level
	MAX_TITLE_LEVEL = 100 // Maximum title level
)

// AA packet operation codes
const (
	OP_ADVENTURE_LIST = 0x023B // Adventure list packet opcode
	OP_AA_UPDATE      = 0x024C // AA update packet opcode
	OP_AA_PURCHASE    = 0x024D // AA purchase packet opcode
)

// AA display modes
const (
	AA_DISPLAY_NEW    = 0 // New template display
	AA_DISPLAY_CHANGE = 1 // Change template display
	AA_DISPLAY_UPDATE = 2 // Update existing display
)

// AA validation constants
const (
	MIN_SPELL_ID = 1          // Minimum valid spell ID
	MAX_SPELL_ID = 2147483647 // Maximum valid spell ID
	MIN_NODE_ID  = 1          // Minimum valid node ID
	MAX_NODE_ID  = 2147483647 // Maximum valid node ID
)

// AA processing constants
const (
	AA_PROCESSING_BATCH_SIZE = 100   // Batch size for processing AAs
	AA_CACHE_SIZE            = 10000 // Cache size for AA data
	AA_UPDATE_INTERVAL       = 1000  // Update interval in milliseconds
)

// AA error codes
const (
	AA_ERROR_NONE                = 0  // No error
	AA_ERROR_INVALID_SPELL_ID    = 1  // Invalid spell ID
	AA_ERROR_INVALID_NODE_ID     = 2  // Invalid node ID
	AA_ERROR_INSUFFICIENT_POINTS = 3  // Insufficient AA points
	AA_ERROR_PREREQ_NOT_MET      = 4  // Prerequisites not met
	AA_ERROR_MAX_RANK_REACHED    = 5  // Maximum rank already reached
	AA_ERROR_INVALID_CLASS       = 6  // Invalid class for this AA
	AA_ERROR_EXPANSION_REQUIRED  = 7  // Required expansion not owned
	AA_ERROR_LEVEL_TOO_LOW       = 8  // Character level too low
	AA_ERROR_TREE_LOCKED         = 9  // AA tree is locked
	AA_ERROR_DATABASE_ERROR      = 10 // Database operation failed
)

// AA statistic tracking constants
const (
	STAT_TOTAL_AAS_LOADED    = "total_aas_loaded"
	STAT_TOTAL_NODES_LOADED  = "total_nodes_loaded"
	STAT_AAS_PER_TAB         = "aas_per_tab"
	STAT_PLAYER_AA_PURCHASES = "player_aa_purchases"
	STAT_CACHE_HITS          = "cache_hits"
	STAT_CACHE_MISSES        = "cache_misses"
	STAT_DATABASE_QUERIES    = "database_queries"
)

// Default AA configuration values
const (
	DEFAULT_ENABLE_AA_SYSTEM     = true
	DEFAULT_ENABLE_AA_CACHING    = true
	DEFAULT_ENABLE_AA_VALIDATION = true
	DEFAULT_ENABLE_AA_LOGGING    = false
	DEFAULT_AA_POINTS_PER_LEVEL  = 2
	DEFAULT_AA_MAX_BANKED_POINTS = 30
)
