Module:Abilities/card: Difference between revisionsGive feedback
Removed hex duration as it seems to work without this code now. |
Fix Fire Scarabs T3 upgrade description: suppress "0 DPS" and show "Increased Spirit scaling". Refactor create_description to handle scaling‑only properties |
||
| Line 475: | Line 475: | ||
function create_description(prop, frame) | function create_description(prop, frame) | ||
local | local value_lines = {} -- normal stat changes | ||
local | local scale_lines = {} -- "Increased X scaling" notes | ||
local seen = {} | local seen = {} | ||
for k, v in pairs(prop) do | for k, v in pairs(prop) do | ||
if k == 'DescKey' then | |||
-- skip | |||
elseif type(v) == 'table' then | |||
local has_value = v.Value ~= nil | |||
local has_scale = v.Scale and v.Scale.Value and v.Scale.Value ~= 0 | |||
-- Value is 0 and we have a scaling change → scaling note | |||
if has_value and has_scale and v.Value == 0 then | |||
if not seen["scale_" .. k] then | |||
local scale_type = v.Scale.Type | |||
local capitalized = scale_type:sub(1,1):upper() .. scale_type:sub(2) | |||
table.insert(scale_lines, "Increased " .. capitalized .. " scaling") | |||
seen["scale_" .. k] = true | |||
end | |||
-- Only a scaling change, no value → scaling note (future bot correction) | |||
elseif not has_value and has_scale then | |||
if not seen["scale_" .. k] then | |||
local scale_type = v.Scale.Type | |||
local capitalized = scale_type:sub(1,1):upper() .. scale_type:sub(2) | |||
table.insert(scale_lines, "Increased " .. capitalized .. " scaling") | |||
seen["scale_" .. k] = true | |||
end | |||
-- Normal value (0 without scale, or non‑zero with/without scale) | |||
elseif has_value then | |||
local formatted_value = utils.format_value_with_prepost(k, v.Value, frame) | |||
local attr_name = lang.get_string(k .. '_label') | |||
local key = formatted_value .. '|' .. attr_name | |||
if not seen[key] then | |||
table.insert(value_lines, string.format('%s %s', formatted_value, attr_name)) | |||
seen[key] = true | |||
end | |||
end | |||
else | |||
-- Plain number/string (e.g. OutgoingDamagePenaltyPercent = -15) | |||
local formatted_value = utils.format_value_with_prepost(k, v, frame) | |||
local attr_name = lang.get_string(k .. '_label') | |||
local key = formatted_value .. '|' .. attr_name | |||
if not seen[key] then | |||
table.insert(value_lines, string.format('%s %s', formatted_value, attr_name)) | |||
seen[key] = true | |||
end | |||
end | end | ||
end | end | ||
return | -- Combine: value lines first, then scaling lines | ||
local all_lines = {} | |||
for _, line in ipairs(value_lines) do | |||
table.insert(all_lines, line) | |||
end | |||
for _, line in ipairs(scale_lines) do | |||
table.insert(all_lines, line) | |||
end | |||
return table.concat(all_lines, '<br>') | |||
end | end | ||