更新发送到功能
更新仇恨计算方式 还在开发 更新其他细节
This commit is contained in:
78
Modules/Interrupts.lua
Normal file
78
Modules/Interrupts.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
local NanamiDPS = NanamiDPS
|
||||
local DataStore = NanamiDPS.DataStore
|
||||
local L = NanamiDPS.L
|
||||
|
||||
local Interrupts = {}
|
||||
|
||||
function Interrupts:GetName()
|
||||
return L["Interrupts"]
|
||||
end
|
||||
|
||||
function Interrupts:GetBars(segment)
|
||||
if not segment or not segment.data or not segment.data.interrupts then return {} end
|
||||
|
||||
local bars = {}
|
||||
for name, entry in pairs(segment.data.interrupts) 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 Interrupts:GetTooltip(playerName, segment, tooltip)
|
||||
if not segment or not segment.data.interrupts[playerName] then return end
|
||||
local entry = segment.data.interrupts[playerName]
|
||||
|
||||
tooltip:AddLine("|cffffd100" .. playerName .. " - " .. L["Interrupts"])
|
||||
tooltip:AddDoubleLine("|cffffffff" .. L["Interrupts"], "|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 Interrupts: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 interrupts", i, d.name, d.value))
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
NanamiDPS:RegisterModule("Interrupts", Interrupts)
|
||||
Reference in New Issue
Block a user