Module:AbilityTable: Difference between revisions

Jump to navigation Jump to search
Add melee stat using Scale.Type value matching; add human notes for Puddle Punch and Bashdown (with help from vergir-bot LLM)
Add melee extra columns with Light Melee Scaling and automated heavy melee upgrade notes (with help from vergir-bot LLM)
Line 12: Line 12:
local human_notes = {
local human_notes = {
     ["charges"] = {
     ["charges"] = {
         ["Jar of Dead"] = "Charges by being near when anything dies.",
         ["Jar of Dead"] = "Charges by being near when anything dies.",
     },
     },
     ["melee"] = {
     ["melee"] = {
         ["Puddle Punch"] = "Upgrades to [[Heavy Melee]] on T3. Can be parried.",
         ["Puddle Punch"] = "Can be parried.",
        ["Bashdown"]    = "Counts as [[Light Melee]]. Upgrades to [[Heavy Melee]] on T3.",
     },
     },
}
}
Line 52: Line 51:
     return nil
     return nil
end
end


-- ============================================================
-- ============================================================
Line 107: Line 105:
     if #note_parts > 0 then
     if #note_parts > 0 then
         cells["Notes"] = table.concat(note_parts, " ")
         cells["Notes"] = table.concat(note_parts, " ")
    end
    return cells
end
-- Finds the base light melee scale value for a melee ability.
-- Searches all top-level properties for the first one whose Scale.Type
-- is "melee" and whose scale value is > 0.
local function find_base_melee_scale(ability)
    for _, v in pairs(ability) do
        if type(v) == "table" then
            local scale = v["Scale"]
            if type(scale) == "table"
                and scale["Type"] == "melee"
                and type(scale["Value"]) == "number"
                and scale["Value"] > 0
            then
                return scale["Value"]
            end
        end
    end
    return nil
end
-- Finds the first upgrade tier that introduces a heavy_melee scale > 0.
-- Returns { tier = N, scale = V } or nil.
local function find_heavy_melee_upgrade(ability)
    local upgrades = ability["Upgrades"]
    if type(upgrades) ~= "table" then return nil end
    for i, tier in ipairs(upgrades) do
        if type(tier) == "table" then
            for _, v in pairs(tier) do
                if type(v) == "table" then
                    local scale = v["Scale"]
                    if type(scale) == "table"
                        and scale["Type"] == "heavy_melee"
                        and type(scale["Value"]) == "number"
                        and scale["Value"] > 0
                    then
                        return { tier = i, scale = scale["Value"] }
                    end
                end
            end
        end
    end
    return nil
end
local function melee_cells(ability)
    local cells = {}
    local base_scale = find_base_melee_scale(ability)
    if base_scale then
        cells["Light Melee Scaling"] = "×" .. base_scale
    end
    local heavy_upgrade = find_heavy_melee_upgrade(ability)
    if heavy_upgrade then
        cells["Notes"] = "Gains ×" .. heavy_upgrade.scale
            .. " [[Heavy Melee]] scaling on T" .. heavy_upgrade.tier .. " upgrade."
     end
     end


Line 116: Line 174:
         headers  = { "Charges", "Time Between Charges", "Notes" },
         headers  = { "Charges", "Time Between Charges", "Notes" },
         get_cells = charges_cells,
         get_cells = charges_cells,
    },
    ["melee"] = {
        headers  = { "Light Melee Scaling", "Notes" },
        get_cells = melee_cells,
     },
     },
}
}