Refactor Heimdall modules to use class-based structure for improved organization and clarity
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "Configurator"
|
||||
|
||||
---@class HeimdallConfiguratorConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
|
||||
local ModuleName = "Configurator"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Configurator = {}
|
||||
function shared.Configurator.Init() print(string.format("[Heimdall] %s module loaded", ModuleName)) end
|
||||
---@class Configurator
|
||||
shared.Configurator = {
|
||||
Init = function() print(string.format("[Heimdall] %s module loaded", ModuleName)) end,
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "DeathReporter"
|
||||
|
||||
---@class HeimdallDeathReporterConfig
|
||||
---@field enabled boolean
|
||||
@@ -10,11 +11,9 @@ local _, shared = ...
|
||||
---@field zoneOverride string?
|
||||
---@field duelThrottle number
|
||||
|
||||
local ModuleName = "DeathReporter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.DeathReporter = {}
|
||||
function shared.DeathReporter.Init()
|
||||
---@class DeathReporter
|
||||
shared.DeathReporter = {
|
||||
Init = function()
|
||||
---@type table<string, number>
|
||||
local recentDeaths = {}
|
||||
---@type table<string, number>
|
||||
@@ -48,7 +47,8 @@ function shared.DeathReporter.Init()
|
||||
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])
|
||||
local timeLeft = Heimdall_Data.config.deathReporter.throttle
|
||||
- (GetTime() - recentDeaths[destination])
|
||||
print(
|
||||
string.format(
|
||||
"[%s] Death report throttled for %s (%.1f seconds remaining)",
|
||||
@@ -232,7 +232,12 @@ function shared.DeathReporter.Init()
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Received system message: %s", ModuleName, msg))
|
||||
print(
|
||||
string.format("[%s] Source: %s, Destination: %s", ModuleName, tostring(source), tostring(destination))
|
||||
string.format(
|
||||
"[%s] Source: %s, Destination: %s",
|
||||
ModuleName,
|
||||
tostring(source),
|
||||
tostring(destination)
|
||||
)
|
||||
)
|
||||
end
|
||||
if not source or not destination then return end
|
||||
@@ -259,4 +264,5 @@ function shared.DeathReporter.Init()
|
||||
)
|
||||
end
|
||||
print("[Heimdall] DeathReporter loaded")
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@ local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "Dueler"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Dueler = {}
|
||||
function shared.Dueler.Init()
|
||||
---@class Dueler
|
||||
shared.Dueler = {
|
||||
Init = function()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("DUEL_REQUESTED")
|
||||
frame:SetScript("OnEvent", function(self, event, sender)
|
||||
@@ -36,7 +36,9 @@ function shared.Dueler.Init()
|
||||
CancelDuel()
|
||||
else
|
||||
if Heimdall_Data.config.dueler.debug then
|
||||
print(string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender))
|
||||
print(
|
||||
string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -52,4 +54,5 @@ function shared.Dueler.Init()
|
||||
)
|
||||
end
|
||||
print("[Heimdall] Dueler loaded")
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@ local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "Echoer"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Echoer = {}
|
||||
function shared.Echoer.Init()
|
||||
---@class Echoer
|
||||
shared.Echoer = {
|
||||
Init = function()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
@@ -55,4 +55,5 @@ function shared.Echoer.Init()
|
||||
|
||||
if Heimdall_Data.config.echoer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
||||
print("[Heimdall] Echoer loaded")
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@ local _, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
local ModuleName = "Emoter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Emoter = {}
|
||||
function shared.Emoter.Init()
|
||||
---@class Emoter
|
||||
shared.Emoter = {
|
||||
Init = function()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
@@ -56,4 +56,5 @@ function shared.Emoter.Init()
|
||||
|
||||
if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Module initialized", ModuleName)) end
|
||||
print("[Heimdall] Emoter loaded")
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
Reference in New Issue
Block a user