Module:Abilities/card: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Gammaton32 (talk | contribs) add line break in generated upgrade descriptions |
Gammaton32 (talk | contribs) remove duplicated strings |
||
| Line 370: | Line 370: | ||
function create_description(prop, frame) | function create_description(prop, frame) | ||
local description = '' | local description = '' | ||
local first = true -- | local first = true | ||
local seen = {} -- Set to track added combinations | |||
for k, v in pairs(prop) do | for k, v in pairs(prop) do | ||
if type(v) ~= 'table' then | if type(v) ~= 'table' then | ||
local formatted_value = utils.format_value_with_prepost(k, v, frame) | local formatted_value = utils.format_value_with_prepost(k, v, frame) | ||
local attr_name = lang.get_string(k..'_label') | 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 | -- Add line break if this is not the first item | ||
if not first then | |||
description = description .. '<br>' | |||
end | |||
description = description .. string.format('%s %s', formatted_value, attr_name) | description = description .. string.format('%s %s', formatted_value, attr_name) | ||
first = false -- | first = false | ||
seen[key] = true -- Mark this combination as added | |||
end | |||
end | end | ||
end | end | ||