Module:HeroData: Difference between revisions

Jump to navigation Jump to search
Sur (talk | contribs)
m BonusAttackRange added to hero comparison
Sur (talk | contribs)
m level/spirit scaling now supports multiple scalings at once, mostly for dps/sustained dps
Line 114: Line 114:
local scaling_value
local scaling_value
local scaling_types = {"Spirit", "Level"}
local scaling_types = {"Spirit", "Level"}
local scaling_data_returned = {}
for index, scaling_type in ipairs(scaling_types) do
for index, scaling_type in ipairs(scaling_types) do
Line 125: Line 126:
--If the stat scales
--If the stat scales
if (scaling_value ~= nil) then
if (scaling_value ~= nil) then
return scaling_value, scaling_type
scaling_data_returned[scaling_value] = scaling_type
end
end
end
end
end
end
-- If it doesn't scale, return 0 for value and empty string for scaling type
return scaling_data_returned
return 0, ""
end
end


Line 332: Line 332:
-- Add the scaling str if it scales
-- Add the scaling str if it scales
local scaling_value, scaling_type = p.get_hero_scalar(hero_data, stat_name)
local scaling_data = p.get_hero_scalar(hero_data, stat_name)
local scalar_str = p.get_hero_scalar_str(scaling_value, scaling_type)
local scaling_strs = ""
if (scalar_str ~= "") then scalar_str = " " .. scalar_str end
if (scaling_data ~= nil) then
for scaling_value, scaling_type in pairs(scaling_data) do
local scaling_str = p.get_hero_scalar_str(scaling_value, scaling_type)
if (scaling_str ~= "") then scaling_str = " " .. scaling_str end
scaling_strs = scaling_strs .. scaling_str
end
end
-- Set cell value as "Icon StatvaluePostfix Statname Scaling,"
-- Set cell value as "Icon StatvaluePostfix Statname Scaling,"
-- If icon file already exists, set it to #REDIRECT to the duplicate file page
-- 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_value = image_file .. " " .. stat_value  .. postfix .. " " .. label  .. scaling_strs .. "," .. extra_blank_cell
cell_values = cell_values .. cell_value --add value to values list
cell_values = cell_values .. cell_value --add value to values list
Line 449: Line 455:
-- Iterate attributes within the category
-- Iterate attributes within the category
if (stats_to_include[category] ~= nil) then
if (stats_to_include[category] ~= nil) then
for _, attr_key in ipairs(stats_to_include[category]) do
for _, attr_key in ipairs(stats_to_include[category]) do
Line 456: Line 463:
-- Retrieve scaling val and str if it scales
-- Retrieve scaling val and str if it scales
local scaling_value, scaling_type = p.get_hero_scalar(hero_data, attr_key)
local scaling_data = p.get_hero_scalar(hero_data, attr_key)
local scalar_str = p.get_hero_scalar_str(scaling_value, scaling_type)
local scaling_strs = ""
if (scalar_str ~= "") then scalar_str = " " .. scalar_str end
if (scaling_data ~= nil) then
if (not display_scaling_icons) then scalar_str = "" end
for scaling_value, scaling_type in pairs(scaling_data) do
local scaling_str = p.get_hero_scalar_str(scaling_value, scaling_type)
if (scaling_str ~= "") then scaling_str = " " .. scaling_str end
if (scaling_str ~= nil) then
scaling_strs = scaling_strs .. scaling_str
end
-- Scale the stat value
if (scaling_type == "Spirit") then
stat_value = stat_value + (spirit_power * scaling_value)
elseif (scaling_type == "Level") then
stat_value = stat_value + (power_increases * scaling_value)
end
end
end
if (not display_scaling_icons) then scaling_strs = "" end
-- Scale the stat value
if (scaling_type == "Spirit") then
stat_value = stat_value + (spirit_power * scaling_value)
elseif (scaling_type == "Level") then
stat_value = stat_value + (power_increases * scaling_value)
end
-- Convert from boolean to string, or round it
-- Convert from boolean to string, or round it
Line 476: Line 492:
-- Add it to the row
-- Add it to the row
row_str = row_str .. "<td>" .. stat_value .. scalar_str .. "</td>"
row_str = row_str .. "<td>" .. stat_value .. scaling_strs .. "</td>"
end
end
end
end
Line 505: Line 521:
for _, attr_key in ipairs(stats_to_include[category]) do
for _, attr_key in ipairs(stats_to_include[category]) do
attr_data = category_attrs[attr_key]
attr_data = category_attrs[attr_key]
if (attr_data ~= nil) then
if (attr_data ~= nil) then
Line 522: Line 537:
attr_localized = util_module.add_space_before_cap(attr_key)
attr_localized = util_module.add_space_before_cap(attr_key)
end
end
header_style = ' style="background-color: ' .. "rgb(" .. category_rgb .. ') ;"'
header_style = ' style="background-color: ' .. "rgb(" .. category_rgb .. ') ;"'