local this = class("weaponTpl")

function this:init(config)
  self.data = config
end

function this:getTplById(id)
  return self.data[id]
end

function this:getDesc(tpl)
  return L_Config:provider(tpl.desc)
end

function this:getAttribute(tpl)
  return tpl.attribute
end

function this:getWeaponExp(tpl)
  return tpl.weaponExp
end

function this:getAvatarCount(tpl)
  return #self:getAvatar(tpl)
end

function this:getId(tpl)
  return tpl.id
end

function this:getAvatar(tpl)
  local tmp = {}
  for _, v in ipairs(tpl.avatar) do
    table.insert(tmp, L_Config:getPathByHash(v))
  end
  return tmp
end

function this:getType(tpl)
  return tpl.type
end

function this:getWeaponSkill(tpl)
  return tpl.weaponSkill
end

function this:getWeaponDefault(tpl)
  return tpl.weaponDefault
end

function this:getAvatarTexture(tpl)
  local tmp = {}
  for _, v in ipairs(tpl.avatarTexture) do
    table.insert(tmp, L_Config:getPathByHash(v))
  end
  return tmp
end

function this:getName(tpl)
  return L_Config:provider(tpl.name)
end

function this:getRarity(tpl)
  return tpl.rarity
end

function this:getProperty(id, level)
  local weaponAttribute = self:getAttribute(self:getTplById(id))
  if weaponAttribute then
    local weaponValueTpl = L_GameTpl:getWeaponValueTpl()
    local property = weaponValueTpl:getBaseAttribute(weaponValueTpl:getTplById(weaponAttribute * 1000 + level))
    local proList = {}
    for k, v in pairs(property) do
      proList[k] = math.floor(v)
    end
    return proList
  end
  return {}
end

function this:getSkillId(id, star)
  local weaponSkill = self:getReishiSkill(self:getTplById(id))
  if weaponSkill ~= 0 then
    return weaponSkill * 10 + star
  end
end

return this
