Module:Abilities/card: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Added nil check for channel time |
Fixed upgrade description generation returning empty string if there is scaling |
||
| Line 397: | Line 397: | ||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
local | local upgrades = ability.Upgrades | ||
local upgrade_boxes = {} | local upgrade_boxes = {} | ||
for k, | for k, upgrade in pairs(upgrades) do | ||
local description = lang.get_string( | local description = lang.get_string(upgrade.DescKey) | ||
-- Generate a description if there is no localized string | -- Generate a description if there is no localized string | ||
if (description == nil or description == '') then | if (description == nil or description == '') then | ||
description = create_description( | description = create_description(upgrade, frame) | ||
end | end | ||
| Line 423: | Line 423: | ||
cost = UPGRADE_COST_MAP[k], | cost = UPGRADE_COST_MAP[k], | ||
description = frame:preprocess(description), | description = frame:preprocess(description), | ||
scale_value = | scale_value = upgrade.Scale and commonutils.round_to_sig_fig(upgrade.Scale.Value, 3), | ||
scale_type = | scale_type = upgrade.Scale and upgrade.Scale.Type, | ||
fontsize = fontsize | fontsize = fontsize | ||
} | } | ||
| Line 440: | Line 440: | ||
for k, v in pairs(prop) do | for k, v in pairs(prop) do | ||
local value | |||
if type(v) | if type(v) == 'table' then | ||
value = v.Value | |||
else | |||
value = v | |||
end | |||
local formatted_value = utils.format_value_with_prepost(k, value, frame) | |||
local attr_name = lang.get_string(k..'_label') | |||
local key = formatted_value .. '|' .. attr_name -- Unique identifier | |||
-- Skip if this combination has already been added | |||
if not seen[key] then | |||
-- Add line break if this is not the first item | |||
if not first then | |||
description = description .. '<br>' | |||
end | end | ||
end | end | ||
description = description .. string.format('%s %s', formatted_value, attr_name) | |||
first = false | |||
seen[key] = true -- Mark this combination as added | |||
end | end | ||
return description | return description | ||
end | end | ||