local NanamiDPS = NanamiDPS local DataStore = NanamiDPS.DataStore local L = NanamiDPS.L local Overhealing = {} function Overhealing:GetName() return L["Overhealing"] end function Overhealing:GetBars(segment) if not segment or not segment.data or not segment.data.healing then return {} end local bars = {} for name, entry in pairs(segment.data.healing) do local class = DataStore:GetClass(name) local r, g, b = NanamiDPS.GetClassColor(class) if not NanamiDPS.validClasses[class] then r, g, b = NanamiDPS.str2rgb(name) r = r * 0.6 + 0.4 g = g * 0.6 + 0.4 b = b * 0.6 + 0.4 end local effectiveVal = entry._esum or entry._sum local overhealVal = entry._sum - effectiveVal local overhealPct = entry._sum > 0 and (overhealVal / entry._sum * 100) or 0 if overhealVal > 0 then table.insert(bars, { id = name, name = name, value = overhealVal, class = class, r = r * 0.7 + 0.3, g = g * 0.5, b = b * 0.5, valueText = NanamiDPS.formatNumber(overhealVal) .. " (" .. NanamiDPS.round(overhealPct, 1) .. "%)", overhealPct = overhealPct, totalHeal = entry._sum, effectiveHeal = effectiveVal, }) end end table.sort(bars, function(a, b) return a.value > b.value end) local total = 0 for _, bar in ipairs(bars) do total = total + bar.value end for _, bar in ipairs(bars) do bar.percent = total > 0 and (bar.value / total * 100) or 0 end return bars end function Overhealing:GetTooltip(playerName, segment, tooltip) if not segment or not segment.data.healing[playerName] then return end local entry = segment.data.healing[playerName] local effectiveVal = entry._esum or entry._sum local overhealVal = entry._sum - effectiveVal local overhealPct = entry._sum > 0 and NanamiDPS.round(overhealVal / entry._sum * 100, 1) or 0 tooltip:AddLine("|cffffd100" .. playerName) tooltip:AddDoubleLine("|cffcc8888" .. L["Overhealing"], "|cffcc8888" .. NanamiDPS.formatNumber(overhealVal)) tooltip:AddDoubleLine("|cffcc8888" .. L["Overheal %"], "|cffcc8888" .. overhealPct .. "%") tooltip:AddDoubleLine("|cffffffff" .. L["Healing Done"], "|cffffffff" .. NanamiDPS.formatNumber(entry._sum)) tooltip:AddDoubleLine("|cffffffff" .. L["Effective"], "|cffffffff" .. NanamiDPS.formatNumber(effectiveVal)) if entry.spells and entry.effective then tooltip:AddLine(" ") tooltip:AddLine("|cffffd100" .. L["Details"] .. ":") local sorted = {} for spell, amount in pairs(entry.spells) do table.insert(sorted, { spell = spell, amount = amount }) end table.sort(sorted, function(a, b) return a.amount > b.amount end) for _, s in ipairs(sorted) do local eff = entry.effective[s.spell] or s.amount local oh = s.amount - eff if oh > 0 then local pct = s.amount > 0 and NanamiDPS.round(oh / s.amount * 100, 1) or 0 tooltip:AddDoubleLine("|cffffffff" .. s.spell, "|cffcc8888+" .. NanamiDPS.formatNumber(oh) .. " (" .. pct .. "%)") end end end end function Overhealing:GetReportLines(segment, count) local bars = self:GetBars(segment) local lines = {} count = count or 5 for i = 1, math.min(count, table.getn(bars)) do local d = bars[i] table.insert(lines, string.format("%d. %s - %s (%.1f%%)", i, d.name, NanamiDPS.formatNumber(d.value), d.overhealPct)) end return lines end NanamiDPS:RegisterModule("Overhealing", Overhealing)