local StarRewardCell = class("StarRewardCell", BaseCell)

local BG = {"dungeon_armor_bg_4", "dungeon_armor_bg_5"}
local BTN = {"common_btn_grey_3", "common_btn_green_3"}

function StarRewardCell:refresh(index, config, got, allStarNum)
    local uiMap = self:getUIMap()
    if not self.rewardCell then
        self.rewardCell = CellManager:addCellComp(uiMap["star_reward_cell.bg.reward_cell"], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
    end
    self.rewardCell:refreshByConfig(config.reward)
    self.rewardCell:showMask(got == true, got == true)

    uiMap["star_reward_cell.bg.btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM))
    local getBtn = uiMap["star_reward_cell.bg.btn"]
    local bg = uiMap["star_reward_cell.bg"]
    getBtn:setActive(not got)
    local btnIcon = BTN[1]
    local bgIcon = BG[1]
    getBtn:addClickListener(nil)
    if config.star <= allStarNum then
        btnIcon = BTN[2]
        bgIcon = BG[2]
        if not got then
            getBtn:addClickListener(function()
                ModuleManager.DungeonArmorManager:reqStarReward(index)
            end)
        end
    end
    getBtn:setSprite(GConst.ATLAS_PATH.COMMON, btnIcon)
    bg:setSprite(GConst.ATLAS_PATH.UI_DUGEON_ARMOR, bgIcon)

    uiMap["star_reward_cell.bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_ARMOR_DESC_10, config.star))
end

return StarRewardCell