local this = {}

function this:getLastVersion()
  return self.data.external.version or 1
end

function this:getLastDifficulty()
  if math.isEmpty(self.data.external.difficulty) then
    return self:getMaxDifficulty()
  else
    return self.data.external.difficulty
  end
end

function this:getMaxDifficulty()
  return self.data.external.max_difficulty or 1
end

function this:getIsDifficultyUnlock(difficulty)
  return difficulty <= self:getMaxDifficulty()
end

function this:getResearchPointNum(version)
  version = version or 1
  local researchNum = self.data.external.rnum or {}
  return researchNum[version] or 0
end

function this:getIsResearchUnlock(researchId)
  local researchData = self.data.external.researchs or {}
  return researchData[researchId] ~= nil
end

function this:getSurveryPoint()
  return self.data.external.survey_num or 0
end

function this:getSurveryRefreshTime()
  return self.data.external.refresh_tm or 0
end

function this:isSurveyRewardGetted(id)
  local surveys = self.data.external.surveys or {}
  return surveys[id] ~= nil
end

function this:getUnlocks()
  return self.data.external.unlocks or {}
end

function this:getIsEchoUnlock(echoId)
  local guid = echoId * 100 + L_Const.RogueInfoSendType.ECHOS
  local data = self:getUnlocks()[guid]
  if data and data.status == 2 then
    return true
  end
end

function this:getIsInfoUnlock(infoId)
  local guid = infoId * 100 + L_Const.RogueInfoSendType.INFOS
  local data = self:getUnlocks()[guid]
  if data and data.status == 2 then
    return true
  end
end

function this:getIsEventUnlock(eventId)
  local guid = eventId * 100 + L_Const.RogueInfoSendType.DIALOGS
  local data = self:getUnlocks()[guid]
  if data and data.status == 2 then
    return true
  end
end

function this:getIsStrategyUnlock(strategyId)
  local guid = strategyId * 100 + L_Const.RogueInfoSendType.STRATEGY
  local data = self:getUnlocks()[guid]
  if data and data.status == 1 then
    return true
  end
end

return this
