225 lines
8.1 KiB
Lua
225 lines
8.1 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()
|
|
if EDITOR_MODE then
|
|
Logger.logHighlight("检查跨天:".. tostring(DataManager.DungeonData:getIfCanReset()))
|
|
end
|
|
if not DataManager.DungeonData:getIfCanReset() then
|
|
return
|
|
end
|
|
|
|
-- 跨天重置数据
|
|
DataManager.DungeonData:onDayChange()
|
|
end
|
|
|
|
-- 请求挑战金币副本
|
|
function DungeonManager:reqChallengeGold(id)
|
|
local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD
|
|
-- 判断次数
|
|
if DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
|
return
|
|
end
|
|
|
|
-- 判断体力
|
|
if not DataManager.DungeonData:isEnoughHp(moduleKey) then
|
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
|
ModuleManager.CommerceManager:showBuyVitUI()
|
|
return
|
|
end
|
|
|
|
if not DataManager.DungeonData:isCanChallenge(moduleKey) then
|
|
return
|
|
end
|
|
|
|
local parmas = {chapter_gold_id = id}
|
|
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)
|
|
DataManager.DungeonData:setCurFightChapterId(result.reqData.chapter_gold_id)
|
|
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DUNGEON_GOLD)
|
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_CHALLENGE)
|
|
end
|
|
end
|
|
|
|
-- 请求结算金币副本
|
|
function DungeonManager:reqEndChallengeGold(id, combatReport, taskProgress, totalDamage, remainingHp)
|
|
local parmas = {
|
|
win = combatReport.victory,
|
|
total_damage = totalDamage,
|
|
remaining_hp = remainingHp,
|
|
chapter_gold_id = id,
|
|
task_stat = taskProgress,
|
|
combatReport = combatReport,
|
|
}
|
|
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 DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
|
return
|
|
end
|
|
|
|
-- 判断体力
|
|
if not DataManager.DungeonData:isEnoughHp(moduleKey) then
|
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
|
ModuleManager.CommerceManager:showBuyVitUI()
|
|
return
|
|
end
|
|
|
|
if not DataManager.DungeonData: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)
|
|
GFunc.showRewardBox(result.rewards)
|
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_SWEEP)
|
|
end
|
|
end
|
|
|
|
-- 请求挑战碎片副本
|
|
function DungeonManager:reqChallengeShards(id)
|
|
local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_SHARDS
|
|
-- 判断次数
|
|
if DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
|
return
|
|
end
|
|
|
|
-- 判断体力
|
|
if not DataManager.DungeonData:isEnoughHp(moduleKey) then
|
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
|
ModuleManager.CommerceManager:showBuyVitUI()
|
|
return
|
|
end
|
|
|
|
if not DataManager.DungeonData:isCanChallenge(moduleKey) then
|
|
return
|
|
end
|
|
|
|
local parmas = {chapter_shards_id = id}
|
|
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)
|
|
DataManager.DungeonData:setCurFightChapterId(result.reqData.chapter_shards_id)
|
|
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DUNGEON_SHARDS)
|
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_CHALLENGE)
|
|
end
|
|
end
|
|
|
|
-- 请求结算碎片副本
|
|
function DungeonManager:reqEndChallengeShards(id, combatReport, taskProgress, totalDamage)
|
|
local parmas = {
|
|
win = combatReport.victory,
|
|
total_damage = totalDamage,
|
|
chapter_shards_id = id,
|
|
task_stat = taskProgress,
|
|
combatReport = combatReport,
|
|
}
|
|
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 DataManager.DungeonData:getRemainTimes(moduleKey) <= 0 then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
|
return
|
|
end
|
|
|
|
-- 判断体力
|
|
if not DataManager.DungeonData:isEnoughHp(moduleKey) then
|
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
|
ModuleManager.CommerceManager:showBuyVitUI()
|
|
return
|
|
end
|
|
|
|
if not DataManager.DungeonData: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)
|
|
GFunc.showRewardBox(result.rewards)
|
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DUNGEON_SWEEP)
|
|
end
|
|
end
|
|
|
|
return DungeonManager |