77 lines
2.3 KiB
Lua
77 lines
2.3 KiB
Lua
local BountyManager = class("BountyManager", BaseModule)
|
|
|
|
function BountyManager:showBountyMainUI()
|
|
UIManager:showUI("app/ui/bounty/bounty_main_ui")
|
|
end
|
|
|
|
function BountyManager:showBountyBuyUI()
|
|
UIManager:showUI("app/ui/bounty/bounty_buy_ui")
|
|
end
|
|
|
|
function BountyManager:claimReward(index, isPro)
|
|
local args = {
|
|
level = index,
|
|
is_pro = isPro,
|
|
}
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.BountyRewardReq, args, {}, self.onClaimReward, BIReport.ITEM_GET_TYPE.BOUNTY_REWARD)
|
|
end
|
|
|
|
function BountyManager:onClaimReward(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
if result.rewards then
|
|
GFunc.showRewardBox(result.rewards)
|
|
end
|
|
if result.reqData.is_pro ~= nil then
|
|
if result.reqData.is_pro then
|
|
DataManager.BountyData:onClaimProReward(result.reqData.level)
|
|
else
|
|
DataManager.BountyData:onClaimReward(result.reqData.level)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function BountyManager:buyBountyLevel()
|
|
if not DataManager.BountyData:getIfCanBuyLevel() then
|
|
return
|
|
end
|
|
local cost = DataManager.BountyData:getBuyBountyLevelCost()
|
|
local costId = GFunc.getRewardId(cost)
|
|
local costNum = GFunc.getRewardNum(cost)
|
|
if not GFunc.checkCost(costId, costNum, true) then
|
|
return
|
|
end
|
|
local params ={
|
|
titleTx = "临时文本:确认解锁等级",
|
|
content = "临时文本:理解解锁当前等级\n等级奖励将立即解锁,你收集到的积分数量仍然相同",
|
|
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
|
showToday = GConst.MESSAGE_BOX_SHOW_TODAY.BOUNTY_BUY_LEVEL,
|
|
costId = costId,
|
|
costNum = costNum,
|
|
okFunc = function()
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.BountyLevelUnlockReq, {}, {}, self.onBoughtBountyLevel, BIReport.ITEM_GET_TYPE.BOUNTY_UNLOCK_LEVEL)
|
|
end,
|
|
}
|
|
GFunc.showMessageBox(params)
|
|
end
|
|
|
|
function BountyManager:onBoughtBountyLevel(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
DataManager.BountyData:onBoughtLevel()
|
|
end
|
|
end
|
|
|
|
function BountyManager:buyBounty(advanced)
|
|
if not DataManager.BountyData:getIsOpen() then
|
|
return
|
|
end
|
|
PayManager:purchasePackage(DataManager.BountyData:getGiftId(advanced), PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
|
end
|
|
|
|
function BountyManager:onBoughtBountyFinish(result)
|
|
if result.status == 0 then
|
|
DataManager.BountyData:setBought(result.season, result.level)
|
|
end
|
|
end
|
|
|
|
return BountyManager |