local this = {}
local heroTpl = L_GameTpl:getHeroTpl()
local skillLevelTpl = L_GameTpl:getSkillLevelTpl()
local heroBreakTpl = L_GameTpl:getHeroBreakTpl()
local accessoryTpl = L_GameTpl:getAccessoryTpl()
local charDataTpl = L_GameTpl:getCharDataTpl()
local charVoiceTpl = L_GameTpl:getCharVoiceTpl()
local charStoryTpl = L_GameTpl:getCharStoryTpl()
local gachaTpl = L_GameTpl:getGachaTpl()
local playerTitleTpl = L_GameTpl:getPlayerTitleTpl()
local achievementGroupTpl = L_GameTpl:getAchievementGroupTpl()
local achievementTpl = L_GameTpl:getAchievementTpl()
local exploreRewardTpl = L_GameTpl:getExploreRewardTpl()
local charPlotTpl = L_GameTpl:getCharPlotTpl()
local mountTpl = L_GameTpl:getMountTpl()
local gameEventsTpl = L_GameTpl:getGameEventsTpl()
local _gameEventsTpl = L_GameTpl:getGameEventsTpl()
local _dungeonEntrustTpl = L_GameTpl:getDungeonEntrustTpl()
local _dungeonEntrustRewardTpl = L_GameTpl:getDungeonEntrustRewardTpl()

function this:getDotHeroNew()
  local heros = L_HeroStore:getAllHero()
  local kvMap = {}
  for _, hero in pairs(heros) do
    if self:haveNew(self.DotDef.HeroNew, L_HeroStore:getHeroGuid(hero)) then
      kvMap[L_HeroStore:getHeroGuid(hero)] = 1
    end
  end
  return kvMap
end

function this:getDotHeroSkill()
  local heros = L_HeroStore:getAllHero()
  local kvMap = {}
  for _, hero in pairs(heros) do
    local skill_list = L_HeroStore:getHeroSysSkillLevel(hero)
    local skill_config_list = heroTpl:getSkillSystem(heroTpl:getTplById(L_HeroStore:getHeroConfigId(hero)))
    for k, skillId in ipairs(skill_config_list) do
      if skill_list[k] then
        local tpl = skillLevelTpl:getTplByIdAndLevel(skillId, skill_list[k])
        if skillLevelTpl:getCanUp(tpl) then
          local canUpgrade = true
          local material_list = skillLevelTpl:getItem(tpl)
          for i = 1, #material_list do
            local item = L_ItemManager:parseCommonItem(material_list[i][1])
            canUpgrade = canUpgrade and item.num >= material_list[i][2]
          end
          local nextTpl = skillLevelTpl:getTplByIdAndLevel(skillId, skill_list[k] + 1)
          nextTpl = nextTpl or tpl
          canUpgrade = canUpgrade and skillLevelTpl:getHeroLevel(nextTpl) <= L_HeroStore:getHeroLevel(hero) and skillLevelTpl:getHeroRank(nextTpl) <= L_HeroStore:getHeroRank(hero)
          if canUpgrade then
            kvMap[L_HeroStore:getHeroGuid(hero) .. "_" .. skillId] = 1
          end
        end
      end
    end
  end
  return kvMap
end

function this:getDotHeroStar()
  local heros = L_HeroStore:getAllHero()
  local kvMap = {}
  for _, hero in pairs(heros) do
    local heroStar = L_HeroStore:getHeroStar(hero)
    local heroGuid = L_HeroStore:getHeroGuid(hero)
    local heroConfigId = L_HeroStore:getHeroConfigId(hero)
    local canBreak = heroStar < 6
    for k, v in pairs(heroBreakTpl:getBreakItemCost(heroBreakTpl:getTplById(heroConfigId))) do
      for i = 1, #v do
        canBreak = canBreak and 1 <= L_BagStore:getItemNum(v[2])
      end
    end
    if canBreak then
      kvMap[heroGuid] = 1
      kvMap[heroGuid .. "_" .. heroStar + 1] = 1
    end
  end
  return kvMap
