local k=require("\112\108\046\099\108\097\115\115")local V=require("\105\110\118\111\107\097\116\105\111\110\046\108\097\110\103\046\100\101\108\101\103\097\116\105\111\110")local E=require("\109\111\115\101\115")local D=require("\105\110\118\111\107\097\116\105\111\110\046\099\111\110\115\116\046\105\110\118\111\107\101\114")local l=k()local x=E.map(D.ORB_ABILITIES,function(k)return k,true end)local h={"\071\101\116\068\117\114\097\116\105\111\110";"\071\101\116\083\112\101\099\105\097\108\086\097\108\117\101\070\111\114";"\073\115\073\116\101\109"}V.delegate(l,"\101\110\116\105\116\121",h)function l._init(V,k)V.entity=k V.name=V.entity:GetAbilityName()V.index=V.entity:GetAbilityIndex()end function l.IsOrbAbility(k)return E.toBoolean(x[k.name])end function l.IsInvocationAbility(k)return k:IsOrbAbility()or k.name==D.ABILITY_INVOKE end return l
--- Ability class that represents either an ability or item.
-- @classmod invokation.dota2.Ability
local class = require("pl.class")
local delegation = require("invokation.lang.delegation")
local m = require("moses")

local INVOKER = require("invokation.const.invoker")

local M = class()

local ORB_ABILITIES = m.map(INVOKER.ORB_ABILITIES, function(ability)
  return ability, true
end)

local DELEGATES = { "GetDuration", "GetSpecialValueFor", "IsItem" }

delegation.delegate(M, "entity", DELEGATES)

--- Constructor.
-- @tparam CDOTABaseAbility|CDOTA_Item entity Ability or item entity
function M:_init(entity)
  self.entity = entity
  self.name = self.entity:GetAbilityName()
  self.index = self.entity:GetAbilityIndex()
end

--- Checks if this ability is an Invoker orb ability (quas, wex or exort).
-- @treturn bool `true` if it's an orb ability, `false` otherwise
function M:IsOrbAbility()
  return m.toBoolean(ORB_ABILITIES[self.name])
end

--- Checks if this ability is an Invoker "invocation" ability (quas, wex, exort or invoke).
-- @treturn bool `true` if it's an invocation ability, `false` otherwise
function M:IsInvocationAbility()
  return self:IsOrbAbility() or self.name == INVOKER.ABILITY_INVOKE
end

return M
