From 630fcfc3d9ad9c1728789cf08698c6a1547de3ae Mon Sep 17 00:00:00 2001 From: LyLo Date: Tue, 1 Aug 2023 13:20:02 -0400 Subject: [PATCH] More types --- src/Class/Class.lua | 15 +++++++++++++++ src/Command/Command.lua | 7 +++++++ src/List/List.lua | 4 +--- src/MythicPlusUtils/MythicPlusUtils.lua | 5 +---- src/ObjectManager/ObjectManager.lua | 7 ++++++- src/Unit/Unit.lua | 6 +++--- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/Class/Class.lua b/src/Class/Class.lua index b1f3d11..69db919 100644 --- a/src/Class/Class.lua +++ b/src/Class/Class.lua @@ -18,12 +18,21 @@ function Class:__index(k) return response end +---@class Class +---@field class Class.class + +---@class Class.class +---@field locale string +---@field name string +---@field id number + -- Constructor ---@param locale string ---@param name string ---@param id number function Class:New(locale, name, id) local self = setmetatable({}, Class) + self.class = { locale = locale, name = name, @@ -50,10 +59,16 @@ function Class:GetID() return self.class.id end +---@class ColorMixin +---@field r number +---@field g number +---@field b number + -- Return the classes color ---@return ColorMixin classColor function Class:GetColor() return C_ClassColor.GetClassColor(self.class.name) end + return Class diff --git a/src/Command/Command.lua b/src/Command/Command.lua index 0e04436..03af256 100644 --- a/src/Command/Command.lua +++ b/src/Command/Command.lua @@ -1,6 +1,13 @@ -- Create a wow command handler class ---@class Command +---@field command string +---@field commands Command.commands[] local Command = {} + +---@class Command.commands +---@field helpmsg string +---@field cb fun(args: table) + Command.__index = Command ---@return string diff --git a/src/List/List.lua b/src/List/List.lua index 421567f..1921466 100644 --- a/src/List/List.lua +++ b/src/List/List.lua @@ -1,5 +1,3 @@ -local Tinkr, Bastion = ... - ---@class List local List = { -- Add overload @@ -144,7 +142,7 @@ function List:findIndex(callback) return nil end ----@param callback fun(value: any): boolean +---@param callback fun(...): boolean ---@return nil function List:sort(callback) table.sort(self._list, callback) diff --git a/src/MythicPlusUtils/MythicPlusUtils.lua b/src/MythicPlusUtils/MythicPlusUtils.lua index f131c74..f84ee36 100644 --- a/src/MythicPlusUtils/MythicPlusUtils.lua +++ b/src/MythicPlusUtils/MythicPlusUtils.lua @@ -17,6 +17,7 @@ MythicPlusUtils.__index = MythicPlusUtils function MythicPlusUtils:New() local self = setmetatable({}, MythicPlusUtils) + ---@diagnostic disable-next-line: assign-type-mismatch self.random = math.random(1000000, 9999999) self.aoeBosses = { @@ -567,8 +568,4 @@ function MythicPlusUtils:IsAOEBoss(unit) return self.aoeBosses[unit:GetID()] end -function MythicPlusUtils:IsTankBuster(spell) - return self.tankBusters[spell:GetID()] -end - return MythicPlusUtils diff --git a/src/ObjectManager/ObjectManager.lua b/src/ObjectManager/ObjectManager.lua index 1aaca3d..8e21b53 100644 --- a/src/ObjectManager/ObjectManager.lua +++ b/src/ObjectManager/ObjectManager.lua @@ -1,6 +1,11 @@ local Tinkr, Bastion = ... ---@class ObjectManager +---@field _lists table +---@field enemies List +---@field friends List +---@field activeEnemies List +---@field explosives List local ObjectManager = {} ObjectManager.__index = ObjectManager @@ -20,7 +25,7 @@ end -- Register a custom list with a callback ---@param name string ---@param cb function ----@return List +---@return List | false function ObjectManager:RegisterList(name, cb) if self._lists[name] then return false diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 400cb9c..0640dcb 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -505,7 +505,7 @@ end -- Check if unit is interruptible ---@param percent number ----@param ignoreInterruptible boolean +---@param ignoreInterruptible? boolean ---@return boolean function Unit:IsInterruptibleAt(percent, ignoreInterruptible) if not ignoreInterruptible and not self:IsInterruptible() then @@ -933,7 +933,6 @@ function Unit:IsStealthed() local Shadowmeld = Bastion.SpellBook:GetSpell(58984) local Sepsis = Bastion.SpellBook:GetSpell(328305) - return self:GetAuras():FindAny(Stealth) or self:GetAuras():FindAny(ShadowDance) end @@ -1107,6 +1106,7 @@ end ---@param Target Unit ---@param Angle number ---@param Distance number +---@param rotation? number ---@return boolean function Unit:IsWithinCone(Target, Angle, Distance, rotation) if not Target:Exists() then @@ -1114,7 +1114,7 @@ function Unit:IsWithinCone(Target, Angle, Distance, rotation) end local angle = self:GetAngle(Target) - local rotation = rotation or self:GetFacing() + rotation = rotation or self:GetFacing() local diff = math.abs(angle - rotation)