local this = {}

function this:req_worldExploreReward(mapId, callback)
  local data = {u32 = mapId}
  L_Net:sendMessage(MsgGenCode.CSProtoWorldMapExploreReward, data, function(rspData, errorCode)
    local rewards = rspData.rewards
    if errorCode == L_Const.errorCode.ErrCodeSucc then
      if not table.isEmpty(rewards) then
        self:call(self.event.MapExploreReward)
        L_RewardManager:showPage(rewards)
      end
      if callback then
        callback()
      end
    end
  end)
end

function this:rsp_syncExploration(explore)
  if table.isEmpty(explore) then
    return
  end
  if not table.isEmpty(explore.map_info) then
    for i, v in pairs(explore.map_info) do
      if table.isEmpty(self.data.exploreInfo[v.map_id]) then
        self.data.exploreInfo[v.map_id] = {}
      end
      self.data.exploreInfo[v.map_id] = v
    end
  end
  if not table.isEmpty(explore.mission_info) then
    for i, v in pairs(explore.mission_info) do
      if table.isEmpty(self.data.missionInfo[v.exploration_id]) then
        self.data.missionInfo[v.exploration_id] = {}
      end
      self.data.missionInfo[v.exploration_id] = v
    end
  end
  self:checkExploreLvChange(self.data.exploreInfo)
  self:checkMissionStatusChange(explore.mission_info)
  if self.data.setHasInitSync == false and explore.login then
    self:initExploreServerData()
    self.data.setHasInitSync = true
  end
  self:call(self.event.ExplorationSync)
end

return this
