Module:HeroData: Difference between revisions

LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
Comparison table column widths based on scaling templates count
Line 525: Line 525:
-- Pre-pass: find which stats have scaling
local stats_with_any_scaling = {}
local stats_with_both_scaling = {}
for _, hero_entry in ipairs(sorted_heroes) do
local hero_data = hero_entry.data
for _, category in ipairs(attribute_orders["category_order"]) do
if stats_to_include[category] ~= nil then
for _, attr_key in ipairs(stats_to_include[category]) do
local scaling_data = p.get_hero_scaling_data(hero_data, attr_key)
if scaling_data ~= nil and next(scaling_data) ~= nil then
stats_with_any_scaling[attr_key] = true
local has_spirit = false
local has_level = false
for _, scaling_type in pairs(scaling_data) do
if scaling_type == "Spirit" then has_spirit = true end
if scaling_type == "Level" then has_level = true end
end
if has_spirit and has_level then
stats_with_both_scaling[attr_key] = true
end
end
end
end
end
end
-- First header is Hero (sticky)
-- First header is Hero (sticky)
local headers_str = '<th style="position: sticky; left: 0; top: -1px; z-index: 12; background-color: #27292d; isolation: isolate;">Hero</th>'
local headers_str = '<th style="position: sticky; left: 0; top: -1px; z-index: 12; background-color: #27292d; isolation: isolate;">Hero</th>'
Line 579: Line 606:
end
end
header_style = ' style="position: sticky; top: -1px; z-index: 3; background-color: rgb(' .. category_rgb .. ');"'
local th_style = 'position: sticky; top: -1px; z-index: 3; background-color: rgb(' .. category_rgb .. ');'
if stats_with_both_scaling[attr_key] then
th_style = th_style .. ' min-width: 130px;'
elseif stats_with_any_scaling[attr_key] then
th_style = th_style .. ' min-width: 75px;'
end
header_style = ' style="' .. th_style .. '"'
headers_str = headers_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>"
headers_str = headers_str .. "<th" .. header_style .. ">" .. attr_localized .. postfix .. "</th>"