c1_lua/lua/app/module/dungeon/dungeon_manager.lua
2023-06-12 15:39:52 +08:00

206 lines
6.9 KiB
Lua

local DungeonManager = class("DungeonManager", BaseModule)
-- 外部接口--------------------------------------------------------------------------
-- 挑战
function DungeonManager:reqChallenge(module, id)
if module == ModuleManager.MODULE_KEY.DUNGEON_GOLD then
self:reqChallengeGold(id)
elseif module == ModuleManager.MODULE_KEY.DUNGEON_SHARDS then
self:reqChallengeShards(id)
end
end
-- 结算
function DungeonManager:reqEndChallenge(module, id)
if module == ModuleManager.MODULE_KEY.DUNGEON_GOLD then
self:reqEndChallengeGold(id)
elseif module == ModuleManager.MODULE_KEY.DUNGEON_SHARDS then
self:reqEndChallengeShards(id)
end
end
-- 扫荡
function DungeonManager:reqSweep(module, id)
if module == ModuleManager.MODULE_KEY.DUNGEON_GOLD then
self:reqSweepGold(id)
elseif module == ModuleManager.MODULE_KEY.DUNGEON_SHARDS then
self:reqSweepShards(id)
end
end
-- 内部接口--------------------------------------------------------------------------
function DungeonManager:checkDayChange()
end
-- 请求挑战金币副本
function DungeonManager:reqChallengeGold(id)
local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD
-- 判断次数
if not DataManager.DungeonData:getRemainTimes(moduleKey) > 0 then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
return
end
-- 判断体力
if not DataManager.DailyChallengeData:isEnoughHp(moduleKey) then
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
ModuleManager.CommerceManager:showBuyVitUI()
return
end
if not DataManager.DailyChallengeData:isCanChallenge(moduleKey) then
return
end
local parmas = {}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeStartReq, parmas, {}, self.respChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_CHALLENGE)
end
-- 响应挑战金币副本
function DungeonManager:respChallengeGold(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_GOLD)
end
end
-- 请求结算金币副本
function DungeonManager:reqEndChallengeGold()
local parmas = {
win = true,
total_damage = nil,
remaining_hp = nil,
chapter_gold_id = nil,
task_stat = nil,
combatReport = nil,
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeSettlementReq, parmas, {}, self.respEndChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_END)
end
-- 响应结算金币副本
function DungeonManager:respEndChallengeGold(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DungeonData:initDungeonGold(result.gold_challenge)
ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DUNGEON_GOLD, result.rewards, result.reqData.combatReport)
end
end
-- 请求扫荡金币副本
function DungeonManager:reqSweepGold(id)
local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD
-- 判断次数
if not DataManager.DungeonData:getRemainTimes(moduleKey) > 0 then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
return
end
-- 判断体力
if not DataManager.DailyChallengeData:isEnoughHp(moduleKey) then
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
ModuleManager.CommerceManager:showBuyVitUI()
return
end
if not DataManager.DailyChallengeData:isCanChallenge(moduleKey) then
return
end
local parmas = {
chapter_gold_id = id,
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeFarmReq, parmas, {}, self.respSweepGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_SWEEP)
end
-- 响应扫荡金币副本
function DungeonManager:respSweepGold(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_GOLD)
end
end
-- 请求挑战碎片副本
function DungeonManager:reqChallengeShards(id)
local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD
-- 判断次数
if not DataManager.DungeonData:getRemainTimes(moduleKey) > 0 then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
return
end
-- 判断体力
if not DataManager.DailyChallengeData:isEnoughHp(moduleKey) then
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
ModuleManager.CommerceManager:showBuyVitUI()
return
end
if not DataManager.DailyChallengeData:isCanChallenge(moduleKey) then
return
end
local parmas = {}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeStartReq, parmas, {}, self.respChallengeShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_CHALLENGE)
end
-- 响应挑战碎片副本
function DungeonManager:respChallengeShards(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_SHARDS)
end
end
-- 请求结算碎片副本
function DungeonManager:reqEndChallengeShards()
local parmas = {
win = true,
total_damage = nil,
chapter_Shards_id = nil,
task_stat = nil,
combatReport = nil,
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeSettlementReq, parmas, {}, self.respEndChallengeShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_END)
end
-- 响应结算碎片副本
function DungeonManager:respEndChallengeShards(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DungeonData:initDungeonShards(result.shards_challenge)
ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DUNGEON_SHARDS, result.rewards, result.reqData.combatReport)
end
end
-- 请求扫荡碎片副本
function DungeonManager:reqSweepShards(id)
local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_SHARDS
-- 判断次数
if not DataManager.DungeonData:getRemainTimes(moduleKey) > 0 then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
return
end
-- 判断体力
if not DataManager.DailyChallengeData:isEnoughHp(moduleKey) then
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
ModuleManager.CommerceManager:showBuyVitUI()
return
end
if not DataManager.DailyChallengeData:isCanChallenge(moduleKey) then
return
end
local parmas = {
chapter_shards_id = id,
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterShardsChallengeFarmReq, parmas, {}, self.respSweepShards, BIReport.ITEM_GET_TYPE.DUNGEON_SHARDS_SWEEP)
end
-- 响应扫荡碎片副本
function DungeonManager:respSweepShards(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DungeonData:onFightCountReduce(ModuleManager.MODULE_KEY.DUNGEON_SHARDS)
end
end
return DungeonManager