local AIHelperData = class("AIHelperData", BaseData)

local INIT_DELAY_TIME = 10
local REQ_INTERVAL = 1800

function AIHelperData:ctor()
    self.data.isDirty = false
    self.aiHelperRpCount = 0
end

function AIHelperData:init(data, isInit)
    self.nextReqTime = Time:getServerTime() + REQ_INTERVAL
    if isInit then -- 初始化没有数据，自己构建一份，并且延迟发送请求
        data = {
            count = 0
        }
        self.nextReqTime = Time:getServerTime() + INIT_DELAY_TIME
    end
    if not data then
        return
    end
    self.aiHelperRpCount = data.count
    self:setIsDirty()
end

function AIHelperData:setIsDirty()
    self.data.isDirty = not self.data.isDirty
end

function AIHelperData:getNextReqTime()
    return self.nextReqTime
end

function AIHelperData:getNeedReqTime()
    if self:getNextReqTime() <= Time:getServerTime() then
        self.nextReqTime = Time:getServerTime() + REQ_INTERVAL
        return true
    end

    return false
end

function AIHelperData:getRp()
    return self.aiHelperRpCount > 0
end

function AIHelperData:clearRp()
    self.aiHelperRpCount = 0
    self:setIsDirty()
end

return AIHelperData