end

function this:getHeroAcc()
  local kvMap = {}
  local kvMapSp = {}
  local kvMapAc = {}
  if L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.spiritron) then
    kvMapSp = self:getDotHeroSpirit()
  end
  if L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.accessory) then
    kvMapAc = self:getDotHeroJewel()
  end
  for k, sp in pairs(kvMapSp) do
    kvMap[k] = sp
  end
  for k, ac in pairs(kvMapAc) do
    if kvMap[k] == 0 or not kvMap[k] then
      kvMap[k] = ac
    end
  end
  return kvMap
end

function this:getDotHeroSpirit()
  local kvMap = {}
  local weaponList = L_SpiritronStore:getSpiritronList()
  local haveRest = false
  for k, weapon in pairs(weaponList) do
    if math.isEmpty(weapon.spiritronHero) then
      haveRest = true
      break
    end
  end
  if not haveRest then
    return kvMap
  end
  local heros = L_HeroStore:getAllHero()
  for _, hero in pairs(heros) do
    if L_HeroStore:getHeroSpiritronGuid(hero) == 0 then
      kvMap[L_HeroStore:getHeroGuid(hero)] = 1
    end
  end
  return kvMap
end

function this:getDotHeroJewel()
  local kvMap = {}
  local jewelList = L_AccessoryStore:getHeroAccessory()
  local restMap = {}
  for _, jewel in pairs(jewelList) do
    if math.isEmpty(jewel.wearHero) and not math.isEmpty(jewel.accessoryId) then
      local tpl = accessoryTpl:getTplById(jewel.accessoryId)
      if not tpl then
        errorf("\231\169\191\228\186\134\232\163\133\229\164\135\232\161\168\228\184\141\229\173\152\229\156\168\229\190\151\232\163\133\229\164\135 accessoryId == " .. tostring(jewel.accessoryId))
      else
        restMap[accessoryTpl:getType(tpl)] = true
      end
    end
  end
  local heros = L_HeroStore:getAllHero()
  for _, hero in pairs(heros) do
    for t, _ in pairs(restMap) do
      local accessoryList = L_HeroStore:getHeroAccessoryGuidList(hero)
      if math.isEmpty(accessoryList[t]) then
        kvMap[L_HeroStore:getHeroGuid(hero)] = 1
        kvMap[L_HeroStore:getHeroGuid(hero) .. "_" .. t] = 1
      end
    end
  end
  return kvMap
end

