local GatherResourceTemplateManager = BaseClass("GatherResourceTemplateManager")
local __init = function(self)
  self.templateDic = {}
  self.maxLevel = 0
  self.maxLevelByType = {}
end
local __delete = function(self)
  self.templateDic = nil
end
local GetTemplate = function(self, id)
  if self.templateDic[tonumber(id)] == nil then
    local oneTemplate = LocalController:instance():getLine(TableName.GatherResource, tostring(id))
    if oneTemplate ~= nil then
      local item = GatherResourceTemplate.New()
      item:InitData(oneTemplate)
      if item.id ~= nil then
        self.templateDic[tonumber(item.id)] = item
      end
    end
  end
  return self.templateDic[tonumber(id)]
end
local InitAllTemplate = function(self)
  LocalController:instance():visitTable(TableName.GatherResource, function(id, lineData)
    local item = GatherResourceTemplate.New()
    item:InitData(lineData)
    if item.id ~= nil then
      self.templateDic[tonumber(item.id)] = item
    end
  end)
end
local GetMaxLevel = function(self)
  if self.maxLevel > 0 then
    return self.maxLevel
  end
  local result = 0
  for k, v in pairs(self.templateDic) do
    if result < v.level then
      result = v.level
    end
  end
  self.maxLevel = result
  return result
end
local GetMaxLevelbyType = function(self, type)
  local infoList = DataCenter.SeasonDataManager.SpecialServerSeasonInfoList
  if infoList then
    local serverId = LuaEntry.Player:GetCurServerId()
    local data = infoList[toInt(serverId)]
    if data and data.seasonConfigId then
      local seasonConfig = LocalController:instance():getLine(TableName.LW_Season, data.seasonConfigId)
      if seasonConfig.world_resource_search and #seasonConfig.world_resource_search == 2 then
        if SeasonUtil.CurServerIsInSeason() then
          return toInt(seasonConfig.world_resource_search[1])
        else
          return toInt(seasonConfig.world_resource_search[2])
        end
      end
    end
  end
  return 10
end
local GetTemplatebyLevelType = function(self, level, type, specialType)
  for k, v in pairs(self.templateDic) do
    if v.resource_type == type and v.type == specialType and v.level == level then
      return v
    end
  end
end
GatherResourceTemplateManager.__init = __init
GatherResourceTemplateManager.__delete = __delete
GatherResourceTemplateManager.GetTemplate = GetTemplate
GatherResourceTemplateManager.InitAllTemplate = InitAllTemplate
GatherResourceTemplateManager.GetMaxLevel = GetMaxLevel
GatherResourceTemplateManager.GetMaxLevelbyType = GetMaxLevelbyType
GatherResourceTemplateManager.GetTemplatebyLevelType = GetTemplatebyLevelType
return GatherResourceTemplateManager
