local P=require("\105\110\118\111\107\097\116\105\111\110\046\100\111\116\097\050\046\107\118")local E=require("\112\108\046\099\108\097\115\115")local C=require("\109\111\115\101\115")local u=E()function u._init(F,E,u)local Z=C.extend({},{Name=E},u)C.extend(F,Z)F.__data=Z F.AbilitySpecial=P.AbilitySpecials(u.AbilitySpecial)F.AbilityBehavior=P.Flags(u.AbilityBehavior)F.AbilityUnitTargetFlags=P.Flags(u.AbilityUnitTargetFlags)F.AbilityUnitTargetTeam=P.EnumValues(u.AbilityUnitTargetTeam)F.AbilityUnitTargetType=P.Flags(u.AbilityUnitTargetType)F.AbilityCastPoint=P.Numbers(u.AbilityCastPoint)F.AbilityCastRange=P.Numbers(u.AbilityCastRange)F.AbilityChannelTime=P.Numbers(u.AbilityChannelTime)F.AbilityCooldown=P.Numbers(u.AbilityCooldown)F.AbilityDamage=P.Numbers(u.AbilityDamage)F.AbilityDuration=P.Numbers(u.AbilityDuration)F.AbilityManaCost=P.Numbers(u.AbilityManaCost)F.AbilityCastAnimation=P.EnumValue(u.AbilityCastAnimation)end function u.Serialize(P)return P.__data end function u.Entries(P)return pairs(P:Serialize())end return u
--- AbilityKeyValues class.
-- @classmod invokation.dota2.kv.AbilityKeyValues
local KV = require("invokation.dota2.kv")
local class = require("pl.class")
local m = require("moses")

local M = class()

--- Constructor.
-- @tparam string name Ability name
-- @tparam {[string]=any,...} kv KeyValues data
function M:_init(name, kv)
  local fields = m.extend({}, { Name = name }, kv)

  m.extend(self, fields)

  self.__data = fields
  self.AbilitySpecial = KV.AbilitySpecials(kv.AbilitySpecial)
  self.AbilityBehavior = KV.Flags(kv.AbilityBehavior)
  self.AbilityUnitTargetFlags = KV.Flags(kv.AbilityUnitTargetFlags)
  self.AbilityUnitTargetTeam = KV.EnumValues(kv.AbilityUnitTargetTeam)
  self.AbilityUnitTargetType = KV.Flags(kv.AbilityUnitTargetType)
  self.AbilityCastPoint = KV.Numbers(kv.AbilityCastPoint)
  self.AbilityCastRange = KV.Numbers(kv.AbilityCastRange)
  self.AbilityChannelTime = KV.Numbers(kv.AbilityChannelTime)
  self.AbilityCooldown = KV.Numbers(kv.AbilityCooldown)
  self.AbilityDamage = KV.Numbers(kv.AbilityDamage)
  self.AbilityDuration = KV.Numbers(kv.AbilityDuration)
  self.AbilityManaCost = KV.Numbers(kv.AbilityManaCost)
  self.AbilityCastAnimation = KV.EnumValue(kv.AbilityCastAnimation)
end

--- Serializes the KeyValues data
-- @treturn {[string]=any,...} Serialized data
function M:Serialize()
  return self.__data
end

--- Returns an iterator function that iterates over the KeyValues entries.
-- @treturn iter(string,any)
function M:Entries()
  return pairs(self:Serialize())
end

return M