function this:getDotHeroInfo()
  local kvMap = {}
  local heros = L_HeroStore:getAllHero()
  local storyOpen = L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.heroDataStory)
  local voiceOpen = L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.heroDataVoice)
  local dramaOpen = L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.heroDataDrama)
  local favorOpen = L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.heroFavorability)
  for _, hero in pairs(heros) do
    local heroId = L_HeroStore:getHeroConfigId(hero)
    if not math.isEmpty(heroId) then
      local charConf = charDataTpl:getTplById(heroId)
      if not charConf then
        errorf("charData\232\161\168 \230\178\161\230\156\137heroid: " .. heroId)
      else
        if storyOpen then
          local storys = charDataTpl:getCharacterStory(charConf)
          for i, v in pairs(storys) do
            local unLockCondition = charStoryTpl:getUnlockCondition(charStoryTpl:getTplById(v))
            local unlock, _ = L_ConditionManager:isComplete(unLockCondition)
            local new = not L_HeroStore:getIsCharDataRead(heroId, L_Const.heroData.story, v) and unlock
            if new then
              kvMap[heroId] = 1
              kvMap[heroId .. "_story"] = 1
              break
            end
          end
        end
        if voiceOpen then
          local voices = charDataTpl:getCharacterVoice(charConf)
          for i, v in pairs(voices) do
            if charVoiceTpl:getTplById(v) == nil then
              errorf("charDataTpl\231\154\132CharacterVoice\233\133\141\228\186\134\228\184\128\228\184\170id " .. v .. " \229\156\168charVoice\232\161\168\233\135\140\230\137\190\228\184\141\229\136\176", 2)
            else
              local unLockCondition = charVoiceTpl:getUnlockCondition(charVoiceTpl:getTplById(v))
              local unlock, _ = L_ConditionManager:isComplete(unLockCondition)
              local new = not L_HeroStore:getIsCharDataRead(heroId, L_Const.heroData.voice, v) and unlock
              if new then
                kvMap[heroId] = 1
                kvMap[heroId .. "_voice"] = 1
                break
              end
            end
          end
        end
        if dramaOpen then
          local charPlots = charPlotTpl:getChildren(heroId)
          if charPlots then
            for i, charPlot in ipairs(charPlots) do
              local taskId = charPlotTpl:getTaskId(charPlot)
              local taskFinish = true
              if taskId and taskId ~= 0 then
                taskFinish = L_TaskStore:checkTaskIsFinished(taskId)
              end
              if not taskFinish then
                local isComp, result = L_ConditionManager:isComplete(charPlotTpl:getUnlockCondition(charPlot))
                if isComp then
                  local charId = charPlotTpl:getId(charPlot)
                  local new = not L_HeroStore:getIsCharDataRead(heroId, L_Const.heroData.drama, charId)
                  if new then
                    kvMap[heroId] = 1
                    kvMap[heroId .. "_drama"] = 1
                    kvMap[heroId .. "_drama_" .. charId] = 1
                  end
                end
              end
            end
          end
        end
        if favorOpen and hero.store_favor_rewards and 0 < #hero.store_favor_rewards then
          kvMap[heroId] = 1
          kvMap[heroId .. "_favor"] = 1
        end
      end
    end
  end
  return kvMap
end

function this:getDotSpiritNew()
  local weapons = L_SpiritronStore:getSpiritronList()
  local kvMap = {}
  for _, weapon in pairs(weapons) do
    if self:haveNew(self.DotDef.SpiritNew, weapon.guid) and math.isEmpty(weapon.exp) and math.isEmpty(weapon.spiritronHero) then
      kvMap[weapon.guid] = 1
    elseif self:haveNew(self.DotDef.SpiritNew, weapon.guid) then
      self:clearNew(self.DotDef.SpiritNew, weapon.guid)
    end
  end
  return kvMap
end

function this:getDotJewelNew()
  local jewels = L_AccessoryStore:getHeroAccessory()
  local kvMap = {}
  for _, jewel in pairs(jewels) do
    if self:haveNew(L_ReddotManager.DotDef.JewelNew, jewel.guid) then
      kvMap[jewel.guid] = 1
    end
  end
  return kvMap
end

function this:getDotGacha()
  local kvMap = {}
  if not L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.gacha) then
    return kvMap
  end
  return kvMap
end

function this:getDotFriend()
  return table.count(L_FriendStore:getFriendApplicationList())
end

function this:getDotAchieve()
  local kvMap = {}
  for id, conf in pairs(achievementGroupTpl.data) do
    local achievement_server = L_AchievementStore:getAchievementListByGroupId(id)
    if not L_AchievementStore:getIsAchievementRewardCollect(id) then
      local tplList = achievementTpl:getTplListByGroupId(id)
      local finishCount = L_AchievementStore:getFinishCountOfGroup(id)
      if finishCount >= #tplList then
        kvMap[id] = 1
      end
    end
    for _, acData in pairs(achievement_server) do
      if not acData.isReward and L_AchievementStore:getIsAchievementCompleted(acData.achievementId) then
        kvMap[id] = 1
        break
      end
    end
  end
  return kvMap
end

function this:getDotSpecialShop()
  return 0
end

