local NanamiDPS = NanamiDPS local DataStore = NanamiDPS.DataStore local L = NanamiDPS.L local Deaths = {} function Deaths:GetName() return L["Deaths"] end function Deaths:GetBars(segment) if not segment or not segment.data or not segment.data.deaths then return {} end local bars = {} for name, entry in pairs(segment.data.deaths) 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 table.insert(bars, { id = name, name = name, value = entry._sum or 0, class = class, r = r, g = g, b = b, valueText = tostring(entry._sum or 0) .. "x", events = entry.events, }) end table.sort(bars, function(a, b) return a.value > b.value end) return bars end function Deaths:GetTooltip(playerName, segment, tooltip) if not segment or not segment.data.deaths[playerName] then return end local entry = segment.data.deaths[playerName] tooltip:AddLine("|cffffd100" .. playerName .. " - " .. L["Deaths"]) tooltip:AddDoubleLine("|cffffffff" .. L["Deaths"], "|cffffffff" .. (entry._sum or 0)) if entry.events and table.getn(entry.events) > 0 then local lastDeath = entry.events[table.getn(entry.events)] tooltip:AddLine(" ") tooltip:AddLine("|cffffd100" .. L["Last Events"] .. " (" .. (lastDeath.timeStr or "") .. "):") if lastDeath.events then local startIdx = math.max(1, table.getn(lastDeath.events) - 9) for i = startIdx, table.getn(lastDeath.events) do local evt = lastDeath.events[i] if evt then local timeAgo = "" if lastDeath.time and evt.time then timeAgo = string.format("-%.1fs", lastDeath.time - evt.time) end if evt.type == "damage" then local line = string.format("|cffff4444-%s|r %s (%s)", NanamiDPS.formatNumber(math.abs(evt.amount or 0)), evt.spell or "?", evt.source or "?") tooltip:AddDoubleLine("|cffaaaaaa" .. timeAgo, line) elseif evt.type == "heal" then local line = string.format("|cff44ff44+%s|r %s (%s)", NanamiDPS.formatNumber(evt.amount or 0), evt.spell or "?", evt.source or "?") tooltip:AddDoubleLine("|cffaaaaaa" .. timeAgo, line) end end end end end end function Deaths: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 - %dx deaths", i, d.name, d.value)) end return lines end NanamiDPS:RegisterModule("Deaths", Deaths)