local addonName, addon = ...

addon.LootTracker = addon.LootTracker or {}
addon.LootTracker.UpgradeTracks = addon.LootTracker.UpgradeTracks or {}

local Tracks = addon.LootTracker.UpgradeTracks

local function Entry(ilvl, bonusId, suffix, groupLabel)
    return {
        ilvl = ilvl,
        bonusId = bonusId,
        suffix = suffix,
        groupLabel = groupLabel,
        label = string.format(
            "%d%s",
            ilvl,
            suffix and suffix ~= ""
            and (" (" .. suffix .. ")")
            or ""
        ),
    }
end

Tracks.dungeonOrder = {
    "champion",
    "hero",
    "greatvault",
}

Tracks.dungeon = {
    champion = {
        Entry(292, 12833, "+0", "CHAMPION"),
        Entry(295, 12834, "+2 +3", "CHAMPION"),
        Entry(298, 12835, "+4", "CHAMPION"),
        Entry(302, 12836, "+5", "CHAMPION"),
        Entry(305, 12837, "UPGRADE", "CHAMPION"),
        Entry(308, 12838, "UPGRADE", "CHAMPION"),
    },

    hero = {
        Entry(305, 12841, "+6 +7", "HERO"),
        Entry(308, 12842, "+8 +9", "HERO"),
        Entry(311, 12843, "+10", "HERO"),
        Entry(315, 12844, "UPGRADE", "HERO"),
        Entry(318, 12845, "UPGRADE", "HERO"),
        Entry(321, 12846, "UPGRADE", "HERO"),
    },

    greatvault = {
        Entry(318, 12849, "+10", "MYTH"),
        Entry(321, 12850, "UPGRADE", "MYTH"),
        Entry(324, 12851, "UPGRADE", "MYTH"),
        Entry(328, 12852, "UPGRADE", "MYTH"),
        Entry(331, 12853, "UPGRADE", "MYTH"),
        Entry(334, 12854, "UPGRADE", "MYTH"),
    },
}

Tracks.raidOrder = {
    "lfr",
    "normal",
    "heroic",
    "mythic",
}

Tracks.raid = {
    lfr = {
        Entry(279, 12825, "BOSS", "LFR"),
        Entry(282, 12826, "BOSS", "LFR"),
        Entry(285, 12827, "BOSS", "LFR"),
        Entry(289, 12828, "BOSS", "LFR"),
        Entry(292, 12829, "UPGRADE", "LFR"),
        Entry(295, 12830, "UPGRADE", "LFR"),
    },

    normal = {
        Entry(292, 12833, "BOSS", "NORMAL"),
        Entry(295, 12834, "BOSS", "NORMAL"),
        Entry(298, 12835, "BOSS", "NORMAL"),
        Entry(302, 12836, "BOSS", "NORMAL"),
        Entry(305, 12837, "UPGRADE", "NORMAL"),
        Entry(308, 12838, "UPGRADE", "NORMAL"),
    },

    heroic = {
        Entry(305, 12841, "BOSS", "HEROIC"),
        Entry(308, 12842, "BOSS", "HEROIC"),
        Entry(311, 12843, "BOSS", "HEROIC"),
        Entry(315, 12844, "BOSS", "HEROIC"),
        Entry(318, 12845, "UPGRADE", "HEROIC"),
        Entry(321, 12846, "UPGRADE", "HEROIC"),
    },

    mythic = {
        Entry(318, 12849, "BOSS", "MYTHIC"),
        Entry(321, 12850, "BOSS", "MYTHIC"),
        Entry(324, 12851, "BOSS", "MYTHIC"),
        Entry(328, 12852, "BOSS", "MYTHIC"),
        Entry(331, 12853, "BOSS", "MYTHIC"),
        Entry(334, 12854, "BOSS", "MYTHIC"),
    },
}

function Tracks:GetDungeonEntry(trackName, rank)
    local track = self.dungeon[trackName]
    return track and track[rank] or nil
end

function Tracks:GetRaidEntry(difficulty, rank)
    local track = self.raid[difficulty]
    return track and track[rank] or nil
end
