Module:AbilityTable: Difference between revisions

Jump to navigation Jump to search
Add melee extra columns with Light Melee Scaling and automated heavy melee upgrade notes (with help from vergir-bot LLM)
Fix melee scaling notes: additive upgrade interpretation for Rend; updated heavy melee note wording with bold (with help from vergir-bot LLM)
Line 110: Line 110:
end
end


-- Finds the base light melee scale value for a melee ability.
-- Finds the base light melee scale value: the first top-level property
-- Searches all top-level properties for the first one whose Scale.Type
-- whose Scale.Type is "melee" and whose scale value is > 0.
-- is "melee" and whose scale value is > 0.
local function find_base_melee_scale(ability)
local function find_base_melee_scale(ability)
     for _, v in pairs(ability) do
     for _, v in pairs(ability) do
Line 129: Line 128:
end
end


-- Finds the first upgrade tier that introduces a heavy_melee scale > 0.
-- Scans all upgrade tiers for melee-scale changes. Upgrade objects are
-- Returns { tier = N, scale = V } or nil.
-- additive in the engine, so the final scale = base + upgrade delta.
local function find_heavy_melee_upgrade(ability)
-- Returns a list of note strings, one per relevant upgrade tier found.
-- Handles two cases:
--  heavy_melee scale > 0 introduced  → ability gains heavy melee scaling
--   melee scale changed (delta ~= 0)  → existing melee scaling is modified
local function build_melee_upgrade_notes(ability, base_melee_scale)
     local upgrades = ability["Upgrades"]
     local upgrades = ability["Upgrades"]
     if type(upgrades) ~= "table" then return nil end
     if type(upgrades) ~= "table" then return {} end
 
    local notes = {}
 
     for i, tier in ipairs(upgrades) do
     for i, tier in ipairs(upgrades) do
         if type(tier) == "table" then
         if type(tier) == "table" then
Line 139: Line 145:
                 if type(v) == "table" then
                 if type(v) == "table" then
                     local scale = v["Scale"]
                     local scale = v["Scale"]
                     if type(scale) == "table"
                     if type(scale) == "table" and type(scale["Value"]) == "number" then
                        and scale["Type"] == "heavy_melee"
                         local stype = scale["Type"]
                         and type(scale["Value"]) == "number"
                         local delta = scale["Value"]
                         and scale["Value"] > 0
 
                    then
                        if stype == "heavy_melee" and delta > 0 then
                        return { tier = i, scale = scale["Value"] }
                            -- Introduces heavy melee scaling (additive on top of zeroed melee)
                            table.insert(notes, "T" .. i .. " upgrade changes scaling to ×"
                                .. delta .. " of '''[[Heavy Melee]]''' damage.")
 
                        elseif stype == "melee" and delta ~= 0 and base_melee_scale then
                            -- Modifies existing melee scaling additively
                            local final = base_melee_scale + delta
                            -- Round to avoid float noise (e.g. 1.2 + 0.4 = 1.5999...)
                            final = math.floor(final * 1000 + 0.5) / 1000
                            table.insert(notes, "T" .. i .. " upgrade adds ×"
                                .. delta .. " [[Melee Damage]] scaling (total ×" .. final .. ").")
                        end
                     end
                     end
                 end
                 end
Line 150: Line 167:
         end
         end
     end
     end
     return nil
 
     return notes
end
end


Line 161: Line 179:
     end
     end


     local heavy_upgrade = find_heavy_melee_upgrade(ability)
     local upgrade_notes = build_melee_upgrade_notes(ability, base_scale)
     if heavy_upgrade then
     if #upgrade_notes > 0 then
         cells["Notes"] = "Gains ×" .. heavy_upgrade.scale
         cells["Notes"] = table.concat(upgrade_notes, " ")
            .. " [[Heavy Melee]] scaling on T" .. heavy_upgrade.tier .. " upgrade."
     end
     end