function this:getDotMail()
  local mails = L_MailManager:getMailByCategory(L_Const.mailCategory.all)
  for _, mail in pairs(mails) do
    if L_MailManager:isMailHasRed(mail) then
      return 1
    end
  end
  return 0
end

function this:getDotWorldExplore()
  local kvMap = {}
  return kvMap
end

function this:getDotPetNew()
  local kvMap = {}
  local pets = L_PetStore:getPetList()
  for _, pet in pairs(pets) do
    if self:haveNew(self.DotDef.PetNew, pet.guid) then
      kvMap[pet.guid] = 1
    end
  end
  return kvMap
end

function this:getDotPetGeneMutation()
  local kvMap = {}
  local pets = L_PetStore:getPetList()
  for _, pet in pairs(pets) do
    if self:haveNew(self.DotDef.PetGeneMutation, pet.guid) then
      kvMap[pet.guid] = 1
    end
  end
  return kvMap
end

function this:getDotEntrustTaskDifficulty()
  local kvMap = {}
  local allModeInfo = _dungeonEntrustTpl:getModeInfo()
  for difficultyId, v in pairs(allModeInfo) do
    local starNum = L_EntrustStore:getEntrustStarNumByDifficulty(L_Const.EntrustType.AreaEntrust, difficultyId)
    local modeInfo = _dungeonEntrustRewardTpl:getInfoByDifficulty(L_Const.EntrustType.AreaEntrust, difficultyId)
    if modeInfo then
      local haveNew = false
      for _, v in ipairs(modeInfo) do
        if starNum >= v.starNum and not L_EntrustStore:checkEntrustRewardReceived(v.id) then
          kvMap[difficultyId] = 1
          haveNew = true
          break
        end
      end
      if not haveNew then
        kvMap[difficultyId] = 0
      end
    end
  end
  return kvMap
end

function this:getDotEntrustTrain()
  local dataList = L_Const.trainTaskType
  local _trainTaskTpl = L_GameTpl:getTrainTaskTpl()
  local kvMap = {}
  for _, selectType in pairs(dataList) do
    local data = _trainTaskTpl:getTplListByTrainTaskType(selectType)
    for i, v in pairs(data) do
      local taskId = _trainTaskTpl:getTaskid(v)
      local tpl_task = _trainTaskTpl:getTplById(taskId)
      local lock = not L_ConditionManager:isComplete(_trainTaskTpl:getUnlockCondition(tpl_task))
      if not self:haveNew(L_ReddotManager.DotDef.EntrustTrain, taskId) and not lock then
        kvMap[taskId] = 1
      end
    end
  end
  return kvMap
end

function this:getDairyDotActivity()
  local activityRewardData1 = L_ActivityTaskStore:getActivityRewardListByIndex(1)
  for i, v in pairs(activityRewardData1) do
    if v.canReward == 1 and v.isFinish == false then
      return 1
    end
  end
  local activityTaskList1 = L_ActivityTaskStore:getActivityTaskGroupByIndex(1)
  for i, v in pairs(activityTaskList1) do
    if v.finishState == 1 then
      return 1
    end
  end
  return 0
end

function this:getWeeklyDotActivity()
  local activityRewardData2 = L_ActivityTaskStore:getActivityRewardListByIndex(2)
  for i, v in pairs(activityRewardData2) do
    if v.canReward == 1 and v.isFinish == false then
      return 1
    end
  end
  local activityTaskList2 = L_ActivityTaskStore:getActivityTaskGroupByIndex(2)
  for i, v in pairs(activityTaskList2) do
    if v.finishState == 1 then
      return 1
    end
  end
  return 0
end

function this:getNoviceTaskDot()
  return L_NoviceTaskStore:getCanReceiveRewardNumber()
end

