Compare commits

..

1 Commits

Author SHA1 Message Date
João Fidalgo ae7d2091d5 feat: add spell traits 4 months ago
  1. 49
      src/Spell/Spell.lua
  2. 5
      src/SpellBook/SpellBook.lua

@ -49,20 +49,12 @@ end
-- Constructor -- Constructor
---@param id number ---@param id number
---@param traits? table
---@return Spell ---@return Spell
function Spell:New(id, traits) function Spell:New(id)
local self = setmetatable({}, Spell) local self = setmetatable({}, Spell)
self.spellID = id self.spellID = id
if traits == nil then traits = {} end
for k in pairs(traits) do
if self.traits[k] ~= nil and traits[k] ~= nil then
self.traits[k] = traits[k]
end
end
return self return self
end end
@ -342,44 +334,7 @@ function Spell:Castable()
return self:GetCastableFunction()(self) return self:GetCastableFunction()(self)
end end
if not self:IsKnownAndUsable() then return false end return self:IsKnownAndUsable()
local player = Bastion.UnitManager:Get("player")
if self.traits.targeted then
local target = self:GetTarget()
if not target or
not target:Exists() then return false end
if not self:IsInRange(target) then return false end
if not self.traits.ignoreFacing then
if not player:IsFacing(target) then return false end
end
if not self.traits.ignoreLoS then
if not player:CanSee(target) then return false end
end
end
if not self.traits.ignoreCasting then
if player:IsCasting() then return false end
end
if not self.traits.ignoreChanneling then
if player:IsChanneling() then return false end
end
if not self.traits.ignoreGCD then
if player:GetGCD() > C_Spell.GetSpellQueueWindow() then return false end
end
if not self.traits.ignoreMoving then
if self:GetCastLength() > 0 and player:IsMoving() then return false end
end
return true
end end
-- Set a script to check if the spell is castable -- Set a script to check if the spell is castable

@ -15,11 +15,10 @@ end
-- Get a spell from the spellbook -- Get a spell from the spellbook
---@param id number ---@param id number
---@param traits? table
---@return Spell ---@return Spell
function SpellBook:GetSpell(id, traits) function SpellBook:GetSpell(id)
if self.spells[id] == nil then if self.spells[id] == nil then
self.spells[id] = Bastion.Spell:New(id, traits) self.spells[id] = Bastion.Spell:New(id)
end end
return self.spells[id] return self.spells[id]

Loading…
Cancel
Save