local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarActPvpCell = class("SideBarActPvpCell", SideBarBaseCellComp)

function SideBarActPvpCell:getModuleKey()
    return nil
end

function SideBarActPvpCell:getHasPurchase()
    return true
end

function SideBarActPvpCell:getIsOpen()
    return DataManager.ActPvpData:getIsOpen()
end

function SideBarActPvpCell:getSpineName()
    return "ui_main_btn_act_pvp"
end

function SideBarActPvpCell:onClick()
    ModuleManager.ActPvpManager:showMainUI()
end

function SideBarActPvpCell:getIsShowRedPoint()
    return DataManager.ActBossRushData:getRp()
end

function SideBarActPvpCell:onRefresh()
    self.timeBg:setVisible(true)
    self:_refreshTime()
end

function SideBarActPvpCell:updateTime()
    if self:getIsOpen() then
        self:_refreshTime()
    else
        self:closeBtn()
    end
end

function SideBarActPvpCell:_refreshTime()
    local remainTime = DataManager.ActPvpData:getRemainTime()
    if remainTime >= 0 then
        self.timeTx:setText(GFunc.getTimeStr(remainTime))
    else
        self.timeTx:setText("00:00:00")
    end
end

return SideBarActPvpCell