-- ══════════════════════════════════════════════════════════════
-- MODUL: ExpansionData – Expansion-spezifische Zonendaten
-- Gefahrenzonen, Level-Ranges, Raidnamen pro Expansion.
-- Wird von DangerZone und ZoneWarning als Pre-Seed verwendet.
-- ══════════════════════════════════════════════════════════════

local addonName, addon = ...
local GDL = _G["GuildDeathLog"]
local ExpansionData = {}

-- ══════════════════════════════════════════════════════════════
-- CLASSIC ERA – Vanilla (Interface 11xxx)
-- ══════════════════════════════════════════════════════════════
ExpansionData.CLASSIC = {
    dangerZones = {
        -- Raids (instant tod bei falschem Zug)
        ["Molten Core"]            = 3,
        ["Blackwing Lair"]         = 3,
        ["Zul'Gurub"]              = 3,
        ["Ruins of Ahn'Qiraj"]     = 3,
        ["Ahn'Qiraj"]              = 3,
        ["Naxxramas"]              = 3,
        -- High-Level Dungeons
        ["Scholomance"]            = 2,
        ["Stratholme"]             = 2,
        ["Blackrock Spire"]        = 2,
        ["Dire Maul"]              = 2,
        ["Sunken Temple"]          = 2,
        -- Elite-Außengebiete
        ["Winterspring"]           = 2,
        ["Eastern Plaguelands"]    = 2,
        ["Western Plaguelands"]    = 2,
        ["Silithus"]               = 2,
        ["Blackrock Mountain"]     = 3,
    },
    levelZones = {
        -- Anfänger-Zonen (Lvl 1-10)
        ["Elwynn Forest"]          = { min = 1,  max = 10 },
        ["Dun Morogh"]             = { min = 1,  max = 10 },
        ["Teldrassil"]             = { min = 1,  max = 10 },
        ["Durotar"]                = { min = 1,  max = 10 },
        ["Mulgore"]                = { min = 1,  max = 10 },
        ["Tirisfal Glades"]        = { min = 1,  max = 10 },
        -- Mid-Level
        ["Stranglethorn Vale"]     = { min = 30, max = 45 },
        ["Un'Goro Crater"]         = { min = 48, max = 55 },
        -- Endgame
        ["Burning Steppes"]        = { min = 52, max = 58 },
        ["Eastern Plaguelands"]    = { min = 54, max = 60 },
        ["Winterspring"]           = { min = 55, max = 60 },
        ["Silithus"]               = { min = 55, max = 60 },
    },
    raidNames = {
        "Molten Core", "Blackwing Lair", "Zul'Gurub",
        "Ruins of Ahn'Qiraj", "Ahn'Qiraj", "Naxxramas",
    },
    expansion = "classic",
}

-- ══════════════════════════════════════════════════════════════
-- THE BURNING CRUSADE (Interface 205xx)
-- ══════════════════════════════════════════════════════════════
ExpansionData.TBC = {
    dangerZones = {
        -- Raids (alle extrem gefährlich)
        ["Black Temple"]           = 3,
        ["Sunwell Plateau"]        = 3,
        ["The Eye"]                = 3,
        ["Tempest Keep"]           = 3,
        ["Serpentshrine Cavern"]   = 3,
        ["Coilfang Reservoir"]     = 3,
        ["Mount Hyjal"]            = 3,
        ["Battle for Mount Hyjal"] = 3,
        ["Magtheridon's Lair"]     = 3,
        ["Gruul's Lair"]           = 3,
        -- Dungeons (Heroic-Modus = extrem)
        ["The Arcatraz"]           = 2,
        ["The Mechanar"]           = 2,
        ["The Botanica"]           = 2,
        ["Shadow Labyrinth"]       = 2,
        ["Shattered Halls"]        = 2,
        ["The Steamvault"]         = 2,
        -- Außengebiete mit starken Elites
        ["Shadowmoon Valley"]      = 3,  -- Black Temple-Elites
        ["Isle of Quel'Danas"]     = 3,  -- Sunwell-Mobs, extrem dicht
        ["Netherstorm"]            = 2,  -- Arkane Elites
        ["Blade's Edge Mountains"] = 2,  -- Gruul-Elite-Bereich
        ["Hellfire Peninsula"]     = 2,  -- Erste Outland-Zone, dichte Elites
        ["Terokkar Forest"]        = 2,  -- Bone Wastes, starke Undead
    },
    levelZones = {
        -- TBC Startbereich
        ["Hellfire Peninsula"]     = { min = 58, max = 63 },
        ["Zangarmarsh"]            = { min = 60, max = 64 },
        ["Terokkar Forest"]        = { min = 62, max = 65 },
        ["Nagrand"]                = { min = 64, max = 67 },
        ["Blade's Edge Mountains"] = { min = 65, max = 68 },
        ["Netherstorm"]            = { min = 67, max = 70 },
        ["Shadowmoon Valley"]      = { min = 67, max = 70 },
        ["Isle of Quel'Danas"]     = { min = 70, max = 70 },
        -- Classic-Zonen bleiben auch relevant
        ["Outland"]                = { min = 58, max = 70 },
    },
    raidNames = {
        "Black Temple", "Sunwell Plateau", "The Eye", "Tempest Keep",
        "Serpentshrine Cavern", "Battle for Mount Hyjal",
        "Magtheridon's Lair", "Gruul's Lair",
    },
    expansion = "tbc",
    -- TBC-spezifisch: kein Blizzard HC-Mode
    hasOfficialHC = false,
    -- Outland-Startzone für Neuankömmlinge
    entryZone = "Hellfire Peninsula",
}

