Module:Abilities/card: Difference between revisions

Added prefix support for altbox
Removed exclude plus logic as it should no longer be needed in format_value_with_prepost function
Line 29: Line 29:
combat_barrier = {img='Barrier.png', link='Barrier', color = 'Green'},
combat_barrier = {img='Barrier.png', link='Barrier', color = 'Green'},
time = {img='AttributeIconTechDuration.png', link='Ability Duration', color = 'Purple'},
time = {img='AttributeIconTechDuration.png', link='Ability Duration', color = 'Purple'},
}
--- A set of stat types that represent absolute values and should not have a '+' prefix.
local ABSOLUTE_VALUE_TYPES = {
damage = true,
bullet_damage = true,
tech_damage = true,
melee_damage = true,
health = true,
healing = true,
range = true,
distance = true,
duration = true,
cooldown = true,
time = true,
charges = true,
cast = true,
combat_barrier = true
}
}


Line 315: Line 297:
-- Exclude 0 values
-- Exclude 0 values
if value and value ~= 0 then
if value and value ~= 0 then
--- Determine if the '+' sign should be excluded for this stat type by checking against the set.
local exclude_plus_flag = ABSOLUTE_VALUE_TYPES[prop.Type] or false
local icon = get_icon(prop.Type)
local icon = get_icon(prop.Type)
local main_box = frame:expandTemplate{
local main_box = frame:expandTemplate{
Line 324: Line 303:
title = prop.Title,
title = prop.Title,
key = prop.Key,
key = prop.Key,
value = utils.format_value_with_prepost(prop.Key, value, frame, exclude_plus_flag),
value = utils.format_value_with_prepost(prop.Key, value, frame),
icon = icon.img,
icon = icon.img,
icon_link = icon.link,
icon_link = icon.link,
Line 366: Line 345:
for k, prop in pairs(props) do
for k, prop in pairs(props) do
local exclude_plus_flag = ABSOLUTE_VALUE_TYPES[prop.Type] or false
-- 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 375: Line 353:
args = {
args = {
  key = prop.Key,
  key = prop.Key,
     value = utils.format_value_with_prepost(prop.Key, prop.Value, frame, exclude_plus_flag),
     value = utils.format_value_with_prepost(prop.Key, prop.Value, frame),
  icon = icon.img,
  icon = icon.img,
  icon_link = icon.link,
  icon_link = icon.link,