Module:HeroData: Difference between revisions

Jump to navigation Jump to search
Sur (talk | contribs)
m create_stat_boxes moved to hero.write_stat_boxes
Sur (talk | contribs)
m category data moved to attribute data; utils_module>util_module; attributes_module>attribute_module
Line 2: Line 2:
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local heroes_data = mw.loadJsonData("Data:HeroData.json")
local attributes_data = mw.loadJsonData("Data:AttributeData.json")
local attributes_data = mw.loadJsonData("Data:AttributeData.json")
local utils_module = require('Module:Utilities')
local util_module = require('Module:Utilities')
local attribute_module = require('Module:AttributeData')


-- returns the table of a specific item, used by external modules
-- returns the table of a specific item, used by external modules
Line 57: Line 58:
--If the stat scales
--If the stat scales
if (scaling_value ~= nil) then
if (scaling_value ~= nil) then
scaling_value = utils_module.round_to_sig_fig(scaling_value, 3)
scaling_value = util_module.round_to_sig_fig(scaling_value, 3)
--The hero has a scaling value with this stat
--The hero has a scaling value with this stat
Line 124: Line 125:
local stats_to_add_blank_after = {BulletLifesteal = true, CritDamageReceivedScale = true}
local stats_to_add_blank_after = {BulletLifesteal = true, CritDamageReceivedScale = true}
if (hero_data == nil) then return "Hero Not Found in AttrData" end
if (hero_data == nil) then return "Hero Not Found in AttrData" end
local category_data = { --category specific parameters
local category_data = attribute_module.get_category_data()
["Weapon"] = {
box_name = "CitadelCategoryWeapon",
box_rgb = "213, 144, 63",
num_cols = 2
},
["Vitality"] = {
box_name = "CitadelCategoryArmor",
box_rgb = "116, 176, 28",
num_cols = 2
},
["Spirit"] = {
box_name = "CitadelCategoryTech",
box_rgb = "194, 136, 240",
num_cols = 2
},
}
for _, category in ipairs(attributes_data["_category_order"]) do
for _, category in ipairs(attributes_data["_category_order"]) do
stats = attributes_data[category]
stats = attributes_data[category]
local category_values = category_data[category]
local category_values = category_data[category]
template_args["box_name"] = category_values.box_name
template_args["box_name"] = category_values.unlocalized_name
template_args["box_rgb"] = category_values.box_rgb
template_args["box_rgb"] = category_values.rgb
template_args["num_cols"] = category_values.num_cols
template_args["num_cols"] = 2
cell_values = ""
cell_values = ""
Line 165: Line 150:
--Round value to 3 significant figures
--Round value to 3 significant figures
stat_value = utils_module.round_to_sig_fig(stat_value, 3)
stat_value = util_module.round_to_sig_fig(stat_value, 3)
 
 
-- get label and postfix
-- get label and postfix
label = utils_module.call_lang(stat_data["label"])
label = util_module.call_lang(stat_data["label"])
postfix = stat_data["postfix"]
postfix = stat_data["postfix"]
if (postfix == nil) then  
if (postfix == nil) then  
postfix = ""
postfix = ""
else
else
postfix = utils_module.call_lang(postfix)
postfix = util_module.call_lang(postfix)
end
end
-- Check if icon file exists, and if not, don't use any image
-- Check if icon file exists, and if not, don't use any image
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
image_file_name = 'File:AttributeIcon' .. stat_name .. '.png'
image_file_name = utils_module.get_image_file(image_file_name)
image_file_name = util_module.get_image_file(image_file_name)
-- Add an empty cell following some stats to align them correctly as seen in game
-- Add an empty cell following some stats to align them correctly as seen in game