Editing Module:AbilityTable/ComplexRenderers

Jump to navigation Jump to search
Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 81: Line 81:
end
end


-- Pads a whole-number scaling out to one decimal, so a running total of 2
-- Formats one barrier step. Spirit scaling goes through {{Ss}}, expanded via
-- reads "2.0" next to its "1.5" neighbours instead of "2". Values that already
-- the frame the surrounding #invoke is already running under: module return
-- carry decimals are left alone, which keeps precision on things like 0.75.
-- values are not re-expanded, so a literal "{{Ss|0.8}}" would reach the page
local function format_scale(scale)
-- as text. The plain fallback covers a nil frame (module console).
    local text = tostring(scale)
    if not text:find(".", 1, true) then text = text .. ".0" end
    return text
end
 
-- Formats one barrier step. Spirit scaling goes through the compact {{Ss}}
-- form, expanded via the frame the surrounding #invoke is already running
-- under: module return values are not re-expanded, so a literal "{{Ss|0.8}}"
-- would reach the page as text. The plain fallback covers a nil frame
-- (module console).
local function format_barrier(value, scale)
local function format_barrier(value, scale)
     local out = tostring(value)
     local out = tostring(value)
     if scale and scale ~= 0 then
     if scale and scale ~= 0 then
        local scale_text = format_scale(scale)
         local frame = mw.getCurrentFrame()
         local frame = mw.getCurrentFrame()
         if frame then
         if frame then
             out = out .. " " .. frame:expandTemplate{
             out = out .. " " .. frame:expandTemplate{ title = "Ss", args = { scale } }
                title = "Ss",
                args = { scale_text, compact = "1", show_value = "1" },
            }
         else
         else
             out = out .. " ×" .. scale_text
             out = out .. " ×" .. scale
         end
         end
     end
     end
Line 399: Line 385:
             end
             end
         end
         end
    end
    return cells
end
-- Renders Spirit Power scaling.
-- Shows the Scale.Value for abilities whose Scale.Type is "spirit".
function p.RenderSpiritScaling(ability)
    local base_scale = nil
    local base_prop = nil
    -- Find base Spirit scaling
    for k, v in pairs(ability) do
        if k ~= "Upgrades" and type(v) == "table" then
            local scale = v["Scale"]
            if type(scale) == "table"
              and scale["Type"] == "spirit"
              and type(scale["Value"]) == "number"
              and scale["Value"] ~= 0 then
                base_scale = scale["Value"]
                base_prop = k
                break
            end
        end
    end
    local cells = {}
    if base_scale then
        cells["Spirit Scaling"] = "×" .. base_scale
    end
    local upgrades = ability["Upgrades"]
    if type(upgrades) ~= "table" then return cells end
    local notes = {}
    for i, tier in ipairs(upgrades) do
        if type(tier) == "table" then
            local upgrade_scale = nil
            for k, v in pairs(tier) do
                if type(v) == "table" then
                    local scale = v["Scale"]
                    if type(scale) == "table"
                      and scale["Type"] == "spirit"
                      and type(scale["Value"]) == "number"
                      and scale["Value"] ~= 0 then
                        upgrade_scale = scale["Value"]
                        break
                    end
                end
            end
            if upgrade_scale then
                table.insert(notes,
                    "on T" .. i .. " gets +×" .. upgrade_scale .. " Spirit scaling")
            end
        end
    end
    if #notes > 0 then
        cells["Notes"] = table.concat(notes, ". ")
     end
     end


Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template