Editing Module:Sandbox/VergirGive feedback
Jump to navigation
Jump to search
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 65: | Line 65: | ||
local function format_spirit(v) | local function format_spirit(v) | ||
return string.format("%.3g", v) | return string.format("%.3g", v) | ||
end | end | ||
| Line 91: | Line 74: | ||
-- Renders Spirit Power scaling. | -- Renders Spirit Power scaling. | ||
-- Lists every prop that scales with Spirit at base, one per line | -- Lists every prop that scales with Spirit at base, one per line, labelled | ||
-- | -- with the prop's name from the ability card: "×0.55 (Base Damage)". Two | ||
-- props sharing a name are told apart by the card's Title | -- props sharing a name are told apart by the card's Title | ||
-- ("Damage: Cost of Stay"); props the card does not list show their raw key. | -- ("Damage: Cost of Stay"); props the card does not list show their raw key. | ||
| Line 104: | Line 86: | ||
local base = spirit_scalings(ability, labels) | local base = spirit_scalings(ability, labels) | ||
local tiers = {} | local tiers = {} | ||
local upgrades = ability["Upgrades"] | local upgrades = ability["Upgrades"] | ||
if type(upgrades) == "table" then | if type(upgrades) == "table" then | ||
for i, tier in ipairs(upgrades) do | for i, tier in ipairs(upgrades) do | ||
if type(tier) == "table" then | if type(tier) == "table" then tiers[i] = spirit_scalings(tier, labels) end | ||
end | end | ||
end | end | ||
| Line 128: | Line 107: | ||
end | end | ||
note_keys(base) | note_keys(base) | ||
for _, | for _, list in pairs(tiers) do note_keys(list) end | ||
local function label_of(key) | local function label_of(key) | ||
| Line 145: | Line 124: | ||
local lines = {} | local lines = {} | ||
for _, prop in ipairs(base) do | for _, prop in ipairs(base) do | ||
table.insert(lines, | table.insert(lines, "×" .. format_spirit(prop.value) .. " (" .. label_of(prop.key) .. ")") | ||
running[prop.key] = prop.value | running[prop.key] = prop.value | ||
end | end | ||
| Line 152: | Line 131: | ||
local notes = {} | local notes = {} | ||
for | for i = 1, (type(upgrades) == "table" and #upgrades or 0) do | ||
local | local list = tiers[i] | ||
if list then | |||
local groups, group_order = {}, {} -- Multiply upgrades, grouped by multiplier | |||
for _, up in ipairs(list) do | |||
local label = label_of(up.key) | |||
local current = running[up.key] | |||
if up.multiply then | |||
local group = groups[up.value] | |||
if not group then | |||
group = { labels = {}, totals = {} } | |||
groups[up.value] = group | |||
table.insert(group_order, up.value) | |||
end | |||
table.insert(group.labels, label) | |||
if current then | |||
table.insert(group.totals, "×" .. format_spirit(running[up.key])) | running[up.key] = current * up.value | ||
table.insert(group.totals, "×" .. format_spirit(running[up.key])) | |||
else | |||
table.insert(group.totals, "?") | |||
end | |||
elseif current then | |||
running[up.key] = current + up.value | |||
table.insert(notes, "T" .. i .. " upgrade adds +×" .. format_spirit(up.value) | |||
.. " " .. label .. " scaling (total ×" .. format_spirit(running[up.key]) .. ")") | |||
else | else | ||
table.insert( | running[up.key] = up.value | ||
table.insert(notes, "T" .. i .. " upgrade grants ×" .. format_spirit(up.value) | |||
.. " " .. label .. " scaling") | |||
end | end | ||
end | end | ||
for _, m in ipairs(group_order) do | |||
local group = groups[m] | |||
table.insert(notes, "T" .. i .. " upgrade multiplies " .. join_names(group.labels) | |||
.. " scaling by " .. format_spirit(m) | |||
.. " (total " .. table.concat(group.totals, ", ") .. ")") | |||
end | |||
end | end | ||
end | end | ||
| Line 675: | Line 656: | ||
table.insert(out, "|}") | table.insert(out, "|}") | ||
return table.concat(out, "\n") | return table.concat(out, "\n") | ||
end | end | ||
return p | return p | ||