Module:AbilityTable/ComplexRenderers: Difference between revisionsGive feedback
add RenderBarrier for the barrier list: running totals of barrier value and Spirit scaling per upgrade tier (with help from vergir-bot LLM) |
add scalingspirit |
||
| (One intermediate revision by one other user not shown) | |||
| Line 81: | Line 81: | ||
end | end | ||
-- Formats one barrier step. Spirit scaling goes through {{Ss}}, expanded via | -- Pads a whole-number scaling out to one decimal, so a running total of 2 | ||
-- reads "2.0" next to its "1.5" neighbours instead of "2". Values that already | |||
-- carry decimals are left alone, which keeps precision on things like 0.75. | |||
local function format_scale(scale) | |||
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{ title = "Ss", args = { | out = out .. " " .. frame:expandTemplate{ | ||
title = "Ss", | |||
args = { scale_text, compact = "1", show_value = "1" }, | |||
} | |||
else | else | ||
out = out .. " ×" .. | out = out .. " ×" .. scale_text | ||
end | end | ||
end | end | ||
| Line 385: | Line 399: | ||
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 | ||