54 lines
2.2 KiB
Lua
54 lines
2.2 KiB
Lua
local SummonManager = class("SummonManager", BaseModule)
|
|
|
|
-- 商城宝箱
|
|
function SummonManager:summon(summonType, costType)
|
|
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.STORE_BOX_OPEN, true) then
|
|
return
|
|
end
|
|
|
|
if summonType == GConst.SummonConst.SUMMON_TYPE.LV_3 and not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.STORE_BOX_3_OPEN, true) then
|
|
return
|
|
end
|
|
|
|
local costItem, cost = DataManager.SummonData:getSummonCost(summonType)
|
|
if costType == 1 then
|
|
if not GFunc.checkCost(costItem.id, costItem.num, false) then
|
|
return
|
|
end
|
|
else
|
|
if not GFunc.checkCost(cost.id, cost.num, false) then
|
|
return
|
|
end
|
|
end
|
|
|
|
local params = {type = summonType, consume_type = costType}
|
|
local responseData = {}
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.SummonReq, params, responseData, self.summonFinish, BIReport.ITEM_GET_TYPE.SUMMON)
|
|
end
|
|
|
|
function SummonManager:summonFinish(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
DataManager.SummonData:init(result.summon_info)
|
|
if result.reqData then
|
|
local summonType = result.reqData.type
|
|
ModuleManager.ShopManager:showBoxOpenUI({type = GConst.ShopConst.BOX_REWARD_TYPE.SUMMON, params = summonType, rewards = result.rewards})
|
|
-- 任务
|
|
if summonType == GConst.SummonConst.SUMMON_TYPE.LV_1 then
|
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_OPEN_SHOP_BOX_LEVEL_1, 1)
|
|
elseif summonType == GConst.SummonConst.SUMMON_TYPE.LV_2 then
|
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_OPEN_SHOP_BOX_LEVEL_2, 1)
|
|
elseif summonType == GConst.SummonConst.SUMMON_TYPE.LV_3 then
|
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_OPEN_SHOP_BOX_LEVEL_3, 1)
|
|
end
|
|
end
|
|
if result.summon_info.count then
|
|
local totalCount = 0
|
|
for t, count in pairs(result.summon_info.count) do
|
|
totalCount = totalCount + count
|
|
end
|
|
BIReport:postFirstDayOpenBox(totalCount)
|
|
end
|
|
end
|
|
end
|
|
|
|
return SummonManager |