function this:getDotNewTutorialGuide()
  local ids = L_GuideStore:getUnlockGuideDataMapIds()
  local _guideGroupTpl = L_GameTpl:getGuideGroupTpl()
  local kvMap = {}
  for _, id in pairs(ids) do
    local tpl = _guideGroupTpl:getTplById(id)
    local tutorialIds = _guideGroupTpl:getTutorialId(tpl)
    for i, tutorialId in pairs(tutorialIds) do
      if self:haveNew(L_ReddotManager.DotDef.NewTutorialGuide, tutorialId) then
        kvMap[tutorialId] = 1
      end
    end
  end
  return kvMap
end

function this:getDotTitle()
  local kvMap = {}
  for id, conf in pairs(playerTitleTpl.data) do
    if self:haveNew(L_ReddotManager.DotDef.Title, id) then
      kvMap[id] = 1
    end
  end
  self._dirtyList[L_ReddotManager.DotDef.TitleSuf] = true
  self._dirtyList[L_ReddotManager.DotDef.TitlePre] = true
  return kvMap
end

function this:getDotTitlePre()
  for id, conf in pairs(playerTitleTpl.data) do
    if playerTitleTpl:getType(conf) == 1 and self:haveNew(L_ReddotManager.DotDef.Title, id) then
      return 1
    end
  end
  return 0
end

function this:getDotTitleSuf()
  for id, conf in pairs(playerTitleTpl.data) do
    if playerTitleTpl:getType(conf) == 2 and self:haveNew(L_ReddotManager.DotDef.Title, id) then
      return 1
    end
  end
  return 0
end

function this:getHomeScience()
  return L_HomeScienceStore:getIsRed()
end

function this:getTechnologyTypeRedList()
  return L_TechnologyStore:getTechnologyTypeRedList()
end

function this:getDotPamiTalkGroup()
  local category = L_PamiTalkManager:getCategoryLetterServerData(1)
  if table.isEmpty(category) then
    return {}
  end
  local kvMap = {}
  for k, group in pairs(category.groups) do
    if group.redNum > 0 then
      kvMap[k] = 1
    end
  end
  return kvMap
end

function this:getDotPamiTalkLetter()
  local letters = L_PamiTalkManager:getLetterMap()
  if table.isEmpty(letters) then
    return {}
  end
  local kvMap = {}
  for k, letter in pairs(letters) do
    if letter.hasRed then
      kvMap[k] = 1
    end
  end
  return kvMap
end

function this:getDotPamiTalkCategory()
  local parseLetters = L_PamiTalkManager:getParsedLetters()
  if table.isEmpty(parseLetters) then
    return {}
  end
  local kvMap = {}
  for k, category in pairs(parseLetters) do
    if category.redNum > 0 then
      kvMap[k] = 1
    end
  end
  return kvMap
end

function this:getDotAnnouncementActive()
  local datas = L_AnnouncementStore:getAnnouncementDatas()
  local kvMap = {}
  if table.isEmpty(datas) then
    return kvMap
  end
  for k, data in pairs(datas) do
    if data:IsValid() and not L_AnnouncementStore:getAnnouncementIsRead(data:getId()) then
      kvMap[data:getId()] = 1
      kvMap["Anncouncement_" .. data:getAnnouncementTab()] = 1
    end
  end
  return kvMap
end

function this:getDotHomeLevelNew()
  local kvMap = {}
  local curLv = L_PlayerStore:getLv()
  for i = 1, curLv do
    if self:haveNew(self.DotDef.LevelUnlockHomeContent, i) then
      kvMap[i] = 1
    end
  end
  return kvMap
end

function this:getPetRankUp()
  local kvMap = {}
  local pets = L_PetStore:getPetList()
  local petRankTpl = L_GameTpl:getPetRankTpl()
  for _, pet in pairs(pets) do
    local rankData = petRankTpl:getchildren(pet.id)
    if not table.isEmpty(rankData) then
      local lackUpCondition = pet.lv < rankData.levelNeed
      local nextStageId = rankData.nextPetId
      if math.isEmpty(nextStageId) then
        lackUpCondition = true
      end
      if not lackUpCondition then
        local item = rankData.rankBreakthroughItem
        for i = 1, #item do
          if not math.isEmpty(item[i][1]) and item[i][2] > L_BagStore:getItemNum(item[i][1]) then
            lackUpCondition = true
          end
        end
      end
      if not lackUpCondition then
        kvMap[pet.guid] = 1
      end
    end
  end
  return kvMap
