local this = {}
local _accessoryTpl = L_GameTpl:getAccessoryTpl()

function this:init()
  this.super.init(self)
  self.data = {
    accessoryList = {}
  }
end

function this:getHeroAccessory()
  return self.data.accessoryList
end

function this:getAccessory(guid, isCreate)
  local accessoryList = self:getHeroAccessory()
  local entity = accessoryList[guid]
  if entity == nil and isCreate then
    entity = require(L_R.store .. "accessory.data.accessory").new()
    self.data.accessoryList[guid] = entity
    entity.guid = guid
  end
  return entity
end

function this:getIsEquipped(guid)
  local accessory = self:getAccessory(guid)
  return accessory.wearHero ~= 0
end

function this:getIsMaxLevel(guid)
  local accessory = self:getAccessory(guid)
  if not accessory then
    return
  end
  local maxLevel = _accessoryTpl:getMaxLevel(_accessoryTpl:getTplById(accessory.accessoryId))
  return maxLevel <= accessory.level
end

local _accessoryHeadRankIconEnums = {
  [1] = "UI/Atlas/CellIcon/tex_icon_iconbg_1.png",
  [2] = "UI/Atlas/CellIcon/tex_icon_iconbg_2.png",
  [3] = "UI/Atlas/CellIcon/tex_icon_iconbg_3.png",
  [4] = "UI/Atlas/CellIcon/tex_icon_iconbg_4.png"
}

function this:getAccessoryHeadRankIcon(rarity)
  return _accessoryHeadRankIconEnums[rarity]
end

return this
