-- TOG Tools — Game-version flags
--
-- Loaded FIRST, before TOGTools.lua, and deliberately dependency-free: no Ace,
-- no LibStub, no frames. Every module branches on `addon.gameVersion`, and this
-- addon ships six TOCs, so the derivation that decides which branch runs is the
-- single highest-consequence piece of logic in the addon — a wrong flag here
-- doesn't error, it silently routes an entire flavour down the wrong code path.
--
-- Keeping it in its own file with zero dependencies is what makes it reachable
-- from the offline test harness. Before this split the derivation sat inline in
-- TOGTools.lua, three lines above `LibStub("AceAddon-3.0"):NewAddon(...)`, so
-- loading the file offline was impossible and specs had to hand-build the flag
-- tables — which tested the branches but never the code that picks them.

local _, addon = ...

-- Interface/TOC number -> flag table. Pure: no globals read, no state touched.
--
-- The bands are the client's own major-version encoding (Vanilla 1.x = 11xxx,
-- TBC 2.x = 2xxxx, ...), so each expansion is a 10000-wide window and Retail is
-- simply "none of the Classic windows". Deriving isRetail as the negation rather
-- than a band of its own means a future Classic expansion can't accidentally be
-- classified as Retail — it lands outside every band and needs a band added,
-- which fails loudly in testing rather than quietly taking Retail paths.
function addon.DeriveGameVersion(tocVersion)
    local gv = {}
    gv.isVanilla = tocVersion < 20000
    gv.isTBC     = tocVersion >= 20000 and tocVersion < 30000
    gv.isWrath   = tocVersion >= 30000 and tocVersion < 40000
    gv.isCata    = tocVersion >= 40000 and tocVersion < 50000
    gv.isMists   = tocVersion >= 50000 and tocVersion < 60000
    gv.isClassic = gv.isVanilla or gv.isTBC or gv.isWrath or gv.isCata or gv.isMists
    gv.isRetail  = not gv.isClassic
    -- Retail 12.0+ ("Midnight") is where the secret-value system, the combat-log
    -- block and the automated-public-chat block land, so several modules gate on
    -- this specifically rather than on isRetail — 11.x has none of them.
    gv.isRetail120Plus = tocVersion >= 120000
    return gv
end

addon.gameVersion = addon.DeriveGameVersion(select(4, GetBuildInfo()))
