更新发送到功能
更新仇恨计算方式 还在开发 更新其他细节
This commit is contained in:
90
Modules/EnemyDamageDone.lua
Normal file
90
Modules/EnemyDamageDone.lua
Normal file
@@ -0,0 +1,90 @@
|
||||
local NanamiDPS = NanamiDPS
|
||||
local DataStore = NanamiDPS.DataStore
|
||||
local L = NanamiDPS.L
|
||||
|
||||
local EnemyDamageDone = {}
|
||||
|
||||
function EnemyDamageDone:GetName()
|
||||
return L["Enemy Damage Done"]
|
||||
end
|
||||
|
||||
function EnemyDamageDone:GetBars(segment)
|
||||
if not segment or not segment.data or not segment.data.damageTaken then return {} end
|
||||
|
||||
-- Aggregate damage by source across all targets
|
||||
local bySource = {}
|
||||
for targetName, entry in pairs(segment.data.damageTaken) do
|
||||
if entry.spells then
|
||||
for spell, amount in pairs(entry.spells) do
|
||||
-- Extract real source from spell name if available
|
||||
-- Otherwise group by spell
|
||||
if not bySource[spell] then
|
||||
bySource[spell] = 0
|
||||
end
|
||||
bySource[spell] = bySource[spell] + amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local bars = {}
|
||||
for spell, total in pairs(bySource) do
|
||||
local r, g, b = NanamiDPS.str2rgb(spell)
|
||||
r = r * 0.5 + 0.5
|
||||
g = g * 0.3 + 0.2
|
||||
b = b * 0.3 + 0.2
|
||||
|
||||
table.insert(bars, {
|
||||
id = spell,
|
||||
name = spell,
|
||||
value = total,
|
||||
r = r, g = g, b = b,
|
||||
})
|
||||
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 EnemyDamageDone:GetTooltip(spellName, segment, tooltip)
|
||||
tooltip:AddLine("|cffffd100" .. (spellName or L["Unknown"]))
|
||||
|
||||
-- Find all targets hit by this spell
|
||||
if segment and segment.data.damageTaken then
|
||||
local targets = {}
|
||||
for targetName, entry in pairs(segment.data.damageTaken) do
|
||||
if entry.spells and entry.spells[spellName] then
|
||||
table.insert(targets, { name = targetName, amount = entry.spells[spellName] })
|
||||
end
|
||||
end
|
||||
table.sort(targets, function(a, b) return a.amount > b.amount end)
|
||||
|
||||
if table.getn(targets) > 0 then
|
||||
tooltip:AddLine(" ")
|
||||
tooltip:AddLine("|cffffd100" .. L["Targets"] .. ":")
|
||||
for _, t in ipairs(targets) do
|
||||
tooltip:AddDoubleLine("|cffffffff" .. t.name, "|cffffffff" .. NanamiDPS.formatNumber(t.amount))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function EnemyDamageDone: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("EnemyDamageDone", EnemyDamageDone)
|
||||
Reference in New Issue
Block a user