local BountyManager = class("BountyManager", BaseModule)

function BountyManager:showMainUI()
end

-- 领取战令奖励
function BountyManager:reqGetAllRewards()
	if not DataManager.BountyData:canGetRewards() then
		return
	end
	self:sendMessage(ProtoMsgType.FromMsgEnum.BountyRewardReq, {season = DataManager.BountyData:getSeason()}, self.rspGetAllRewards, BIReport.ITEM_GET_TYPE.BOUNTY_REWARD)
end

function BountyManager:rspGetAllRewards(result)
	if result.err_code ~= GConst.ERROR_STR.SUCCESS then
		local params = {
			content = I18N:getGlobalText(I18N.GlobalConst.SERVER_DEC_16),
			boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
			okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
		}
		GFunc.showMessageBox(params)
        return
    end

	GFunc.showRewardBox(result.rewards)

	DataManager.BountyData:onClaimAllRewards()
	BIReport:postBountyOpt(BIReport.BOUNTY_OPT.REWARD)
end

-- 领取遗留奖励
function BountyManager:reqGetPreviousAllRewards()
	if not DataManager.BountyData:canGetPreviousRewards() then
		return
	end
	self:sendMessage(ProtoMsgType.FromMsgEnum.BountyPreviousRewardReq, {}, self.rspGetPreviousAllRewards, BIReport.ITEM_GET_TYPE.BOUNTY_PREVIOUS_REWARD)
end
function BountyManager:rspGetPreviousAllRewards(result)
	if result.err_code ~= GConst.ERROR_STR.SUCCESS then
        return
    end

	GFunc.showRewardBox(result.rewards)

	DataManager.BountyData:onGotBountyPreviousReward()
	BIReport:postBountyOpt(BIReport.BOUNTY_OPT.REWARD)
end

-- 解锁高级奖励
function BountyManager:onUnlockPro(type)
	local id = DataManager.BountyData:getProRewardGiftId(type)
	PayManager:purchasePackage(id, PayManager.PURCHARSE_TYPE.ACT_GIFT)
end

function BountyManager:rspBountyBoughtNtf(result)
	DataManager.BountyData:onUnlockPro(result.season, result.bought)
end

return BountyManager