Code format
This commit is contained in:
@@ -16,21 +16,21 @@ function shared.DeathReporter.Init()
|
||||
---@param spellName string
|
||||
local function RegisterDeath(source, destination, spellName)
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s",
|
||||
print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s",
|
||||
ModuleName, source, destination, spellName))
|
||||
end
|
||||
|
||||
if not Heimdall_Data.config.deathReporter.enabled then
|
||||
|
||||
if not Heimdall_Data.config.deathReporter.enabled then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Module disabled, ignoring death event", ModuleName))
|
||||
end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if recentDeaths[destination] and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination])
|
||||
print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)",
|
||||
print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)",
|
||||
ModuleName, destination, timeLeft))
|
||||
end
|
||||
return
|
||||
@@ -38,14 +38,16 @@ function shared.DeathReporter.Init()
|
||||
|
||||
if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName, destination))
|
||||
print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName,
|
||||
destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName, source))
|
||||
print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName,
|
||||
source))
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -54,27 +56,29 @@ function shared.DeathReporter.Init()
|
||||
print(string.format("[%s] Recording death for %s", ModuleName, destination))
|
||||
end
|
||||
recentDeaths[destination] = GetTime()
|
||||
|
||||
|
||||
C_Timer.NewTimer(3, function()
|
||||
if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, destination))
|
||||
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName,
|
||||
destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, source))
|
||||
print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName,
|
||||
source))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Sending death report - %s killed %s with %s",
|
||||
print(string.format("[%s] Sending death report - %s killed %s with %s",
|
||||
ModuleName, source, destination, spellName))
|
||||
end
|
||||
|
||||
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
@@ -132,12 +136,12 @@ function shared.DeathReporter.Init()
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Received system message: %s", ModuleName, msg))
|
||||
end
|
||||
|
||||
if not Heimdall_Data.config.deathReporter.enabled then
|
||||
|
||||
if not Heimdall_Data.config.deathReporter.enabled then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Module disabled, ignoring event", ModuleName))
|
||||
end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
if event == "DUEL_REQUESTED" then
|
||||
@@ -159,21 +163,21 @@ function shared.DeathReporter.Init()
|
||||
|
||||
local subevent = select(2, ...)
|
||||
if subevent ~= "PARTY_KILL" and subevent ~= "UNIT_DIED" then return end
|
||||
|
||||
|
||||
local source, err = CLEUParser.GetSourceName(...)
|
||||
if err then
|
||||
if err then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Error getting source: %s", ModuleName, err))
|
||||
end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local destination, err = CLEUParser.GetDestName(...)
|
||||
if err then
|
||||
if err then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Error getting destination: %s", ModuleName, err))
|
||||
end
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
@@ -182,12 +186,12 @@ function shared.DeathReporter.Init()
|
||||
|
||||
local spellId = CLEUParser.GetSpellId(...)
|
||||
local spellName = GetSpellInfo(spellId) or "Unknown Spell"
|
||||
|
||||
|
||||
RegisterDeath(source, destination, spellName)
|
||||
end)
|
||||
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs",
|
||||
print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs",
|
||||
ModuleName, Heimdall_Data.config.deathReporter.throttle, Heimdall_Data.config.deathReporter.duelThrottle))
|
||||
end
|
||||
print("[Heimdall] DeathReporter loaded")
|
||||
|
||||
Reference in New Issue
Block a user