end

function this:getDotNewEmoji()
  local kvMap = {}
  if not L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.chat) then
    return kvMap
  end
  local emojiOwnedList = L_ChatStore:getEmojiOwnedDic()
  for type, _ in pairs(emojiOwnedList) do
    if not self:haveNew(self.DotDef.NewEmoji, type) then
      kvMap[type] = 1
    end
  end
  return kvMap
end

function this:getDotHeroTalent()
  local kvMap = {}
  local heros = L_HeroStore:getAllHero()
  local talentRankTpl = L_GameTpl:getTalentRankTpl()
  local talentRuneTpl = L_GameTpl:getTalentRuneTpl()
  local configId, guid, rank, rankTpl, runeTpl, runes, allRunes, itemId
  local maxRank = 0
  for _, hero in pairs(heros) do
    guid = L_HeroStore:getHeroGuid(hero)
    configId = L_HeroStore:getHeroConfigId(hero)
    rank = L_HeroStore:getHeroRank(hero)
    runes = L_HeroStore:getHeroRuneIds(hero)
    rankTpl = talentRankTpl:getHeroRankTpl(configId, rank)
    kvMap[guid] = 0
    maxRank = talentRankTpl:getHeroMaxRankNum(configId)
    if rankTpl ~= nil then
      allRunes = talentRankTpl:getRankBreakthroughItem(rankTpl)
      if 0 < table.count(allRunes) then
        for k, id in ipairs(allRunes) do
          if kvMap[guid] ~= 1 and (table.containsValue(runes, 0) or #runes == 0) and math.isEmpty(runes[k]) then
            runeTpl = talentRuneTpl:getTplById(id)
            itemId = talentRuneTpl:getRuneItem(runeTpl)
            if 0 < L_BagStore:getItemNum(itemId) and talentRuneTpl:getEquipRuneThroughCoin(runeTpl) <= L_PlayerStore:getCurrencyNum(L_Const.currencyType.gold) then
              kvMap[guid] = 1
            end
          end
          if 0 < #runes and not table.containsValue(runes, 0) and rank < maxRank then
            local rankPlus = talentRankTpl:getHeroRankTpl(L_HeroStore:getHeroConfigId(hero), rank + 1)
            local rankLevellimit = talentRankTpl:getRankLevelLimit(rankPlus)
            local level = L_HeroStore:getHeroLevel(hero)
            if rankLevellimit <= level and talentRankTpl:getRankBreakthroughCoin(rankTpl) <= L_PlayerStore:getCurrencyNum(L_Const.currencyType.gold) then
              kvMap[guid] = 1
            end
          end
        end
      end
    end
  end
  return kvMap
end

function this:getDotMountNew()
  local kvMap = {}
  if not L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.mount) then
    return kvMap
  end
  local allMount = mountTpl.data
  for _, tpl in pairs(allMount) do
    local mountId = mountTpl:getId(tpl)
    if self:haveNew(self.DotDef.MountNew, mountId) then
      kvMap[mountId] = 1
    end
  end
  return kvMap
end

function this:getDotGameActNew()
  local kvMap = {}
  if not L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.gameAct) then
    return kvMap
  end
  local allGameAct = gameEventsTpl:getAllData()
  for _, tpl in pairs(allGameAct) do
    if not math.isEmpty(gameEventsTpl:getShow(tpl)) then
      local actId = gameEventsTpl:getId(tpl)
      if self:haveNew(self.DotDef.GameAct_New, actId) then
        kvMap[actId] = 1
      end
    end
  end
  return kvMap
end

