Module:HeroData: Difference between revisions

Sur (talk | contribs)
m write_hero_comparison_table complete, now uses level/spirit scaling params
Sur (talk | contribs)
m finally a functioning version of all stats added
Line 3: Line 3:
local attributes_data = mw.loadJsonData("Data:AttributeData.json")
local attributes_data = mw.loadJsonData("Data:AttributeData.json")
local attribute_orders = mw.loadJsonData("Data:StatInfoboxOrder.json")
local attribute_orders = mw.loadJsonData("Data:StatInfoboxOrder.json")
local hero_comp_stats = mw.loadJsonData("Data:HeroStatConstants.json")
local util_module = require('Module:Utilities')
local util_module = require('Module:Utilities')
local lang_module = require('Module:Lang')
local lang_module = require('Module:Lang')
Line 383: Line 384:
local scalar_str
local scalar_str
-- Exclude some specific stats which are currently constant for all heroes at a negligible value
-- Add hero comp stats to
-- TODO extract from data directly
local stats_to_include = {
local stats_to_exclude = {
Weapon = {
BaseWeaponDamageIncrease = true,
"DPS",
FireRate = true,
            "SustainedDPS",
ClipSizeIncrease = true,
            "BulletDamage",
ReloadSpeed = true,
            "BaseWeaponDamageIncrease",
BulletSpeedIncrease = true,
            "RoundsPerSecond",
BulletLifesteal = true,
            "FireRate",
BulletShieldHealth = true,
            "ClipSize",
TechShieldHealth = true,
            "ClipSizeIncrease",
HealingOutput = true,
            "ReloadTime",
DebuffResist = true,
            "ReloadDelay",
CritDamageReceivedScale = true,
            "ReloadSpeed",
StaminaRegenIncrease = true,
            "BulletSpeed",
TechCooldown = true,
            "BulletSpeedIncrease",
TechDuration = true,
            "BulletLifesteal",
TechRange = true,
            "LightMeleeDamage",
TechLifesteal = true,
            "HeavyMeleeDamage",
MaxChargesIncrease = true,
            "BulletsPerShot",
TechCooldownBetweenChargeUses = true
            "ReloadSingle",
            "BulletGravityScale",
            "FalloffStartRange",
            "FalloffEndRange"
},
Vitality = {
"MaxHealth",
            "BaseHealthRegen",
            "BulletArmorDamageReduction",
            "TechArmorDamageReduction",
            "BulletShieldHealth",
            "TechShieldHealth",
            "HealingOutput",
            "DebuffResist",
            "CritDamageReceivedScale",
            "MaxMoveSpeed",
            "SprintSpeed",
            "StaminaCooldown",
            "StaminaRegenIncrease",
            "Stamina"
}
}
}
Line 437: Line 458:
-- Iterate attributes within the category
-- Iterate attributes within the category
for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do
if (stats_to_include[category] ~= nil) then
if (stats_to_exclude[attr_key] == nil) then
for _, attr_key in ipairs(stats_to_include[category]) do
attr_data = category_attrs[attr_key]
--Retrieve the stats value from hero data
--Retrieve the stats value from hero data
stat_value = hero_data[attr_key]
stat_value = hero_data[attr_key]
Line 457: Line 478:
end
end
-- Round it
-- Convert from boolean to string, or round it
stat_value = util_module.round_to_sig_fig(stat_value, 3)
if (type(stat_value)) == 'boolean' then
stat_value = tostring(stat_value)
else
stat_value = util_module.round_to_sig_fig(stat_value, 3)
end
-- Add it to the row
-- Add it to the row
Line 486: Line 511:
-- Iterate attributes within the category
-- Iterate attributes within the category
for _, attr_key in ipairs(attribute_orders[category]["attribute_order"]) do
if (stats_to_include[category] ~= nil) then
if (stats_to_exclude[attr_key] == nil) then
for _, attr_key in ipairs(stats_to_include[category]) do
attr_data = category_attrs[attr_key]
attr_data = category_attrs[attr_key]
-- Localize, fallback to attr_key
-- If not in attributes data, use key as localized
attr_localized = lang_module._get_string(attr_data["label"])
if (attr_data ~= nil) then
if (attr_localized == nil) then attr_localized = attr_key end
-- Localize, fallback to attr_key
attr_localized = lang_module._get_string(attr_data["label"])
if (attr_localized == nil) then attr_localized = attr_key end
else
attr_localized = attr_key
end
header_style = ' style="background-color: ' .. "rgb(" .. category_rgb .. ') ;"'
header_style = ' style="background-color: ' .. "rgb(" .. category_rgb .. ') ;"'