Module:Abilities/card: Difference between revisionsGive feedback
Jump to navigation
Jump to search
upgrade boxes text scaling |
Gammaton32 (talk | contribs) m Reverted edit by Monster Domosed (talk) to last revision by Gammaton32 Tag: Rollback |
||
| Line 333: | Line 333: | ||
local props = ability.Upgrades | local props = ability.Upgrades | ||
local upgrade_boxes = {} | |||
for k, prop in pairs(props) do | |||
local description = lang.get_string(prop.DescKey) | |||
-- Generate a description if there is no localized string | |||
if (description == nil or description == '') then | |||
description = create_description(prop, frame) | |||
end | |||
-- Vary the font size based on the number of characters to prevent overflow | |||
local fontsize = '1rem' | |||
if #description > 60 and #description < 71 then | |||
fontsize = '0.95rem' | |||
elseif #description > 70 and #description < 91 then | |||
fontsize = '0.875rem' | |||
elseif #description > 90 then | |||
fontsize = '0.8rem' | |||
end | |||
local upgrade_box = frame:expandTemplate{ | |||
title = "Ability_card_v2/Card/UpgradeBox", | |||
args = { | |||
cost = UPGRADE_COST_MAP[k], | |||
description = frame:preprocess(description), | |||
scale_value = prop.Scale and commonutils.round_to_sig_fig(prop.Scale.Value, 3), | |||
scale_type = prop.Scale and prop.Scale.Type, | |||
fontsize = fontsize | |||
} | |||
} | |||
table.insert(upgrade_boxes, upgrade_box) | |||
end | |||
return upgrade_boxes | |||
end | end | ||