Module:HeroData: Difference between revisionsGive feedback
m removed stat box container class |
m hide spirit category for now |
||
| Line 274: | Line 274: | ||
for _, category in ipairs(attribute_orders["category_order"]) do | for _, category in ipairs(attribute_orders["category_order"]) do | ||
stats = attributes_data[category] | if (category ~= "Spirit") then --hide Spirit section for now | ||
stats = attributes_data[category] | |||
local category_values = category_data[category] | |||
template_args["box_name"] = category_values.unlocalized_name | |||
template_args["box_rgb"] = category_values.rgb | |||
template_args["num_cols"] = 2 | |||
cell_values = "" | |||
-- gets the stat's value if it has that stat, default to 0 if not | -- Determine cell values | ||
for _, stat_name in ipairs(attribute_orders[category]["attribute_order"]) do | |||
stat_data = stats[stat_name] | |||
-- gets the stat's value if it has that stat, default to 0 if not | |||
stat_value = hero_data[stat_name] | |||
if (stat_value == nil) then | |||
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 | |||
label = lang_module._get_string(stat_data["label"]) | |||
postfix = stat_data["postfix"] | |||
if (postfix == nil) then | |||
postfix = "" | |||
else | |||
-- light grey for postfixes | |||
postfix = '<span style="color: #666666;">' .. lang_module._get_string(postfix) .. "</span>" | |||
end | |||
-- if a language is missing the postfix, use no postfix | |||
if (postfix == nil) then | |||
postfix = "" | |||
end | |||
-- Check if icon file exists, and if not, don't use any image | |||
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png' | |||
-- 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) | |||
-- Create the template'd icon | |||
local icon_color = attribute_module.get_attr_icon_color(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>' | |||
end | |||
-- use white instead of grey if grey is returned | |||
-- Add an empty cell following some stats to align them correctly as seen in game | |||
if (stats_to_add_blank_after[stat_name]) then | |||
extra_blank_cell = " ," --prefixed space is needed | |||
else | |||
extra_blank_cell = "" | |||
end | |||
-- slightly lighter color for stat name | |||
label = '<span style="color: #3d3d3d;">' .. label .. '</span>' | |||
-- Add the scaling str if it scales | |||
local scaling_value, scaling_type = p.get_hero_scalar(hero_data, stat_name) | |||
local scalar_str = p.get_hero_scalar_str(scaling_value, scaling_type) | |||
if (scalar_str ~= "") then scalar_str = " " .. scalar_str end | |||
-- 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 | |||
-- | -- Write current call | ||
template_call = mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args } | |||
-- Add call to the set of calls | |||
template_calls = template_calls .. "\n" .. template_call | |||
-- Add the | |||
end | end | ||
end | end | ||