More actions
m fix outdated use of PageRef for write_default_items() |
m use {{PI}} instead of {{Ls}} for level scaling |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 139: | Line 139: | ||
--If the hero scales with the stat, it returns {{Ss|value}} or {{Ls|value}}, else blank string | --If the hero scales with the stat, it returns {{Ss|value}} or {{Ls|value}}, else blank string | ||
--{{#invoke:HeroData| | --{{#invoke:HeroData|get_hero_scalar|HERO_NAME|SCALING_TYPE|STAT_NAME}}-- | ||
p. | p.get_hero_scalar = function(frame) | ||
local | local hero_key = frame.args[1] | ||
local hero_stat_key = frame.args[ | local scaling_type = frame.args[2] | ||
local hero_data = | local hero_stat_key = frame.args[3] | ||
if(hero_data == nil) then return "Hero | |||
return p. | local hero_data = heroes_data[hero_key] | ||
if(hero_data == nil) then return "Hero " .. hero_key .. " not found." end | |||
local scaling_data = hero_data[scaling_type .. "Scaling"] | |||
if scaling_data == nil then return scaling_type .. "Scaling data not found for hero" .. hero_key end | |||
local scaling_value = scaling_data[hero_stat_key] | |||
if scaling_value == nil then return scaling_type .. "Scaling data does not have key " .. hero_stat_key .. " for hero " .. hero_key end | |||
local scaling_str = p.write_scalar_str(scaling_value, scaling_type) | |||
if (scaling_str ~= "") then scaling_str = " " .. scaling_str end | |||
return scaling_str | |||
end | end | ||
-- Retrieve scaling string of a hero's given stat, if it has scaling, else return blank | -- Retrieve scaling string of a hero's given stat, if it has scaling, else return blank | ||
-- Scaling string meaning the expanded template {{Ss|scalar}} or {{Ls|scalar}} | -- Scaling string meaning the expanded template {{Ss|scalar}} or {{Ls|scalar}} | ||
function p. | function p.write_scalar_str(scaling_value, scaling_type) | ||
local scaling_abbrevs = {Spirit = "Ss", Level = " | local scaling_abbrevs = {Spirit = "Ss", Level = "PI"} | ||
-- Return blank if it doesnt scale | -- Return blank if it doesnt scale | ||
Line 170: | Line 181: | ||
-- Retrieve scaling value and type of a hero's given stat, if it has scaling, else return 0 | -- Retrieve scaling value and type of a hero's given stat, if it has scaling, else return 0 | ||
function p. | function p.get_hero_scaling_data(hero_data, hero_stat_key) | ||
local scaling_type_full | local scaling_type_full | ||
local scaling_data | local scaling_data | ||
Line 381: | Line 392: | ||
-- Add the scaling str if it scales | -- Add the scaling str if it scales | ||
local scaling_data = p. | local scaling_data = p.get_hero_scaling_data(hero_data, stat_name) | ||
local scaling_strs = "" | local scaling_strs = "" | ||
if (scaling_data ~= nil) then | if (scaling_data ~= nil) then | ||
for scaling_value, scaling_type in pairs(scaling_data) do | for scaling_value, scaling_type in pairs(scaling_data) do | ||
local scaling_str = p. | local scaling_str = p.write_scalar_str(scaling_value, scaling_type) | ||
if (scaling_str ~= "") then scaling_str = " " .. scaling_str end | if (scaling_str ~= "") then scaling_str = " " .. scaling_str end | ||
scaling_strs = scaling_strs .. scaling_str | scaling_strs = scaling_strs .. scaling_str | ||
Line 482: | Line 493: | ||
in_development = hero_data["InDevelopment"] | in_development = hero_data["InDevelopment"] | ||
is_disabled = hero_data["IsDisabled"] | is_disabled = hero_data["IsDisabled"] | ||
if | if (not is_disabled) then | ||
--Add the row's stats | --Add the row's stats | ||
Line 517: | Line 528: | ||
-- Retrieve scaling val and str if it scales | -- Retrieve scaling val and str if it scales | ||
local scaling_data = p. | local scaling_data = p.get_hero_scaling_data(hero_data, attr_key) | ||
local scaling_strs = "" | local scaling_strs = "" | ||
if (scaling_data ~= nil) then | if (scaling_data ~= nil) then | ||
for scaling_value, scaling_type in pairs(scaling_data) do | for scaling_value, scaling_type in pairs(scaling_data) do | ||
local scaling_str = p. | local scaling_str = p.write_scalar_str(scaling_value, scaling_type) | ||
if (scaling_str ~= "") then scaling_str = " " .. scaling_str end | if (scaling_str ~= "") then scaling_str = " " .. scaling_str end | ||
if (scaling_str ~= nil) then | if (scaling_str ~= nil) then |