Module:Abilities/card: Difference between revisions

LVL (talk | contribs)
Update stat formatting to exclude the '+' prefix for absolute values (e.g., Damage, Health).
LVL (talk | contribs)
Temporary change for mcginnis heal radius to appear
Line 263: Line 263:
function get_main_boxes(hero_key, ability_num, info_section_num)
function get_main_boxes(hero_key, ability_num, info_section_num)
local ability = utils.get_ability_card_data(hero_key, ability_num)
local ability = utils.get_ability_card_data(hero_key, ability_num)
if(ability == nil) then return "Ability Not Found" end
if(ability == nil) then return {} end -- return empty table, not string
local info_section = ability['Info'..info_section_num]
local info_section = ability['Info'..info_section_num]
-- some abilities have no info sections
-- some abilities have no info sections
if info_section == nil then return '' end
if info_section == nil then return {} end
local main = info_section.Main
local main = info_section.Main
if main == nil then
if main == nil then
return ''
return {}
end
end
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
local props = info_section.Main.Props
local props = {}
-- Start with the standard Props array
if main.Props then
for _, prop in ipairs(main.Props) do
table.insert(props, prop)
end
end
-- === SPECIAL CASE: Auto-include HealRadius in Info1 ===
if info_section_num == 1 and ability.Range and ability.Range.HealRadius then
local healRadius = ability.Range.HealRadius
-- Only add if it's not already in Props (avoid duplicates)
local alreadyExists = false
for _, prop in ipairs(props) do
if prop.Key == "HealRadius" or (prop.Name and prop.Name == "Heal Radius") then
alreadyExists = true
break
end
end
if not alreadyExists then
table.insert(props, {
Key = "HealRadius",
Name = healRadius.Name or "Heal Radius",
Value = healRadius.Value,
Type = healRadius.Type or "distance",
Scale = healRadius.Scale  -- preserve scaling info
})
end
end
--- A set of stat types that represent absolute values and should not have a '+' prefix.
--- A set of stat types that represent absolute values and should not have a '+' prefix.
local ABSOLUTE_VALUE_TYPES = {
local ABSOLUTE_VALUE_TYPES = {
Line 298: Line 327:
local main_boxes = {}
local main_boxes = {}
for k, prop in pairs(props) do
for k, prop in ipairs(props) do -- use ipairs for ordered iteration
local value = prop.Value
local value = prop.Value
-- If it scales with melee damage, set the value using the hero's base melee to match in game visuals
-- If it scales with melee damage, set the value using the hero's base melee to match in game visuals