Merge pull request 'EmmyLua Types' (#2) from sundance/bastion:emmy into main

Reviewed-on: 4n0n/bastion#2
pull/1/head
4n0n 2 years ago
commit fca98cbadf
  1. 4
      src/APL/APL.lua
  2. 1
      src/Aura/Aura.lua
  3. 4
      src/AuraTable/AuraTable.lua
  4. 1
      src/Cache/Cache.lua
  5. 1
      src/Cacheable/Cacheable.lua
  6. 1
      src/Class/Class.lua
  7. 2
      src/ClassMagic/ClassMagic.lua
  8. 2
      src/Command/Command.lua
  9. 2
      src/EventManager/EventManager.lua
  10. 6
      src/Item/Item.lua
  11. 2
      src/ItemBook/ItemBook.lua
  12. 1
      src/List/List.lua
  13. 1
      src/Module/Module.lua
  14. 1
      src/MythicPlusUtils/MythicPlusUtils.lua
  15. 2
      src/NotificationsList/NotificationsList.lua
  16. 1
      src/ObjectManager/ObjectManager.lua
  17. 1
      src/Refreshable/Refreshable.lua
  18. 5
      src/Spell/Spell.lua
  19. 4
      src/SpellBook/SpellBook.lua
  20. 1
      src/Timer/Timer.lua
  21. 6
      src/Unit/Unit.lua
  22. 6
      src/UnitManager/UnitManager.lua
  23. 1
      src/Vector3/Vector3.lua
  24. 25
      src/_bastion.lua

@ -1,4 +1,5 @@
-- Create an APL trait for the APL class -- Create an APL trait for the APL class
---@class APLTrait
local APLTrait = {} local APLTrait = {}
APLTrait.__index = APLTrait APLTrait.__index = APLTrait
@ -29,6 +30,7 @@ function APLTrait:__tostring()
end end
-- Create an APL actor for the APL class -- Create an APL actor for the APL class
---@class APLActor
local APLActor = {} local APLActor = {}
APLActor.__index = APLActor APLActor.__index = APLActor
@ -116,7 +118,7 @@ function APLActor:__tostring()
end end
-- APL (Attack priority list) class -- APL (Attack priority list) class
---@class APL
local APL = {} local APL = {}
APL.__index = APL APL.__index = APL

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Aura class -- Create a new Aura class
---@class Aura
local Aura = {} local Aura = {}
function Aura:__index(k) function Aura:__index(k)

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new AuraTable class -- Create a new AuraTable class
---@class AuraTable
local AuraTable = {} local AuraTable = {}
AuraTable.__index = AuraTable AuraTable.__index = AuraTable
@ -196,6 +197,7 @@ function AuraTable:Clear()
end end
-- Check if the unit has a specific aura -- Check if the unit has a specific aura
---@return Aura
function AuraTable:Find(spell) function AuraTable:Find(spell)
local auras = self:GetUnitAuras() local auras = self:GetUnitAuras()
local aurasub = auras[spell:GetID()] local aurasub = auras[spell:GetID()]
@ -217,6 +219,7 @@ function AuraTable:Find(spell)
return Bastion.Aura:New() return Bastion.Aura:New()
end end
---@return Aura
function AuraTable:FindMy(spell) function AuraTable:FindMy(spell)
local aurasub = self.playerAuras[spell:GetID()] local aurasub = self.playerAuras[spell:GetID()]
@ -238,6 +241,7 @@ function AuraTable:FindMy(spell)
end end
-- Find any -- Find any
---@return Aura
function AuraTable:FindAny(spell) function AuraTable:FindAny(spell)
local a = self:Find(spell) local a = self:Find(spell)
if a:IsValid() then if a:IsValid() then

@ -1,3 +1,4 @@
---@class Cache
local Cache = {} local Cache = {}
Cache.__index = Cache Cache.__index = Cache

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Define a Cacheable class -- Define a Cacheable class
---@class Cacheable
local Cacheable = { local Cacheable = {
cache = nil, cache = nil,
callback = nil, callback = nil,

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Class class -- Create a new Class class
---@class Class
local Class = {} local Class = {}
function Class:__index(k) function Class:__index(k)

@ -1,6 +1,8 @@
---@class ClassMagic
local ClassMagic = {} local ClassMagic = {}
ClassMagic.__index = ClassMagic ClassMagic.__index = ClassMagic
---@return any
function ClassMagic:Resolve(Class, key) function ClassMagic:Resolve(Class, key)
if Class[key] or Class[key] == false then if Class[key] or Class[key] == false then
return Class[key] return Class[key]

@ -1,5 +1,5 @@
-- Create a wow command handler class -- Create a wow command handler class
---@class Command
local Command = {} local Command = {}
Command.__index = Command Command.__index = Command

@ -1,5 +1,5 @@
-- Create an EventManager class -- Create an EventManager class
---@class EventManager
local EventManager = { local EventManager = {
events = {}, events = {},
eventHandlers = {}, eventHandlers = {},

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Item class -- Create a new Item class
---@class Item
local Item = { local Item = {
UsableIfFunc = false, UsableIfFunc = false,
PreUseFunc = false, PreUseFunc = false,
@ -170,18 +171,21 @@ function Item:Usable()
end end
-- Set a script to check if the Item is Usable -- Set a script to check if the Item is Usable
---@param func fun(self:Item):boolean
function Item:UsableIf(func) function Item:UsableIf(func)
self.UsableIfFunc = func self.UsableIfFunc = func
return self return self
end end
-- Set a script to run before the Item has been Use -- Set a script to run before the Item has been Use
---@param func fun(self:Item)
function Item:PreUse(func) function Item:PreUse(func)
self.PreUseFunc = func self.PreUseFunc = func
return self return self
end end
-- Set a script to run after the Item has been Use -- Set a script to run after the Item has been Use
---@param func fun(self:Item)
function Item:OnUse(func) function Item:OnUse(func)
self.OnUseFunc = func self.OnUseFunc = func
return self return self
@ -278,6 +282,8 @@ function Item:GetChargesRemaining()
end end
-- Create a condition for the Item -- Create a condition for the Item
---@param name string
---@param func fun(self:Item)
function Item:Condition(name, func) function Item:Condition(name, func)
self.conditions[name] = { self.conditions[name] = {
func = func func = func

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new ItemBook class -- Create a new ItemBook class
---@class ItemBook
local ItemBook = {} local ItemBook = {}
ItemBook.__index = ItemBook ItemBook.__index = ItemBook
@ -12,6 +13,7 @@ function ItemBook:New()
end end
-- Get a spell from the ItemBook -- Get a spell from the ItemBook
---@return Item
function ItemBook:GetItem(id) function ItemBook:GetItem(id)
if self.items[id] == nil then if self.items[id] == nil then
self.items[id] = Bastion.Item:New(id) self.items[id] = Bastion.Item:New(id)

@ -1,5 +1,6 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class List
local List = {} local List = {}
List.__index = List List.__index = List

@ -1,5 +1,6 @@
-- Create a module class for a bastion module -- Create a module class for a bastion module
---@class Module
local Module = {} local Module = {}
Module.__index = Module Module.__index = Module

@ -1,5 +1,6 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class MythicPlusUtils
local MythicPlusUtils = { local MythicPlusUtils = {
debuffLogging = false, debuffLogging = false,
random = '' random = ''

@ -1,5 +1,6 @@
-- Create a NotificationsList class -- Create a NotificationsList class
---@class NotificationsList
local NotificationsList = { local NotificationsList = {
notifications = {} notifications = {}
} }
@ -29,6 +30,7 @@ function NotificationsList:New()
end end
-- Create a notification class for the notifications list (takes icon and text) -- Create a notification class for the notifications list (takes icon and text)
---@class Notification
local Notification = { local Notification = {
} }
Notification.__index = Notification Notification.__index = Notification

@ -1,5 +1,6 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class ObjectManager
local ObjectManager = {} local ObjectManager = {}
ObjectManager.__index = ObjectManager ObjectManager.__index = ObjectManager

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Define a Refreshable class -- Define a Refreshable class
---@class Refreshable
local Refreshable = { local Refreshable = {
cache = nil, cache = nil,
callback = nil, callback = nil,

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Spell class -- Create a new Spell class
---@class Spell
local Spell = { local Spell = {
CastableIfFunc = false, CastableIfFunc = false,
PreCastFunc = false, PreCastFunc = false,
@ -50,6 +51,7 @@ function Spell:GetID()
end end
-- Add post cast func -- Add post cast func
---@param func fun(self:Spell)
function Spell:PostCast(func) function Spell:PostCast(func)
self.PostCastFunc = func self.PostCastFunc = func
return self return self
@ -173,18 +175,21 @@ function Spell:Castable()
end end
-- Set a script to check if the spell is castable -- Set a script to check if the spell is castable
---@param func fun(spell:Spell):boolean
function Spell:CastableIf(func) function Spell:CastableIf(func)
self.CastableIfFunc = func self.CastableIfFunc = func
return self return self
end end
-- Set a script to run before the spell has been cast -- Set a script to run before the spell has been cast
---@param func fun(spell:Spell)
function Spell:PreCast(func) function Spell:PreCast(func)
self.PreCastFunc = func self.PreCastFunc = func
return self return self
end end
-- Set a script to run after the spell has been cast -- Set a script to run after the spell has been cast
---@param func fun(spell:Spell)
function Spell:OnCast(func) function Spell:OnCast(func)
self.OnCastFunc = func self.OnCastFunc = func
return self return self

@ -1,10 +1,12 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new SpellBook class -- Create a new SpellBook class
---@class SpellBook
local SpellBook = {} local SpellBook = {}
SpellBook.__index = SpellBook SpellBook.__index = SpellBook
-- Constructor -- Constructor
---@return SpellBook
function SpellBook:New() function SpellBook:New()
local self = setmetatable({}, SpellBook) local self = setmetatable({}, SpellBook)
self.spells = {} self.spells = {}
@ -12,6 +14,7 @@ function SpellBook:New()
end end
-- Get a spell from the spellbook -- Get a spell from the spellbook
---@return Spell
function SpellBook:GetSpell(id) function SpellBook:GetSpell(id)
if self.spells[id] == nil then if self.spells[id] == nil then
self.spells[id] = Bastion.Spell:New(id) self.spells[id] = Bastion.Spell:New(id)
@ -20,6 +23,7 @@ function SpellBook:GetSpell(id)
return self.spells[id] return self.spells[id]
end end
---@return Spell
function SpellBook:GetIfRegistered(id) function SpellBook:GetIfRegistered(id)
return self.spells[id] return self.spells[id]
end end

@ -1,6 +1,7 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Timer class -- Create a new Timer class
---@class Timer
local Timer = { local Timer = {
startTime = nil, startTime = nil,
resetAfterCombat = false, resetAfterCombat = false,

@ -1,9 +1,12 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Unit class -- Create a new Unit class
---@class Unit
local Unit = { local Unit = {
cache = nil, cache = nil,
---@type AuraTable
aura_table = nil, aura_table = nil,
---@type Unit
unit = nil, unit = nil,
last_shadow_techniques = 0, last_shadow_techniques = 0,
swings_since_sht = 0, swings_since_sht = 0,
@ -226,6 +229,7 @@ function Unit:GetClass()
end end
-- Get the units auras -- Get the units auras
---@return AuraTable
function Unit:GetAuras() function Unit:GetAuras()
return self.aura_table return self.aura_table
end end
@ -669,7 +673,7 @@ function Unit:IsStealthed()
local Sepsis = Bastion.SpellBook:GetSpell(328305) local Sepsis = Bastion.SpellBook:GetSpell(328305)
return self:GetAuras():FindAny(Stealth) or self:GetAuras():FindAny(ShadowDance) return self:GetAuras():FindAny(Stealth) or self:GetAuras():FindAny(ShadowDance)
end end
-- Get unit swing timers -- Get unit swing timers

@ -48,6 +48,7 @@ local function Validate(token)
end end
-- Create a new UnitManager class -- Create a new UnitManager class
---@class UnitManager
local UnitManager = { local UnitManager = {
units = {}, units = {},
customUnits = {}, customUnits = {},
@ -108,6 +109,7 @@ function UnitManager:Validate(token)
end end
-- Get or create a unit -- Get or create a unit
---@return Unit
function UnitManager:Get(token) function UnitManager:Get(token)
-- if not Validate(token) then -- if not Validate(token) then
-- error("UnitManager:Get - Invalid token: " .. token) -- error("UnitManager:Get - Invalid token: " .. token)
@ -145,6 +147,9 @@ function UnitManager:SetObject(unit)
end end
-- Create a custom unit and cache it for .5 seconds -- Create a custom unit and cache it for .5 seconds
---@param token string
---@param cb fun():Unit
---@return Unit
function UnitManager:CreateCustomUnit(token, cb) function UnitManager:CreateCustomUnit(token, cb)
local unit = cb() local unit = cb()
local cachedUnit = Bastion.Cacheable:New(unit, cb) local cachedUnit = Bastion.Cacheable:New(unit, cb)
@ -175,6 +180,7 @@ function UnitManager:EnumFriends(cb)
end end
-- Enum Enemies (object manager) -- Enum Enemies (object manager)
---@param cb fun(unit: Unit):boolean
function UnitManager:EnumEnemies(cb) function UnitManager:EnumEnemies(cb)
Bastion.ObjectManager.activeEnemies:each(function(unit) Bastion.ObjectManager.activeEnemies:each(function(unit)
if cb(unit) then if cb(unit) then

@ -1,5 +1,6 @@
-- Create a Vector3 class -- Create a Vector3 class
---@class Vector3
local Vector3 = {} local Vector3 = {}
Vector3.__index = Vector3 Vector3.__index = Vector3

@ -1,5 +1,6 @@
local Tinkr = ... local Tinkr = ...
---@class Bastion
local Bastion = { local Bastion = {
DebugMode = false DebugMode = false
} }
@ -9,30 +10,54 @@ function Bastion.require(class)
return Tinkr:require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) return Tinkr:require("scripts/bastion/src/" .. class .. "/" .. class, Bastion)
end end
---@type ClassMagic
Bastion.ClassMagic = Bastion.require("ClassMagic") Bastion.ClassMagic = Bastion.require("ClassMagic")
---@type List
Bastion.List = Bastion.require("List") Bastion.List = Bastion.require("List")
---@type NotificationsList, Notification
Bastion.NotificationsList, Bastion.Notification = Bastion.require("NotificationsList") Bastion.NotificationsList, Bastion.Notification = Bastion.require("NotificationsList")
---@type Vector3
Bastion.Vector3 = Bastion.require("Vector3") Bastion.Vector3 = Bastion.require("Vector3")
---@type Command
Bastion.Command = Bastion.require("Command") Bastion.Command = Bastion.require("Command")
---@type Cache
Bastion.Cache = Bastion.require("Cache") Bastion.Cache = Bastion.require("Cache")
---@type Cacheable
Bastion.Cacheable = Bastion.require("Cacheable") Bastion.Cacheable = Bastion.require("Cacheable")
---@type Refreshable
Bastion.Refreshable = Bastion.require("Refreshable") Bastion.Refreshable = Bastion.require("Refreshable")
---@type Unit
Bastion.Unit = Bastion.require("Unit") Bastion.Unit = Bastion.require("Unit")
---@type Aura
Bastion.Aura = Bastion.require("Aura") Bastion.Aura = Bastion.require("Aura")
---@type APL, APLActor, APLTrait
Bastion.APL, Bastion.APLActor, Bastion.APLTrait = Bastion.require("APL") Bastion.APL, Bastion.APLActor, Bastion.APLTrait = Bastion.require("APL")
Bastion.Module = Bastion.require("Module") Bastion.Module = Bastion.require("Module")
---@type UnitManager
Bastion.UnitManager = Bastion.require("UnitManager"):New() Bastion.UnitManager = Bastion.require("UnitManager"):New()
---@type ObjectManager
Bastion.ObjectManager = Bastion.require("ObjectManager"):New() Bastion.ObjectManager = Bastion.require("ObjectManager"):New()
---@type EventManager
Bastion.EventManager = Bastion.require("EventManager"):New() Bastion.EventManager = Bastion.require("EventManager"):New()
---@type Spell
Bastion.Spell = Bastion.require("Spell") Bastion.Spell = Bastion.require("Spell")
---@type SpellBook
Bastion.SpellBook = Bastion.require("SpellBook"):New() Bastion.SpellBook = Bastion.require("SpellBook"):New()
---@type Item
Bastion.Item = Bastion.require("Item") Bastion.Item = Bastion.require("Item")
---@type ItemBook
Bastion.ItemBook = Bastion.require("ItemBook"):New() Bastion.ItemBook = Bastion.require("ItemBook"):New()
---@type AuraTable
Bastion.AuraTable = Bastion.require("AuraTable") Bastion.AuraTable = Bastion.require("AuraTable")
---@type Class
Bastion.Class = Bastion.require("Class") Bastion.Class = Bastion.require("Class")
---@type Timer
Bastion.Timer = Bastion.require("Timer") Bastion.Timer = Bastion.require("Timer")
---@type Timer
Bastion.CombatTimer = Bastion.Timer:New('combat') Bastion.CombatTimer = Bastion.Timer:New('combat')
---@type MythicPlusUtils
Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New() Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New()
---@type NotificationsList
Bastion.Notifications = Bastion.NotificationsList:New() Bastion.Notifications = Bastion.NotificationsList:New()
Bastion.modules = {} Bastion.modules = {}

Loading…
Cancel
Save