diff --git a/src/Command/Command.lua b/src/Command/Command.lua index ca0abf1..f4380b9 100644 --- a/src/Command/Command.lua +++ b/src/Command/Command.lua @@ -81,6 +81,5 @@ function Command:PrintHelp() end end -Bastion.Globals.Command = Command:New("bastion") - Bastion.Command = Command +Bastion.Globals.Command = Bastion.Command:New("bastion") diff --git a/src/EventManager/EventManager.lua b/src/EventManager/EventManager.lua index 2418fe2..9dc8cbd 100644 --- a/src/EventManager/EventManager.lua +++ b/src/EventManager/EventManager.lua @@ -25,11 +25,6 @@ EventManager.__index = EventManager ---@return Bastion.EventManager function EventManager:New() local self = setmetatable({}, EventManager) - self.events = {} - self.eventHandlers = {} - self.wowEventHandlers = {} - self.selfCombatEventHandlers = {} - self.CombatEventHandlers = {} self.playerGUID = UnitGUID("player") or false -- Frame for wow events @@ -138,6 +133,6 @@ function EventManager:CLEUHandler(timestamp, subevent, ...) end end -Bastion.Globals.EventManager = EventManager:New() - Bastion.EventManager = EventManager + +Bastion.Globals.EventManager = Bastion.EventManager:New() diff --git a/src/List/List.lua b/src/List/List.lua index f0455e9..39652a7 100644 --- a/src/List/List.lua +++ b/src/List/List.lua @@ -26,6 +26,10 @@ local List = { self:remove(value) return self end, + __concat = function(a, b) + return a:concat(b) + end, + } List.__index = List @@ -203,7 +207,7 @@ end function List:join(separator) local result = "" for i, v in ipairs(self._list) do - result = result .. v + result = result .. tostring(v) if i < #self._list then result = result .. separator end diff --git a/src/Timer/Timer.lua b/src/Timer/Timer.lua index 616731b..f8a0cc0 100644 --- a/src/Timer/Timer.lua +++ b/src/Timer/Timer.lua @@ -6,11 +6,10 @@ Bastion = ... -- Create a new Timer class ---@class Bastion.Timer ---@field type string ----@field cb false | fun():boolean +---@field cb? fun():boolean local Timer = { startTime = nil, resetAfterCombat = false, - cb = false } Timer.__index = Timer @@ -22,9 +21,7 @@ function Timer:New(type, cb) local self = setmetatable({}, Timer) self.startTime = nil self.type = type - if cb then - self.cb = cb - end + self.cb = cb return self end diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index cdf2016..b1d7dcf 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -5,14 +5,19 @@ Bastion = ... -- Create a new Unit class ---@class Bastion.Unit +---@field cache Bastion.Cache ---@field id boolean | number ---@field ttd_ticker false | cbObject ---@field unit? TinkrObjectReference ---@field aura_table Bastion.AuraTable | nil local Unit = { ---@type Bastion.Cache - cache = nil, aura_table = nil, + last_shadow_techniques = 0, + swings_since_sht = 0, + last_off_attack = 0, + last_main_attack = 0, + last_combat_time = 0, ---@type UnitId | WowGameObject unit = nil, ttd_ticker = false, @@ -75,18 +80,12 @@ end ---@param unit? TinkrObjectReference ---@return Bastion.Unit function Unit:New(unit) - ---@class Bastion.Unit + ---@type Bastion.Unit local self = setmetatable({}, Unit) self.unit = unit - self.last_shadow_techniques = 0 - self.swings_since_sht = 0 - self.last_off_attack = 0 - self.last_main_attack = 0 - self.last_combat_time = 0 self.cache = Bastion.Cache:New() self.aura_table = Bastion.AuraTable:New(self) self.regression_history = {} - self.health = {} return self end @@ -1006,9 +1005,9 @@ function Unit:GetCombatTime() end -- Set last combat time ----@param time number +---@param time? number function Unit:SetLastCombatTime(time) - self.last_combat_time = time + self.last_combat_time = time or GetTime() end -- Get combat odds (if the last combat time is less than 1 minute ago return 1 / time, else return 0) diff --git a/src/UnitManager/UnitManager.lua b/src/UnitManager/UnitManager.lua index a30acff..51e88f6 100644 --- a/src/UnitManager/UnitManager.lua +++ b/src/UnitManager/UnitManager.lua @@ -31,7 +31,7 @@ function UnitManager:__index(k) return UnitManager[k] end - k = k or "none" + local k = k or "none" -- if custom unit exists, return it it's cache expired return a new one if self.customUnits[k] then diff --git a/src/_bastion.lua b/src/_bastion.lua index d1ac5c2..9001101 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -13,12 +13,12 @@ local Bastion = { Tick = GetGameTick() } +Bastion.__index = Bastion + local BastionBase = string.format("%s/%s", "scripts", "bastion") local BastionScriptsBase = string.format("%s/%s", BastionBase, "scripts") local ThirdPartyModulesBase = string.format("%s/%s", "scripts", "BastionScripts") -Bastion.__index = Bastion - ---@class Bastion.LoadedFiles.Table ---@field [number] { originalPath: string, loadedPath: string, reloadable: boolean, order: number, newPath: string } Bastion.LoadedFiles = {} @@ -164,6 +164,7 @@ local bastionFiles = { "~/src/Cache/Cache", "~/src/Cacheable/Cacheable", "~/src/Refreshable/Refreshable", + "~/src/EventManager/EventManager", "~/src/Unit/Unit", "~/src/Aura/Aura", "~/src/APLTrait/APLTrait", @@ -172,7 +173,6 @@ local bastionFiles = { "~/src/Module/Module", "~/src/UnitManager/UnitManager", "~/src/ObjectManager/ObjectManager", - "~/src/EventManager/EventManager", "~/src/Spell/Spell", "~/src/SpellBook/SpellBook", "~/src/Item/Item", @@ -243,15 +243,10 @@ local missed = {} Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() local args = { CombatLogGetCurrentEventInfo() } - ---@type string local subEvent = args[2] - ---@type string local sourceGUID = args[4] - ---@type string local destGUID = args[8] - ---@type number local spellID = args[12] - ---@type string local spellName = args[13] if subEvent == "SPELL_CAST_SUCCESS" then @@ -260,23 +255,20 @@ Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", fun end end - ---@type Bastion.Unit? local u = Bastion.UnitManager[sourceGUID] - ---@type Bastion.Unit local u2 = Bastion.UnitManager[destGUID] - local t = GetTime() - if type(u) ~= "nil" then + if u then u:SetLastCombatTime(t) end - if type(u2) ~= "nil" then + if u2 then u2:SetLastCombatTime(t) if subEvent == "SPELL_MISSED" and sourceGUID == playerGuid and spellID == 408 then local missType = args[15] - if type(u) ~= "nil" and missType == "IMMUNE" then + if missType == "IMMUNE" then local castingSpell = u:GetCastingOrChannelingSpell() if castingSpell and type(castingSpell) == "table" then