Module:HeroData: Difference between revisions

Jump to navigation Jump to search
Sur (talk | contribs)
m stat_infobox color shades slightly distinguished
Sur (talk | contribs)
m display_regions removed; bolding stat value removed
Line 274: Line 274:
stat_data = stats[stat_name]
stat_data = stats[stat_name]
-- Confirm its meant to be displayed in hero stat infobox
should_display = stat_data['display_regions']['hero_statbox']
if (should_display ~= nil) then
-- gets the stat's value if it has that stat, default to 0 if not
stat_value = hero_data[stat_name]
-- gets the stat's value if it has that stat, default to 0 if not
if (stat_value == nil) then
stat_value = hero_data[stat_name]
stat_value = 0 --default to 0 if not present
if (stat_value == nil) then
end
stat_value = 0 --default to 0 if not present
end
--Round value to 3 significant figures
stat_value = util_module.round_to_sig_fig(stat_value, 3)
-- get label and postfix
--Round value to 3 significant figures
label = lang_module._get_string(stat_data["label"])
stat_value = util_module.round_to_sig_fig(stat_value, 3)
postfix = stat_data["postfix"]
if (postfix == nil) then  
-- get label and postfix
postfix = ""
label = lang_module._get_string(stat_data["label"])
else
postfix = stat_data["postfix"]
-- light grey for postfixes
if (postfix == nil) then  
postfix = '<span style="color: #666666;">' .. lang_module._get_string(postfix) .. "</span>"
postfix = ""
end
else
-- if a language is missing the postfix, use no postfix
-- light grey for postfixes
if (postfix == nil) then
postfix = '<span style="color: #666666;">' .. lang_module._get_string(postfix) .. "</span>"
postfix = ""
end
end
-- if a language is missing the postfix, use no postfix
if (postfix == nil) then
-- Check if icon file exists, and if not, don't use any image
postfix = ""
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
end
-- 15px and link to stat name (page name might not match perfectly yet)
image_file = util_module.get_image_file(image_file_name, 15, stat_name)
-- Check if icon file exists, and if not, don't use any image
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
-- Create the template'd icon
-- 15px and link to stat name (page name might not match perfectly yet)
local icon_color = attribute_module.get_attr_icon_color(stat_name)
image_file = util_module.get_image_file(image_file_name, 15, stat_name)
if (icon_color == "Brown") then
image_file = '<span style="position: relative; bottom: 2px; filter: invert(42%) sepia(10%) saturate(2912%) hue-rotate(351deg) brightness(90%) contrast(87%);">' .. image_file .. '</span>'
-- Create the template'd icon
end
local icon_color = attribute_module.get_attr_icon_color(stat_name)
-- use white instead of grey if grey is returned
if (icon_color == "Brown") then
image_file = '<span style="position: relative; bottom: 2px; filter: invert(42%) sepia(10%) saturate(2912%) hue-rotate(351deg) brightness(90%) contrast(87%);">' .. image_file .. '</span>'
-- Add an empty cell following some stats to align them correctly as seen in game
end
if (stats_to_add_blank_after[stat_name]) then
-- use white instead of grey if grey is returned
extra_blank_cell = " ," --prefixed space is needed
else
-- Add an empty cell following some stats to align them correctly as seen in game
extra_blank_cell = ""
if (stats_to_add_blank_after[stat_name]) then
end
extra_blank_cell = " ," --prefixed space is needed
else
-- bold the stat value
extra_blank_cell = ""
stat_value = '<b>' .. stat_value .. '</b>'
-- slightly lighter color for stat name
label = '<span style="color: #3d3d3d;">' .. label .. '</span>'
-- Add the scaling str if it scales
local scalar_str = p.get_hero_scalar_str(hero_data, stat_name)
-- Set cell value as "Icon StatvaluePostfix Statname Scaling,"
-- If icon file already exists, set it to #REDIRECT to the duplicate file page
cell_value = image_file .. " " .. stat_value  .. postfix .. " " .. label .. " " .. scalar_str .. "," .. extra_blank_cell
cell_values = cell_values .. cell_value --add value to values list
end
end
-- slightly lighter color for stat name
label = '<span style="color: #3d3d3d;">' .. label .. '</span>'
-- Add the scaling str if it scales
local scalar_str = p.get_hero_scalar_str(hero_data, stat_name)
-- Set cell value as "Icon StatvaluePostfix Statname Scaling,"
-- If icon file already exists, set it to #REDIRECT to the duplicate file page
cell_value = image_file .. " " .. stat_value  .. postfix .. " " .. label .. " " .. scalar_str .. "," .. extra_blank_cell
cell_values = cell_values .. cell_value --add value to values list
end
end
template_args["cell_values"] = cell_values
template_args["cell_values"] = cell_values