package recipes

import "errors"

// Component slot constants
const (
	SlotPrimary = 0 // Primary component slot
	SlotBuild1  = 1 // Build component slot 1
	SlotBuild2  = 2 // Build component slot 2
	SlotBuild3  = 3 // Build component slot 3
	SlotBuild4  = 4 // Build component slot 4
	SlotFuel    = 5 // Fuel component slot
)

// Crafting stage constants
const (
	Stage0 = 0 // First crafting stage
	Stage1 = 1
	Stage2 = 2
	Stage3 = 3
	Stage4 = 4 // Final crafting stage
)

// Recipe validation constants
const (
	MinRecipeID    = 1
	MaxRecipeID    = 2147483647 // int32 max
	MinRecipeLevel = 1
	MaxRecipeLevel = 100
	MinTier        = 1
	MaxTier        = 10
	MaxNameLength  = 256
	MaxStages      = 5
	MaxSlots       = 6
)

// Tradeskill class bitmasks
// These are used to determine which classes can use a recipe
const (
	TradeskillAny       = 3 // 1+2: Any class can use
	TradeskillAdornment = 1 // Adornment recipes
	TradeskillArtisan   = 2 // Base artisan recipes

	// Base tradeskill classes (bits 0-12)
	TradeskillProvisioner = 1 << 0
	TradeskillWoodworker  = 1 << 1
	TradeskillCarpenter   = 1 << 2
	TradeskillOutfitter   = 1 << 3
	TradeskillArmorer     = 1 << 4
	TradeskillWeaponsmith = 1 << 5
	TradeskillTailor      = 1 << 6
	TradeskillScholar     = 1 << 7
	TradeskillJeweler     = 1 << 8
	TradeskillSage        = 1 << 9
	TradeskillAlchemist   = 1 << 10
	TradeskillCraftsman   = 1 << 11
	TradeskillTinkerer    = 1 << 12
)

// Crafting device types
const (
	DeviceNone           = ""
	DeviceStove          = "Stove & Keg"
	DeviceForge          = "Forge"
	DeviceSewingtable    = "Sewing Table & Mannequin"
	DeviceSawbench       = "Woodworking Table"
	DeviceAlchemytable   = "Chemistry Table"
	DeviceJewelersTable  = "Jeweler's Table"
	DeviceLoomandspool   = "Loom & Spinning Wheel"
	DeviceEssencealtar   = "Engraved Desk"
	DeviceTinkerersbench = "Work Bench"
)

// Recipe skill constants (tradeskill IDs)
const (
	SkillProvisioning   = 40   // Food and drink
	SkillWoodworking    = 140  // Wooden items, bows, arrows
	SkillCarpentry      = 80   // Furniture and housing items
	SkillOutfitting     = 120  // Light and medium armor
	SkillArmoring       = 20   // Heavy armor and shields
	SkillWeaponsmithing = 160  // Metal weapons
	SkillTailoring      = 140  // Cloth armor and bags
	SkillScribing       = 340  // Spells and combat arts
	SkillJewelcrafting  = 280  // Jewelry
	SkillAlchemy        = 320  // Potions and poisons
	SkillTinkering      = 360  // Tinkered items
	SkillTransmuting    = 1289 // Transmutation
	SkillAdorning       = 1796 // Adornments
)

// Error variables
var (
	ErrRecipeNotFound          = errors.New("recipe not found")
	ErrRecipeBookNotFound      = errors.New("recipe book not found")
	ErrInvalidRecipeID         = errors.New("invalid recipe ID")
	ErrInvalidRecipeData       = errors.New("invalid recipe data")
	ErrDuplicateRecipe         = errors.New("duplicate recipe ID")
	ErrDuplicateRecipeBook     = errors.New("duplicate recipe book ID")
	ErrMissingComponents       = errors.New("missing required components")
	ErrInsufficientSkill       = errors.New("insufficient skill level")
	ErrWrongTradeskillClass    = errors.New("wrong tradeskill class")
	ErrWrongDevice             = errors.New("wrong crafting device")
	ErrCannotLearnRecipe       = errors.New("cannot learn recipe")
	ErrCannotUseRecipeBook     = errors.New("cannot use recipe book")
	ErrCraftingInProgress      = errors.New("crafting session in progress")
	ErrInvalidCraftingStage    = errors.New("invalid crafting stage")
	ErrCraftingSessionNotFound = errors.New("crafting session not found")
)

// Database table and column names
const (
	TableRecipes              = "recipe"
	TableRecipeComponents     = "recipe_comp_list_item"
	TableRecipeSecondaryComp  = "recipe_secondary_comp"
	TableCharacterRecipes     = "character_recipes"
	TableCharacterRecipeBooks = "character_recipe_books"
	TableItems                = "items"
	TableItemDetailsRecipe    = "item_details_recipe_items"
)
