115 lines
3.9 KiB
Lua
115 lines
3.9 KiB
Lua
local ArenaBountyManager = class("ArenaBountyManager", BaseModule)
|
|
|
|
function ArenaBountyManager:showBountyMainUI()
|
|
UIManager:showUI("app/ui/arena/bounty_main_ui")
|
|
end
|
|
|
|
function ArenaBountyManager:showBountyBuyUI()
|
|
DataManager.ArenaBountyData:markPopBought()
|
|
UIManager:showUI("app/ui/arena/bounty_buy_ui")
|
|
end
|
|
|
|
function ArenaBountyManager:claimReward(index, isPro)
|
|
local args = {
|
|
level = index,
|
|
is_pro = isPro,
|
|
}
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ArenaBountyRewardReq, args, self.onClaimReward, BIReport.ITEM_GET_TYPE.ARENA_BOUNTY_REWARD)
|
|
end
|
|
|
|
function ArenaBountyManager:onClaimReward(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
if result.rewards then
|
|
-- 读表获取该层奖励 如果是箱子走单独奖励展示接口
|
|
local isOneKeyGet = false
|
|
local isSpecialBox = false
|
|
local index = result.reqData.level
|
|
local rewardId
|
|
if index == 0 then -- 一键领取
|
|
isOneKeyGet = true
|
|
else
|
|
local isPro = result.reqData.is_pro
|
|
local info = DataManager.ArenaBountyData:getSeasonInfoByLevel(index)
|
|
local rewardType
|
|
if info then
|
|
local reward = isPro and info.reward_pro or info.reward
|
|
rewardType = reward and reward.type
|
|
rewardId = reward and reward.id
|
|
if rewardType == GConst.REWARD_TYPE.ITEM then
|
|
local itemCfgInfo = ConfigManager:getConfig("item")[rewardId]
|
|
if itemCfgInfo and itemCfgInfo.type == GConst.ItemConst.ITEM_TYPE.BOX then
|
|
isSpecialBox = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if isSpecialBox and not isOneKeyGet then
|
|
ModuleManager.ShopManager:showBoxOpenUI({type = GConst.ShopConst.BOX_REWARD_TYPE.ARENA_BOUNTY, params = rewardId, rewards = result.rewards})
|
|
local openType = BIReport.BOX_OPEN_OPEN_TYPE.ARENA_BOUNTY
|
|
BIReport:postBoxOpen(rewardId, BIReport.BOX_OPEN_BOX_TYPE.ACTIVITY, openType, 0, result.rewards)
|
|
else
|
|
GFunc.showRewardBox(result.rewards)
|
|
end
|
|
end
|
|
if result.reqData.is_pro ~= nil then
|
|
local BountyData = DataManager.ArenaBountyData
|
|
local index = result.reqData.level
|
|
if index ~= 0 then
|
|
if result.reqData.is_pro then
|
|
BountyData:onClaimProReward(result.reqData.level)
|
|
else
|
|
BountyData:onClaimReward(result.reqData.level)
|
|
end
|
|
else
|
|
BountyData:onOneKeyClaimReward()
|
|
end
|
|
BIReport:postArenaBountyReward(BountyData:getBountyReportType(), BountyData:getLevel(), BountyData:getExp(), BountyData:getSeason(), result.reqData.level, result.reqData.is_pro)
|
|
end
|
|
end
|
|
end
|
|
|
|
function ArenaBountyManager:buyBountyLevel()
|
|
if not DataManager.ArenaBountyData:getIfCanBuyLevel() then
|
|
return
|
|
end
|
|
local cost = DataManager.ArenaBountyData:getBuyBountyLevelCost()
|
|
local costId = GFunc.getRewardId(cost)
|
|
local costNum = GFunc.getRewardNum(cost)
|
|
if not GFunc.checkCost(costId, costNum, true) then
|
|
return
|
|
end
|
|
local params ={
|
|
titleTx = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_TITLE),
|
|
content = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_COUNTENT),
|
|
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.ArenaBountyLevelUnlockReq, {}, self.onBoughtBountyLevel, BIReport.ITEM_GET_TYPE.ARENA_BOUNTY_UNLOCK_LEVEL)
|
|
end,
|
|
}
|
|
GFunc.showMessageBox(params)
|
|
end
|
|
|
|
function ArenaBountyManager:onBoughtBountyLevel(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
DataManager.ArenaBountyData:onBoughtLevel()
|
|
end
|
|
end
|
|
|
|
function ArenaBountyManager:buyBounty(advanced)
|
|
if not DataManager.ArenaBountyData:getIsOpen() then
|
|
return
|
|
end
|
|
PayManager:purchasePackage(DataManager.ArenaBountyData:getGiftId(advanced), PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
|
end
|
|
|
|
function ArenaBountyManager:onBoughtBountyFinish(result)
|
|
if result.status == 0 then
|
|
DataManager.ArenaBountyData:setBought(result.season, result.level)
|
|
end
|
|
end
|
|
|
|
return ArenaBountyManager |