function this:getDotGameActEventsInCenter()
  local kvMap = {}
  if not L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.gameAct) then
    return kvMap
  end
  local gameEventDatas = L_GameEventStore:getAllGameEventDatas()
  for _, gameEventData in pairs(gameEventDatas) do
    local canParticipateIn = gameEventData:canParticipateIn()
    if canParticipateIn then
      local activityId = gameEventData:getActivityId()
      local gameEventsTpl = _gameEventsTpl:getTplById(activityId)
      local isShowInList = _gameEventsTpl:getShow(gameEventsTpl) == 1
      local isSevenDaySignEvent = _gameEventsTpl:getType(gameEventsTpl) == L_Const.ActivityType.AT_DAILY_SIGN
      if isShowInList or isSevenDaySignEvent then
        local gameEvent = gameEventData:getGameEvent()
        if gameEvent:checkRedDot() then
          kvMap[activityId] = 1
        end
      end
    end
  end
  printf("\230\180\187\229\138\168\228\184\173\229\191\131\239\188\140\230\180\187\229\138\168\229\134\133\233\131\168\231\186\162\231\130\185", kvMap)
  return kvMap
end

function this:getDotSpiritStory()
  local kvMap = {}
  if not L_SystemUnlockStore:getSystemIsOpen(L_SystemConst.enum.spiritron) then
    return kvMap
  end
  return kvMap
end

function this:getDotHomeCenterBuildingManageReceiveAllProduction()
  local homeHubWorkingBuildingInfoList = L_HomeStore:getHomeHubWorkingBuildingInfoListByTabType(L_Const.HomeHubTabType.HHTT_PRODUCT)
  for _, homeHubWorkingBuildingInfo in pairs(homeHubWorkingBuildingInfoList) do
    local buildingGuid = homeHubWorkingBuildingInfo.guid
    local csHomeBuildData = L_HomeStore:getCsHomeBuildDataByGuid(buildingGuid)
    local buildingType = L_HomeStore:getHomeBuildingType(csHomeBuildData)
    if buildingType ~= L_Const.WorldMapBuildType.WMBT_HATCH and csHomeBuildData:CanReward() then
      return 1
    end
  end
  return 0
end

function this:getDotHomeCenterBuildingManageReceiveAllCrop()
  local homeHubWorkingBuildingInfoList = L_HomeStore:getHomeHubWorkingBuildingInfoListByTabType(L_Const.HomeHubTabType.HHTT_AUTO_WORK)
  for _, homeHubWorkingBuildingInfo in pairs(homeHubWorkingBuildingInfoList) do
    local buildingGuid = homeHubWorkingBuildingInfo.guid
    local csHomeBuildData = L_HomeStore:getCsHomeBuildDataByGuid(buildingGuid)
    local csRewardList = csHomeBuildData.auto.rewards
    if csRewardList.Count > 0 then
      return 1
    end
  end
  return 0
end

function this:getDotHomeCenterBuildingManageReceiveAllCollection()
  local canCollectAll, _ = L_CollectionManager:judgeCanCollectReward()
  return canCollectAll and 1 or 0
end

function this:getDotEntrustBattleTask()
  local _kiboDuleGroupTpl = L_GameTpl:getKiBoDuelGroupTpl()
  local dataList = _kiboDuleGroupTpl:getValue()
  local kvMap = {}
  for _, data in pairs(dataList) do
    local tpl = _kiboDuleGroupTpl:getTplById(data.id)
    local condition = _kiboDuleGroupTpl:getUnlockCondition(tpl)
    local tmp_lock, results, lockIndex = L_ConditionManager:isComplete(condition)
    local pre_level_id = _kiboDuleGroupTpl:getPreCondition(data.id)
    local is_unlock_pre_level = L_EntrustStore:checkEntrustKiboBattleSuc(pre_level_id)
    if not self:haveNew(L_ReddotManager.DotDef.EntrustBattleTask, data.id) then
      kvMap[data.id] = 1
    end
  end
  return kvMap
end

return this
