local _, data = ... ---@cast data HeimdallData ---@class Heimdall_Data ---@field who { data: table } if not Heimdall_Data then Heimdall_Data = {} end -- We don't care about these persisting -- Actually we don't want some of them to persist -- For those we DO we use (global) Heimdall_Data ---@class HeimdallData ---@field config HeimdallConfig ---@field raceMap table ---@field classColors table ---@field stinkies table ---@field messenger HeimdallMessengerData ---@field who HeimdallWhoData ---@field dumpTable fun(table: any, depth?: number): nil ---@field utf8len fun(input: string): number ---@field padString fun(input: string, targetLength: number, left?: boolean): string --- Config --- ---@class HeimdallConfig ---@field spotter HeimdallSpotterConfig ---@field who HeimdallWhoConfig ---@field messenger HeimdallMessengerConfig ---@class HeimdallSpotterConfig ---@field enabled boolean ---@field everyone boolean ---@field hostile boolean ---@field alliance boolean ---@field stinky boolean ---@field notifyChannel string ---@field zoneOverride string? ---@field throttleTime number ---@class HeimdallWhoConfig ---@field enabled boolean ---@field ignored table ---@field notifyChannel string ---@field zoneNotifyFor table ---@field ttl number ---@class HeimdallMessengerConfig ---@field enabled boolean --- Data --- ---@class HeimdallMessengerData ---@field queue table ---@field ticker number? ---@class HeimdallWhoData ---@field updateTicker number? ---@field whoTicker number? ---@field ignored table data.messenger = { queue = {} } data.config = { spotter = { enabled = true, everyone = false, hostile = true, alliance = false, stinky = false, notifyChannel = "Foobar", zoneOverride = nil, throttleTime = 1 }, who = { enabled = true, ignored = {}, notifyChannel = "Foobar", ttl = 10, zoneNotifyFor = { ["Orgrimmar"] = true, ["Thunder Bluff"] = true, ["Undercity"] = true, ["Durotar"] = true, ["Echo Isles"] = true, ["Valley of Trials"] = true, } }, messenger = { enabled = true } } data.raceMap = { ["Orc"] = "Horde", ["Undead"] = "Horde", ["Tauren"] = "Horde", ["Troll"] = "Horde", ["Blood Elf"] = "Horde", ["Goblin"] = "Horde", ["Human"] = "Alliance", ["Dwarf"] = "Alliance", ["Night Elf"] = "Alliance", ["Gnome"] = "Alliance", ["Draenei"] = "Alliance", ["Worgen"] = "Alliance", ["Vulpera"] = "Horde", ["Nightborne"] = "Horde", ["Zandalari Troll"] = "Horde", ["Kul Tiran"] = "Alliance", ["Dark Iron Dwarf"] = "Alliance", ["Void Elf"] = "Alliance", ["Lightforged Draenei"] = "Alliance", ["Mechagnome"] = "Alliance", ["Mag'har Orc"] = "Horde" } ---@type table data.classColors = { ["Warrior"] = "C69B6D", ["Paladin"] = "F48CBA", ["Hunter"] = "AAD372", ["Rogue"] = "FFF468", ["Priest"] = "FFFFFF", ["Death Knight"] = "C41E3A", ["Shaman"] = "0070DD", ["Mage"] = "3FC7EB", ["Warlock"] = "8788EE", ["Monk"] = "00FF98", ["Druid"] = "FF7C0A", ["Demon Hunter"] = "A330C9" } data.stinkies = {} ---@param input string ---@return number data.utf8len = function(input) if not input then return 0 end local len = 0 local i = 1 local n = #input while i <= n do local c = input:byte(i) if c >= 0 and c <= 127 then i = i + 1 elseif c >= 194 and c <= 223 then i = i + 2 elseif c >= 224 and c <= 239 then i = i + 3 elseif c >= 240 and c <= 244 then i = i + 4 else i = i + 1 end len = len + 1 end return len end ---@param input string ---@param targetLength number ---@param left boolean ---@return string data.padString = function(input, targetLength, left) left = left or false local len = data.utf8len(input) if len < targetLength then if left then input = input .. string.rep(" ", targetLength - len) else input = string.rep(" ", targetLength - len) .. input end end return input end