Module:AbilityTable: Difference between revisions

Vergir (talk | contribs)
register the Barrier column for the barrier list (with help from vergir-bot LLM)
grouped repeated hero cells with rowspan
 
(One intermediate revision by the same user not shown)
Line 24: Line 24:
         headers  = { "Base Damage", "Heavy Melee Scaling", "Notes" },
         headers  = { "Base Damage", "Heavy Melee Scaling", "Notes" },
         get_cells = Renderers.RenderHeavyMelee,
         get_cells = Renderers.RenderHeavyMelee,
    },
    ["scalingspirit"] = {
        headers  = { "Spirit Scaling", "Notes" },
        get_cells = Renderers.RenderSpiritScaling,
     },
     },
     ["healreduce"] = {
     ["healreduce"] = {
Line 322: Line 326:
     end
     end
     table.insert(out, header_row)
     table.insert(out, header_row)
        local hero_counts = {}
    for _, key in ipairs(filtered) do
        local hero = views[key].heroName
        hero_counts[hero] = (hero_counts[hero] or 0) + 1
    end
    local hero_seen = {}


     for _, key in ipairs(filtered) do
     for _, key in ipairs(filtered) do
         local entry  = views[key]
         local entry  = views[key]
         local ability = entry.view
         local ability = entry.view
        local hero    = entry.heroName


         local hero_cell    = frame:expandTemplate{ title = "HeroIcon", args = { entry.heroName } }
         local ability_cell = frame:expandTemplate{
        local ability_cell = frame:expandTemplate{ title = "AbilityIcon", args = { ability["Name"] } }
            title = "AbilityIcon",
            args = { ability["Name"] }
        }


         local extra = get_cells(ability)
         local extra = get_cells(ability)
         enrich_notes_full(extra, stat_notes and stat_notes[ability["Name"]])
         enrich_notes_full(extra, stat_notes and stat_notes[ability["Name"]])


         local row = '| class="ability-table-cell-hero" | '     .. hero_cell
         local row
                .. ' || class="ability-table-cell-ability" | ' .. ability_cell
 
        if not hero_seen[hero] then
            local hero_cell = frame:expandTemplate{
                title = "HeroIcon",
                args = { hero }
            }
 
            if hero_counts[hero] > 1 then
                row = '| rowspan="' .. hero_counts[hero] .. '" class="ability-table-cell-hero" | '
                    .. hero_cell
                    .. ' || class="ability-table-cell-ability" | ' .. ability_cell
            else
                row = '| class="ability-table-cell-hero" | '
                    .. hero_cell
                    .. ' || class="ability-table-cell-ability" | ' .. ability_cell
            end
 
            hero_seen[hero] = true
        else
            row = '| class="ability-table-cell-ability" | ' .. ability_cell
        end
 
         for _, header in ipairs(final_headers) do
         for _, header in ipairs(final_headers) do
             local value = extra[header]
             local value = extra[header]