Module:Icon: Difference between revisions

Jump to navigation Jump to search
LVL (talk | contribs)
Refactor to use HeroData.json, AbilityData.json, and ItemData.jsonm; no more need for hardcoded data table; auto-detect icon types
LVL (talk | contribs)
Add placeholder image support for unreleased heroes (Boho, Druid, Fortuna, etc.) to prevent red links in navboxes
Line 7: Line 7:
local iconDataCache = nil
local iconDataCache = nil
local cachedLangCode, cachedLangData
local cachedLangCode, cachedLangData
-- Heroes/Items that don't have images uploaded yet
local missingImageOverrides = {
    -- Unreleased Heroes
    ["boho"] = "Module-Icon missing.png",
    ["druid"] = "Module-Icon missing.png",
    ["fortuna"] = "Module-Icon missing.png",
    ["graf"] = "Module-Icon missing.png",
    ["gunslinger"] = "Module-Icon missing.png",
    ["skyrunner"] = "Module-Icon missing.png",
    ["swan"] = "Module-Icon missing.png",
    ["thumper"] = "Module-Icon missing.png",
    -- Add any others that show red links
}


-- Build unified lookup table from bot-uploaded JSONs
-- Build unified lookup table from bot-uploaded JSONs
Line 29: Line 43:
             local name = hero.Name
             local name = hero.Name
             local lowerName = name:lower()
             local lowerName = name:lower()
           
            -- Check for missing image override
            local imageName = missingImageOverrides[lowerName] or (name .. ".png")
              
              
             lookup[lowerName] = {
             lookup[lowerName] = {
Line 34: Line 51:
                 key = heroKey,
                 key = heroKey,
                 link = name,
                 link = name,
                 image = name .. ".png",
                 image = imageName,
                 type = "hero"
                 type = "hero"
             }
             }
Line 44: Line 61:
                         abilityToHero[ability.Key] = {
                         abilityToHero[ability.Key] = {
                             heroName = name,
                             heroName = name,
                             abilityName = ability.Name -- Use name from hero data if available
                             abilityName = ability.Name
                         }
                         }
                     end
                     end