Module:HeroData: Difference between revisionsGive feedback
m exclude stats that are always 0 |
m exclude heroes in development or disabled |
||
| Line 75: | Line 75: | ||
return element | return element | ||
end | end | ||
| Line 353: | Line 350: | ||
local spirit_power = frame.args[2] | local spirit_power = frame.args[2] | ||
if (spirit_power == nil) then spirit_power = 0 end | if (spirit_power == nil) then spirit_power = 0 end | ||
local in_development | |||
local is_disabled | |||
-- Initializations and declarations | -- Initializations and declarations | ||
| Line 382: | Line 382: | ||
-- Iterate heroes | -- Iterate heroes | ||
for hero_key, hero_data in pairs(heroes_data) do | for hero_key, hero_data in pairs(heroes_data) do | ||
--Add the row's stats | -- Ensure they are not in development and they are an active hero | ||
in_development = hero_data["inDevelopment"] | |||
is_disabled = hero_data["isDisabled"] | |||
if (not in_development and not is_disabled) then | |||
--Add the row's stats | |||
row_str = "" | |||
-- Retrieve hero's name | |||
hero_name = lang_module._get_string(hero_key) | |||
-- First column in each row is hero name | |||
row_str = row_str .. "<td>" .. hero_name .. "</td>" | |||
-- Iterate attributes within the category | -- Consecutive columns are then stats | ||
-- Iterate categories | |||
for _, category in ipairs(attribute_orders["category_order"]) do | |||
category_attrs = attributes_data[category] | |||
-- Iterate attributes within the category | |||
for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do | |||
if (stats_to_exclude[attr_key] == nil) then | |||
attr_data = category_attrs[attr_key] | |||
--Retrieve the stats value from hero data | |||
stat_value = hero_data[attr_key] | |||
if (stat_value == nil) then stat_value = 0 end | |||
-- Round it | |||
stat_value = util_module.round_to_sig_fig(stat_value, 3) | |||
-- Add it to the row | |||
row_str = row_str .. "<td>" .. stat_value .. "</td>" | |||
end | |||
end | end | ||
end | end | ||
-- Add row to the body | |||
row_str = "<tr>" .. row_str .. "</tr>" | |||
body_str = body_str .. row_str | |||
first_hero = false | |||
end | end | ||
end | end | ||