local this = {}
local _exploreLevelTpl = L_GameTpl:getExploreLevelTpl()

function this:init()
  this.super.init(self)
  self.data = {
    exploreInfo = {},
    missionInfo = {},
    setHasInitSync = false,
    curSceneLevel = {},
    missionCompleteMap = {}
  }
end

function this:state()
  return {}
end

function this:getCurExplore(sceneId)
  local info = self:getExploreInfo(sceneId)
  if not math.isEmpty(info.time) then
    return 1
  end
  return 0
end

function this:getExploreInfo(sceneId)
  for i, v in pairs(self.data.exploreInfo) do
    if v.map_id == sceneId then
      return v
    end
  end
  return {
    map_id = sceneId,
    lv = 1,
    exp = 0,
    time = 0,
    rewards = {}
  }
end

function this:getMissionInfoById(missionId)
  for i, v in pairs(self.data.missionInfo) do
    if v.exploration_id == missionId then
      return v
    end
  end
  return nil
end

function this:getExploreAllInfo()
  return self.data.exploreInfo
end

function this:getExploreAllMission()
  return self.data.missionInfo
end

function this:getExploreGotId(id, sceneId)
  local info = self:getExploreInfo(sceneId)
  if table.isEmpty(info) then
    return false
  end
  for i, v in ipairs(info.rewards or {}) do
    if v == id then
      return true
    end
  end
  return false
end

function this:getExploreHaveRewards(ids, sceneId)
  local info = self:getExploreInfo(sceneId)
  if table.isEmpty(info) then
    return false
  end
  if table.isEmpty(ids) then
    return false
  end
  local rewardMap = {}
  for i, v in pairs(info.rewards or {}) do
    rewardMap[v] = v
  end
  for i, v in pairs(ids) do
    if not rewardMap[v] then
      local reward = _exploreLevelTpl:getReward(_exploreLevelTpl:getTplById(v))
      if not table.isEmpty(reward) then
        return true
      end
    end
  end
  return false
end

function this:getExploreCanRewardIds(ids, sceneId)
  local info = self:getExploreInfo(sceneId)
  if table.isEmpty(info) then
    return {}
  end
  local outPutIds = {}
  for i, v in pairs(ids) do
    local id = table.pairsFind(info.rewards, function(value)
      return value == v
    end)
    if not id then
      local reward = _exploreLevelTpl:getReward(_exploreLevelTpl:getTplById(v))
      if not table.isEmpty(reward) then
        table.insert(outPutIds, v)
      end
    end
  end
  return outPutIds
end

return this
