Module:Sandbox/LVL: Difference between revisions

LVL (talk | contribs)
No edit summary
LVL (talk | contribs)
No edit summary
Line 722: Line 722:
    stat_value = util_module.round_to_sig_fig(stat_value, 3)
    stat_value = util_module.round_to_sig_fig(stat_value, 3)
end
end
-- Build tooltip content showing scaling info
local tooltip_lines = {}
if type(base_value) == "number" then
    table.insert(tooltip_lines, string.format("Base: %s", util_module.round_to_sig_fig(base_value, 3)))
end
if level_scale and level_scale > 0 then
    table.insert(tooltip_lines, string.format("Level: +%s per PI", level_scale))
end
if spirit_scale and spirit_scale > 0 then
    table.insert(tooltip_lines, string.format("Spirit: +%s per point", spirit_scale))
end
if innate_spirit_scale and innate_spirit_scale > 0 then
    table.insert(tooltip_lines, string.format("Innate Spirit: +%s per PI", innate_spirit_scale))
end
local tooltip_text = table.concat(tooltip_lines, "<br>")
-- Build data attributes for JavaScript manipulation (ONLY ONCE)
-- Build data attributes for JavaScript manipulation (ONLY ONCE)
Line 728: Line 745:
    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), -- Prevent double-counting
    (attr_key == "TechPower") and "0" or (tonumber(level_scale) or 0),
    innate_spirit_scale,
    innate_spirit_scale or 0,
    is_resist and ' data-is-resist="true"' or ''
    is_resist and ' data-is-resist="true"' or ''
)
-- Build cell with tooltip wrapper
local cell_inner = string.format(
    '<span class="tooltip-container">' ..
    '<span class="tooltip-trigger" tabindex="0"><span class="stat-num">%s</span></span>' ..
    '<span class="tooltip-content" role="tooltip">%s</span>' ..
    '</span>',
    stat_value,
    tooltip_text
)
)
-- Add it to the row with data attributes and span wrapper
-- Add it to the row with data attributes and span wrapper
row_str = row_str .. string.format(
row_str = row_str .. string.format(
    '<td %s><span class="stat-num">%s</span>%s</td>',
    '<td %s>%s</td>',
    data_attrs,
    data_attrs,
    stat_value,
    cell_inner
    scaling_strs
)
)
end
end