75 lines
2.3 KiB
Lua
75 lines
2.3 KiB
Lua
local NanamiDPS = NanamiDPS
|
|
local DataStore = NanamiDPS.DataStore
|
|
local L = NanamiDPS.L
|
|
|
|
local DPS = {}
|
|
|
|
function DPS:GetName()
|
|
return L["DPS"]
|
|
end
|
|
|
|
function DPS:GetBars(segment)
|
|
if not segment or not segment.data or not segment.data.damage then return {} end
|
|
|
|
local bars = {}
|
|
for name, entry in pairs(segment.data.damage) 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 dps = entry._sum / math.max(entry._ctime, 1)
|
|
table.insert(bars, {
|
|
id = name,
|
|
name = name,
|
|
value = dps,
|
|
class = class,
|
|
r = r, g = g, b = b,
|
|
valueText = NanamiDPS.round(dps, 1) .. " DPS",
|
|
totalDamage = entry._sum,
|
|
ctime = entry._ctime,
|
|
})
|
|
end
|
|
|
|
table.sort(bars, function(a, b) return a.value > b.value end)
|
|
|
|
local best = bars[1] and bars[1].value or 0
|
|
for _, bar in ipairs(bars) do
|
|
bar.percent = best > 0 and (bar.value / best * 100) or 0
|
|
end
|
|
|
|
return bars
|
|
end
|
|
|
|
function DPS:GetTooltip(playerName, segment, tooltip)
|
|
if not segment or not segment.data.damage[playerName] then return end
|
|
local entry = segment.data.damage[playerName]
|
|
local dps = entry._sum / math.max(entry._ctime, 1)
|
|
|
|
tooltip:AddLine("|cffffd100" .. playerName)
|
|
tooltip:AddDoubleLine("|cffffffff" .. L["DPS"], "|cffffffff" .. NanamiDPS.round(dps, 1))
|
|
tooltip:AddDoubleLine("|cffffffff" .. L["Damage Done"], "|cffffffff" .. NanamiDPS.formatNumber(entry._sum))
|
|
tooltip:AddDoubleLine("|cffffffff" .. L["Active Time"],
|
|
"|cffffffff" .. NanamiDPS.formatTime(entry._ctime))
|
|
|
|
NanamiDPS.Tooltip:ShowSpellDetail(playerName, entry.spells, nil, entry._sum, nil, tooltip)
|
|
end
|
|
|
|
function DPS: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 - %.1f DPS (%s)",
|
|
i, d.name, d.value, NanamiDPS.formatNumber(d.totalDamage)))
|
|
end
|
|
return lines
|
|
end
|
|
|
|
NanamiDPS:RegisterModule("DPS", DPS)
|