-- ══════════════════════════════════════════════════════════════
-- WRATH OF THE LICH KING (Interface 304xx)
-- ══════════════════════════════════════════════════════════════
ExpansionData.WRATH = {
    dangerZones = {
        ["Icecrown Citadel"]       = 3,
        ["Ulduar"]                 = 3,
        ["Trial of the Crusader"]  = 3,
        ["Naxxramas"]              = 3,
        ["The Eye of Eternity"]    = 3,
        ["Vault of Archavon"]      = 2,
        ["The Obsidian Sanctum"]   = 3,
        ["Ruby Sanctum"]           = 3,
        -- Gefährliche Außengebiete
        ["Icecrown"]               = 3,
        ["Storm Peaks"]            = 2,
        ["Zul'Drak"]               = 2,
        ["Sholazar Basin"]         = 2,
        ["Crystalsong Forest"]     = 2,
    },
    levelZones = {
        ["Borean Tundra"]          = { min = 68, max = 72 },
        ["Howling Fjord"]          = { min = 68, max = 72 },
        ["Dragonblight"]           = { min = 71, max = 74 },
        ["Grizzly Hills"]          = { min = 73, max = 75 },
        ["Zul'Drak"]               = { min = 74, max = 76 },
        ["Sholazar Basin"]         = { min = 76, max = 78 },
        ["Storm Peaks"]            = { min = 77, max = 80 },
        ["Icecrown"]               = { min = 77, max = 80 },
    },
    raidNames = {
        "Naxxramas", "The Eye of Eternity", "The Obsidian Sanctum",
        "Ulduar", "Trial of the Crusader", "Icecrown Citadel", "Ruby Sanctum",
    },
    expansion = "wrath",
    hasOfficialHC = false,
    entryZone = "Borean Tundra",
}

-- ══════════════════════════════════════════════════════════════
-- ÖFFENTLICHE API
-- ══════════════════════════════════════════════════════════════

function ExpansionData:GetCurrentData()
    if GDL.isTBC        then return self.TBC
    elseif GDL.isWrath  then return self.WRATH
    else                     return self.CLASSIC
    end
end

function ExpansionData:GetDangerZones()
    local data = self:GetCurrentData()
    return data and data.dangerZones or {}
end

function ExpansionData:GetLevelZones()
    local data = self:GetCurrentData()
    return data and data.levelZones or {}
end

function ExpansionData:GetRaidNames()
    local data = self:GetCurrentData()
    return data and data.raidNames or {}
end

function ExpansionData:IsRaid(zoneName)
    if not zoneName then return false end
    for _, raidName in ipairs(self:GetRaidNames()) do
        if raidName:lower() == zoneName:lower() then return true end
    end
    return false
end

function ExpansionData:GetZoneDangerLevel(zoneName)
    if not zoneName then return 0 end
    local zones = self:GetDangerZones()
    return zones[zoneName] or 0
end

function ExpansionData:GetZoneLevelRange(zoneName)
    if not zoneName then return nil end
    local zones = self:GetLevelZones()
    return zones[zoneName]
end

-- Expansion-Display-Farbe (für UI-Anzeigen)
function ExpansionData:GetExpansionColor()
    if GDL.isTBC    then return "|cffFF8C00" end -- Orange (TBC-Flamme)
    if GDL.isWrath  then return "|cff88AABB" end -- Eisblau (Wrath)
    return "|cffFFD100"                           -- Gold (Classic)
end

function ExpansionData:Initialize()
    local data = self:GetCurrentData()
    GDL:Debug(string.format("ExpansionData: %s geladen (%d Gefahrenzonen, %d Raids)",
        (GDL.expansionLabel or "?"),
        data and data.dangerZones and self:CountTable(data.dangerZones) or 0,
        data and data.raidNames and #data.raidNames or 0))
end

function ExpansionData:CountTable(t)
    local n = 0
    for _ in pairs(t or {}) do n = n + 1 end
    return n
end

GDL:RegisterModule("ExpansionData", ExpansionData)
