Module:Sandbox/LVL: Difference between revisions

LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
Resist scaling fix
Line 442: Line 442:
local spirit_scale = 0
local spirit_scale = 0
local level_scale = 0
local level_scale = 0
local is_resist = (attr_key == 'TechResist' or attr_key == 'BulletResist')
 
if (scaling_data ~= nil) then
if (scaling_data ~= nil) then
    for scaling_val, scaling_type in pairs(scaling_data) do
    for scaling_val, scaling_type in pairs(scaling_data) do
Line 453: Line 452:
         
         
        -- Track scaling values for data attributes
        -- Track scaling values for data attributes
        if (scaling_type == "Spirit") then
if (scaling_type == "Spirit") then
            spirit_scale = scaling_val
    spirit_scale = scaling_val
            stat_value = stat_value + (spirit_power * scaling_val)
    stat_value = stat_value + (spirit_power * scaling_val)
        elseif (scaling_type == "Level") then
elseif (scaling_type == "Level") then
            level_scale = scaling_val
    level_scale = scaling_val
            if is_resist then
    stat_value = stat_value + (power_increases * scaling_val)
                -- each PI for resists is multiplicative
end
                stat_value = (stat_value/100 + 1 - (1-scaling_val/100)^power_increases)*100
            else
                stat_value = stat_value + (power_increases * scaling_val)
            end
        end
    end
    end
end
end
Line 501: Line 495:
-- Build data attributes for JavaScript manipulation
-- Build data attributes for JavaScript manipulation
local data_attrs = string.format(
local data_attrs = string.format(
    'data-base="%s" data-spirit-scale="%s" data-level-scale="%s" data-innate-spirit-scale="%s"%s',
    'data-base="%s" data-spirit-scale="%s" data-level-scale="%s" data-innate-spirit-scale="%s" data-sort-value="%s"',
    tostring(type(base_value) == "number" and util_module.round_to_sig_fig(base_value, 3) or base_value),
    tostring(type(base_value) == "number" and util_module.round_to_sig_fig(base_value, 3) or base_value),
    tonumber(spirit_scale) or 0,
    tonumber(spirit_scale) or 0,
    (attr_key == "TechPower") and "0" or (tonumber(level_scale) or 0),
    (attr_key == "TechPower") and "0" or (tonumber(level_scale) or 0), -- Keep this TechPower check to prevent double-scaling
    innate_spirit_scale or 0,
    innate_spirit_scale or 0,
    is_resist and ' data-is-resist="true"' or ''
    stat_value
)
)