Bastion aims to serve as a highly performant, simplisitic, and expandable World of Warcraft data visualization framework.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bastion-Testbed/src/SpellBook/SpellBook.lua

50 lines
1.0 KiB

2 years ago
local Tinkr, Bastion = ...
-- Create a new SpellBook class
---@class SpellBook
2 years ago
local SpellBook = {}
SpellBook.__index = SpellBook
-- Constructor
---@return SpellBook
2 years ago
function SpellBook:New()
local self = setmetatable({}, SpellBook)
self.spells = {}
return self
end
-- Get a spell from the spellbook
---@return Spell
2 years ago
function SpellBook:GetSpell(id)
if self.spells[id] == nil then
self.spells[id] = Bastion.Spell:New(id)
end
return self.spells[id]
end
---@param ... number[]
---@return Spell, ... Spell
function SpellBook:GetSpells(...)
local spells = {}
for _, id in ipairs({ ... }) do
table.insert(spells, self:GetSpell(id))
end
return unpack(spells)
end
---@param name string
---@return Spell
function SpellBook:GetSpellByName(name)
local _, rank, icon, castTime, minRange, maxRange, spellID, originalIcon = GetSpellInfo(name)
return self:GetSpell(spellID)
end
---@return Spell
function SpellBook:GetIfRegistered(id)
return self.spells[id]
end
2 years ago
return SpellBook