local this = class("worldFilterMarkTpl")

function this:init(config)
  self.data = config
  self.idToList = {}
  for _, v in pairs(self.data) do
    local worldId = self:getWorldId(v)
    if self.idToList[worldId] == nil then
      self.idToList[worldId] = {}
    end
    table.insert(self.idToList[worldId], v)
  end
end

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

function this:getTplListByWorldId(id, markType)
  local result = self.idToList[id]
  if table.isEmpty(result) then
    return {}
  end
  if markType then
    local list = {}
    for _, v in ipairs(result) do
      if v.markType == markType and math.isEmpty(self:getShowIf(v)) then
        table.insert(list, v)
      end
    end
    return list
  else
    local filter_result = {}
    for i, v in pairs(result) do
      if math.isEmpty(self:getShowIf(v)) then
        table.insert(filter_result, v)
      end
    end
    return filter_result
  end
end

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

function this:getWorldId(tpl)
  return tpl.worldId
end

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

function this:getMarkType(tpl)
  return tpl.markType
end

function this:getDes(tpl)
  return L_Config:provider(tpl.des)
end

function this:getIcon(tpl)
  local icon = L_Config:getPathByHash(tpl.icon)
  return icon
end

function this:getIconBg(tpl)
  local icon = L_Config:getPathByHash(tpl.iconBg)
  return icon
end

function this:getPosId(tpl)
  return tpl.posId
end

function this:getRewardShow(tpl)
  return tpl.rewardShow
end

function this:getAngle(tpl)
  return tpl.angle
end

function this:getWorldmapId(tpl)
  return tpl.worldmapId
end

function this:getParam(tpl)
  return tpl.param
end

function this:getShowIf(tpl)
  return tpl.showIf
end

function this:getMapMaskIcon(tpl)
  local icon = L_Config:getPathByHash(tpl.mapMaskIcon)
  return icon
end

function this:getUnlockCondition(tpl)
  return tpl.unlockCondition
end

return this
