Module:Sandbox/LVL: Difference between revisions

LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 122: Line 122:
             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
                     -- Base value: only use AltFire if the stat actually exists there
                     -- Base value: special cases for alt-fire row
                     local base_value
                     local base_value
                     if is_alt_fire and hero_data.Weapon and hero_data.Weapon.AltFire
                     if is_alt_fire then
                        and hero_data.Weapon.AltFire[attr_key] ~= nil then
                        -- ClipSize always uses primary
                        base_value = hero_data.Weapon.AltFire[attr_key]
                        if attr_key == "ClipSize" then
                            base_value = get_nested_stat_value(hero_data, attr_key)
                        elseif hero_data.Weapon and hero_data.Weapon.AltFire
                            and hero_data.Weapon.AltFire[attr_key] ~= nil then
                            base_value = hero_data.Weapon.AltFire[attr_key]
                        else
                            base_value = get_nested_stat_value(hero_data, attr_key)
                        end
                     else
                     else
                         base_value = get_nested_stat_value(hero_data, attr_key)
                         base_value = get_nested_stat_value(hero_data, attr_key)
Line 133: Line 140:
                     local stat_value = base_value
                     local stat_value = base_value


                     -- Scaling: only look for AltFire scaling if the stat exists in AltFire
                     -- Scaling: special cases for alt-fire row
                     local scaling_data
                     local scaling_data
                     if is_alt_fire and hero_data.Weapon and hero_data.Weapon.AltFire
                     if is_alt_fire then
                        and hero_data.Weapon.AltFire[attr_key] ~= nil then
                        -- ClipSize always uses primary scaling
                        scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key .. "AltFire")
                        if attr_key == "ClipSize" then
                            scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key)
                        -- Shiv's alt‑fire BulletDamage uses primary scaling
                        elseif hero_key == "hero_shiv" and attr_key == "BulletDamage" then
                            scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key)
                        elseif hero_data.Weapon and hero_data.Weapon.AltFire
                            and hero_data.Weapon.AltFire[attr_key] ~= nil then
                            scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key .. "AltFire")
                        else
                            scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key)
                        end
                     else
                     else
                         scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key)
                         scaling_data = hero_data_module.get_hero_scaling_data(hero_data, attr_key)
Line 253: Line 270:
                     end
                     end


                     -- FIX 2: Alt-fire scaling only for stats that actually appear in AltFire
                     -- Alt-fire scaling (only for stats that truly appear in AltFire)
                     if hero_data.Weapon
                     if hero_data.Weapon
                         and hero_data.Weapon.AltFire
                         and hero_data.Weapon.AltFire
                         and hero_data.Weapon.AltFire[attr_key] ~= nil
                         and hero_data.Weapon.AltFire[attr_key] ~= nil
                     then
                     then
                         local alt_scaling = hero_data_module.get_hero_scaling_data(hero_data, attr_key .. "AltFire")
                         -- Skip ClipSize (we always use primary scaling, no alt column needed)
                        if alt_scaling ~= nil and next(alt_scaling) ~= nil then
                        if attr_key == "ClipSize" then
                            stats_with_any_scaling[attr_key] = true
                            -- do nothing
                            local has_spirit_alt = false
                        elseif hero_entry.key == "hero_shiv" and attr_key == "BulletDamage" then
                            local has_level_alt  = false
                            -- Shiv's alt‑fire BulletDamage uses primary scaling; already counted
                            for _, scaling_type in pairs(alt_scaling) do
                        else
                                if scaling_type == "Spirit" then has_spirit_alt = true end
                            local alt_scaling = hero_data_module.get_hero_scaling_data(hero_data, attr_key .. "AltFire")
                                if scaling_type == "Level"  then has_level_alt  = true end
                            if alt_scaling ~= nil and next(alt_scaling) ~= nil then
                            end
                                stats_with_any_scaling[attr_key] = true
                            if has_spirit_alt and has_level_alt then
                                local has_spirit_alt = false
                                stats_with_both_scaling[attr_key] = true
                                local has_level_alt  = false
                                for _, scaling_type in pairs(alt_scaling) do
                                    if scaling_type == "Spirit" then has_spirit_alt = true end
                                    if scaling_type == "Level"  then has_level_alt  = true end
                                end
                                if has_spirit_alt and has_level_alt then
                                    stats_with_both_scaling[attr_key] = true
                                end
                             end
                             end
                         end
                         end