local NanamiDPS = NanamiDPS local DataStore = NanamiDPS.DataStore local L = NanamiDPS.L local HealingBySpell = {} function HealingBySpell:GetName() return L["Healing by Spell"] end function HealingBySpell:GetBars(segment) if not segment or not segment.data or not segment.data.healing then return {} end local spellTotals = {} local spellEffective = {} for name, entry in pairs(segment.data.healing) do if entry.spells then for spell, amount in pairs(entry.spells) do spellTotals[spell] = (spellTotals[spell] or 0) + amount if entry.effective and entry.effective[spell] then spellEffective[spell] = (spellEffective[spell] or 0) + entry.effective[spell] end end end end local bars = {} for spell, total in pairs(spellTotals) do local effective = spellEffective[spell] or total local overheal = total - effective local r, g, b = NanamiDPS.str2rgb(spell) r = r * 0.4 + 0.3 g = g * 0.5 + 0.4 b = b * 0.4 + 0.3 local valText = NanamiDPS.formatNumber(effective) if overheal > 0 then valText = valText .. " |cffcc8888+" .. NanamiDPS.formatNumber(overheal) end table.insert(bars, { id = spell, name = spell, value = effective, r = r, g = g, b = b, valueText = valText, totalHeal = total, effectiveHeal = effective, overheal = overheal, }) end table.sort(bars, function(a, b) return a.value > b.value end) local grandTotal = 0 for _, bar in ipairs(bars) do grandTotal = grandTotal + bar.value end for _, bar in ipairs(bars) do bar.percent = grandTotal > 0 and (bar.value / grandTotal * 100) or 0 end return bars end function HealingBySpell:GetTooltip(spellName, segment, tooltip) tooltip:AddLine("|cffffd100" .. (spellName or L["Unknown"])) if segment and segment.data.healing then local users = {} local totalAmount = 0 local totalEffective = 0 for name, entry in pairs(segment.data.healing) do if entry.spells and entry.spells[spellName] then local eff = (entry.effective and entry.effective[spellName]) or entry.spells[spellName] table.insert(users, { name = name, amount = entry.spells[spellName], effective = eff, }) totalAmount = totalAmount + entry.spells[spellName] totalEffective = totalEffective + eff end end table.sort(users, function(a, b) return a.effective > b.effective end) tooltip:AddDoubleLine("|cffffffff" .. L["Healing Done"], "|cffffffff" .. NanamiDPS.formatNumber(totalEffective)) if totalAmount - totalEffective > 0 then tooltip:AddDoubleLine("|cffaaaaaa" .. L["Overheal"], "|cffcc8888+" .. NanamiDPS.formatNumber(totalAmount - totalEffective)) end if table.getn(users) > 0 then tooltip:AddLine(" ") tooltip:AddLine("|cffffd100" .. L["Players"] .. ":") for _, u in ipairs(users) do local oh = u.amount - u.effective local rightStr = NanamiDPS.formatNumber(u.effective) if oh > 0 then rightStr = rightStr .. " |cffcc8888+" .. NanamiDPS.formatNumber(oh) end tooltip:AddDoubleLine("|cffffffff" .. u.name, "|cffffffff" .. rightStr) end end end end function HealingBySpell: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.percent)) end return lines end NanamiDPS:RegisterModule("HealingBySpell", HealingBySpell)