Editing Module:Abilities/cardGive 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 3: | Line 3: | ||
local utils = require "Module:Abilities/utils" | local utils = require "Module:Abilities/utils" | ||
local Icon = require"Module:Abilities/icon" | local Icon = require"Module:Abilities/icon" | ||
local p = {} | local p = {} | ||
| Line 199: | Line 198: | ||
-- healing, charges) that always hold a value of 1 and are never displayed, so | -- healing, charges) that always hold a value of 1 and are never displayed, so | ||
-- return the first entry that actually renders a badge. | -- return the first entry that actually renders a badge. | ||
local function pick_scale(attr) | local function pick_scale(attr) | ||
if not attr then | if not attr then | ||
| Line 217: | Line 213: | ||
end | end | ||
for _, entry in ipairs(scale) do | for _, entry in ipairs(scale) do | ||
if type(entry) == 'table' and Icon.isDisplayedScale(entry.Type) then | if type(entry) == 'table' and entry.Value ~= 0 and Icon.isDisplayedScale(entry.Type) then | ||
return entry | |||
end | end | ||
end | end | ||
return | return nil | ||
end | end | ||
| Line 416: | Line 408: | ||
local alt_boxes = {} | local alt_boxes = {} | ||
for k, prop in | for k, prop in pairs(props) do | ||
-- Some props don't have values, as those come from upgrades | -- Some props don't have values, as those come from upgrades | ||
-- For now, we will ignore these and only show data for the base ability | -- For now, we will ignore these and only show data for the base ability | ||
| Line 452: | Line 444: | ||
local UPGRADE_COST_MAP = {1, 2, 5} | local UPGRADE_COST_MAP = {1, 2, 5} | ||
function get_upgrade_boxes(hero_key, ability_num) | function get_upgrade_boxes(hero_key, ability_num) | ||
local ability = utils.get_ability_card_data(hero_key, ability_num) | local ability = utils.get_ability_card_data(hero_key, ability_num) | ||
| Line 471: | Line 453: | ||
local upgrade_boxes = {} | local upgrade_boxes = {} | ||
for k, upgrade in | for k, upgrade in pairs(upgrades) do | ||
local description = lang.get_string(upgrade.DescKey) | local description = lang.get_string(upgrade.DescKey) | ||
local desc_length = description and #description or 0 | |||
-- bypass some keys if they are mistakenly left in game files | -- bypass some keys if they are mistakenly left in game files | ||
| Line 492: | Line 475: | ||
end | end | ||
-- | -- Vary the font size based on the number of characters to prevent overflow | ||
local fontsize = '1rem' | |||
local | if desc_length > 30 and desc_length < 51 then | ||
fontsize = '0.9rem' | |||
elseif desc_length > 50 and desc_length < 71 then | |||
fontsize = '0.8rem' | |||
elseif desc_length > 70 then | |||
fontsize = '0.7rem' | |||
end | |||
local upgrade_scale = pick_scale(upgrade) | local upgrade_scale = pick_scale(upgrade) | ||
| Line 508: | Line 491: | ||
index = k, | index = k, | ||
cost = UPGRADE_COST_MAP[k], | cost = UPGRADE_COST_MAP[k], | ||
description = | description = frame:preprocess(description), | ||
scale_value = upgrade_scale and commonutils.round_to_sig_fig(upgrade_scale.Value, 3), | scale_value = upgrade_scale and commonutils.round_to_sig_fig(upgrade_scale.Value, 3), | ||
scale_type = upgrade_scale and upgrade_scale.Type, | scale_type = upgrade_scale and upgrade_scale.Type, | ||
fontsize = fontsize | |||
fontsize = | |||
} | } | ||
} | } | ||