Module:Icon: Difference between revisions

LVL (talk | contribs)
Add placeholder image support for unreleased heroes (Boho, Druid, Fortuna, etc.) to prevent red links in navboxes
LVL (talk | contribs)
Fix ability link priority: prefer abilities linked to heroes over duplicate/orphan entries with same name
Line 69: Line 69:
     end
     end
      
      
    -- Process Abilities
-- Process Abilities
     for abilityKey, ability in pairs(abilityData) do
     for abilityKey, ability in pairs(abilityData) do
         if type(ability) == "table" and ability.Name then
         if type(ability) == "table" and ability.Name then
Line 76: Line 76:
             local parentInfo = abilityToHero[abilityKey]
             local parentInfo = abilityToHero[abilityKey]
              
              
             -- Determine link (fallback to ability name if no parent found)
             -- If we already have this ability name, prefer the one linked to a hero
            local link = parentInfo and parentInfo.heroName or name
            if lookup[lowerName] and lookup[lowerName].type == "ability" then
           
                local existingHasParent = lookup[lowerName].link ~= lookup[lowerName].name
            lookup[lowerName] = {
                local newHasParent = parentInfo ~= nil
                name = name,
               
                key = abilityKey,
                -- Skip if existing is linked to hero but this one isn't (prevents orphans from overwriting real ones)
                link = link,
                if existingHasParent and not newHasParent then
                image = name .. ".png",
                    -- Skip this orphan ability
                type = "ability",
                else
                class = "theme" -- Abilities get theme class by default
                    -- Overwrite: new has parent and existing doesn't, or both/neither have parents
             }
                    local link = parentInfo and parentInfo.heroName or name
                    lookup[lowerName] = {
                        name = name,
                        key = abilityKey,
                        link = link,
                        image = name .. ".png",
                        type = "ability",
                        class = "theme"
                    }
                end
            else
                -- No existing entry, add normally
                local link = parentInfo and parentInfo.heroName or name
                lookup[lowerName] = {
                    name = name,
                    key = abilityKey,
                    link = link,
                    image = name .. ".png",
                    type = "ability",
                    class = "theme"
                }
             end
         end
         end
     end
     end