Module:Sandbox/LVL: Difference between revisions

LVL (talk | contribs)
No edit summary
Tag: Undo
LVL (talk | contribs)
No edit summary
Line 186: Line 186:
             elseif (attr_key == "DPS" or attr_key == "SustainedDPS")
             elseif (attr_key == "DPS" or attr_key == "SustainedDPS")
                 and hero_data.Weapon and hero_data.Weapon.AltFire then
                 and hero_data.Weapon and hero_data.Weapon.AltFire then
                 -- try direct scaling key (e.g., SustainedDPSAltFire)
                 -- try direct scaling key first
                 local direct_scaling = hero_data_module.get_hero_scaling_data(hero_data, attr_key .. "AltFire")
                 local direct_scaling = hero_data_module.get_hero_scaling_data(hero_data, attr_key .. "AltFire")
                 if direct_scaling and next(direct_scaling) ~= nil then
                 if direct_scaling and next(direct_scaling) ~= nil then
Line 196: Line 196:
                     local level_scale = compute_dps_scaling(hero_data, alt_stats, dps_type, "Level")
                     local level_scale = compute_dps_scaling(hero_data, alt_stats, dps_type, "Level")
                     local spirit_scale = compute_dps_scaling(hero_data, alt_stats, dps_type, "Spirit")
                     local spirit_scale = compute_dps_scaling(hero_data, alt_stats, dps_type, "Spirit")
                     -- round to 5 significant figures to match bot output
                     -- round to 5 sig figs to match bot output
                     level_scale = util_module.round_to_sig_fig(level_scale, 5)
                     level_scale = util_module.round_to_sig_fig(level_scale, 5)
                     spirit_scale = util_module.round_to_sig_fig(spirit_scale, 5)
                     spirit_scale = util_module.round_to_sig_fig(spirit_scale, 5)
Line 224: Line 224:
                     scaling_strs = scaling_strs .. scaling_str
                     scaling_strs = scaling_strs .. scaling_str
                 end
                 end
                 if scaling_type == "Spirit" then
                 if scaling_type == "Spirit" then
                     spirit_scale = scaling_val
                     spirit_scale = scaling_val
Line 239: Line 240:
         end
         end


         local innate_spirit_scale = (hero_data["LevelScaling"] and hero_data["LevelScaling"]["TechPower"]) or 0
         local innate_spirit_scale =
            (hero_data["LevelScaling"] and hero_data["LevelScaling"]["TechPower"]) or 0
 
         if not display_scaling_icons then scaling_strs = "" end
         if not display_scaling_icons then scaling_strs = "" end


         if type(stat_value) == "boolean" then stat_value = tostring(stat_value)
         if type(stat_value) == "boolean" then
         else stat_value = util_module.round_to_sig_fig(stat_value, 3) end
            stat_value = tostring(stat_value)
         else
            stat_value = util_module.round_to_sig_fig(stat_value, 3)
        end


         local cell_inner = string.format(
         local cell_inner = string.format(
             '<span class="stat-num">%s</span><span class="stat-scaling">%s</span>',
             '<span class="stat-num">%s</span><span class="stat-scaling">%s</span>',
             stat_value, scaling_strs
             stat_value,
            scaling_strs
         )
         )


Line 255: Line 262:
         end
         end
         local hit_once = "false"
         local hit_once = "false"
         if (attr_key == "DPS" or attr_key == "SustainedDPS") and weapon_table and weapon_table.HitOnceAcrossAllBullets then
         if (attr_key == "DPS" or attr_key == "SustainedDPS")
            and weapon_table
            and weapon_table.HitOnceAcrossAllBullets
        then
             hit_once = "true"
             hit_once = "true"
         end
         end
Line 269: Line 279:
             hit_once
             hit_once
         )
         )
         return string.format('<td style="white-space: nowrap;" %s>%s</td>', data_attrs, cell_inner)
         return string.format('<td style="white-space: nowrap;" %s>%s</td>', data_attrs, cell_inner)
     end
     end
Line 347: Line 358:
                     end
                     end
                     -- alt-fire checks (unchanged, but now DPS/SustainedDPS might be computed and should be caught)
                     -- alt-fire checks (unchanged, but now DPS/SustainedDPS might be computed and should be caught)
                    -- Alt-fire scaling (only if the stat exists in AltFire)
                     if hero_data.Weapon
                     if hero_data.Weapon
                         and hero_data.Weapon.AltFire
                         and hero_data.Weapon.AltFire