79 lines
2.3 KiB
Lua
79 lines
2.3 KiB
Lua
local NanamiDPS = NanamiDPS
|
|
local DataStore = NanamiDPS.DataStore
|
|
local L = NanamiDPS.L
|
|
|
|
local Dispels = {}
|
|
|
|
function Dispels:GetName()
|
|
return L["Dispels"]
|
|
end
|
|
|
|
function Dispels:GetBars(segment)
|
|
if not segment or not segment.data or not segment.data.dispels then return {} end
|
|
|
|
local bars = {}
|
|
for name, entry in pairs(segment.data.dispels) 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),
|
|
})
|
|
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 Dispels:GetTooltip(playerName, segment, tooltip)
|
|
if not segment or not segment.data.dispels[playerName] then return end
|
|
local entry = segment.data.dispels[playerName]
|
|
|
|
tooltip:AddLine("|cffffd100" .. playerName .. " - " .. L["Dispels"])
|
|
tooltip:AddDoubleLine("|cffffffff" .. L["Dispels"], "|cffffffff" .. (entry._sum or 0))
|
|
|
|
if entry.spells then
|
|
tooltip:AddLine(" ")
|
|
tooltip:AddLine("|cffffd100" .. L["Details"] .. ":")
|
|
local sorted = {}
|
|
for spell, count in pairs(entry.spells) do
|
|
table.insert(sorted, { spell = spell, count = count })
|
|
end
|
|
table.sort(sorted, function(a, b) return a.count > b.count end)
|
|
for _, s in ipairs(sorted) do
|
|
tooltip:AddDoubleLine("|cffffffff" .. s.spell, "|cffffffff" .. s.count)
|
|
end
|
|
end
|
|
end
|
|
|
|
function Dispels: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 - %d dispels", i, d.name, d.value))
|
|
end
|
|
return lines
|
|
end
|
|
|
|
NanamiDPS:RegisterModule("Dispels", Dispels)
|