139 lines
5.1 KiB
Lua
139 lines
5.1 KiB
Lua
local DungeonRuneManager = class("DungeonRuneManager", BaseModule)
|
|
|
|
function DungeonRuneManager:showMainUI()
|
|
UIManager:showUI("app/ui/dungeon_rune/dungeon_rune_main_ui")
|
|
end
|
|
|
|
function DungeonRuneManager:showFightUI(id)
|
|
local runeData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.RUNES_OPEN)
|
|
if not runeData:canFight(id) then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.PASS_REQUIRE))
|
|
end
|
|
|
|
local params = {id = id}
|
|
local isBoss = runeData:isBossChapter(id)
|
|
if isBoss then
|
|
UIManager:showUI("app/ui/dungeon_rune/dungeon_rune_boss_fight_ui", params)
|
|
else
|
|
UIManager:showUI("app/ui/dungeon_rune/dungeon_rune_fight_ui", params)
|
|
end
|
|
end
|
|
|
|
function DungeonRuneManager:showTaskUI(id)
|
|
local params = {id = id}
|
|
UIManager:showUI("app/ui/dungeon_rune/dungeon_rune_task_ui", params)
|
|
end
|
|
|
|
function DungeonRuneManager:showRebirthUI(adCallback, closeCallback, isHpOver)
|
|
UIManager:showUI("app/ui/dungeon_rune/dungeon_rune_rebirth_ui",{adCallback = adCallback, closeCallback = closeCallback, isHpOver = isHpOver})
|
|
end
|
|
|
|
function DungeonRuneManager:reqFight(id)
|
|
local runeData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.RUNES_OPEN)
|
|
if not runeData:canFight(id) then
|
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.PASS_REQUIRE))
|
|
return
|
|
end
|
|
|
|
local passed = runeData:passedChapter(id)
|
|
if not passed and not GFunc.checkCost(GConst.ItemConst.ITEM_ID_GLOD_WING, 1, true) then
|
|
return
|
|
end
|
|
|
|
local heroes = {}
|
|
local formation = DataManager.FormationData:getDungeonArmorFormation()
|
|
for matchType, heroId in pairs(formation) do
|
|
if heroId > 0 then
|
|
table.insert(heroes, heroId)
|
|
end
|
|
end
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterRuneChallengeStartReq, {id = id, heroes = heroes}, {}, self.rspFight, BIReport.ITEM_GET_TYPE.DUNGEON_RUNE_START)
|
|
end
|
|
|
|
function DungeonRuneManager:rspFight(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
local params = {
|
|
atkFormation = {}
|
|
}
|
|
local formation = DataManager.FormationData:getDungeonRuneFormation()
|
|
for elementType, heroId in pairs(formation) do
|
|
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
|
if heroEntity then
|
|
params.atkFormation[elementType] = heroEntity
|
|
end
|
|
end
|
|
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DUNGEON_RUNE, params, function()
|
|
UIManager:closeAllUI()
|
|
ModuleManager.MaincityManager:showMainCityUI()
|
|
self:showMainUI()
|
|
end)
|
|
end
|
|
end
|
|
|
|
function DungeonRuneManager:reqFightSettlement(chapterId, combatReport, taskProgress)
|
|
local parmas = {
|
|
id = chapterId,
|
|
win = combatReport.victory,
|
|
task_stat = taskProgress,
|
|
combatReport = combatReport,
|
|
}
|
|
self:sendmessage(ProtoMsgType.FromMsgEnum.ChapterRuneChallengeSettlementReq, parmas, {}, self.rspFightSettlement, BIReport.ITEM_GET_TYPE.DUNGEON_RUNE_SETTLEMENT)
|
|
end
|
|
|
|
function DungeonRuneManager:rspFightSettlement(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
local runeData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.RUNES_OPEN)
|
|
local passId = runeData:getPassedMaxId()
|
|
if result.reqData then
|
|
runeData:updatePassedMaxId(result.reqData.id, result)
|
|
end
|
|
-- ModuleManager.BattleManager:showBattleArmorResultUI(GConst.BattleConst.BATTLE_TYPE.DUNGEON_ARMOR, result.rewards, result.reqData.combatReport)
|
|
|
|
if passId ~= runeData:getPassedMaxId() then
|
|
local data = {}
|
|
data.dungeon_progress = DataManager.DungeonData:getDungeonBIStr()
|
|
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
|
|
end
|
|
|
|
if result.reqData then
|
|
local taskStat = result.reqData.task_stat
|
|
if taskStat then
|
|
ModuleManager.TaskManager:addFightTaskProgress(taskStat)
|
|
end
|
|
end
|
|
runeData:setDirty()
|
|
end
|
|
end
|
|
|
|
function DungeonRuneManager:reqSweep(id)
|
|
if not GFunc.checkCost(GConst.ItemConst.ITEM_ID_SLIVER_WING, 1, true) then
|
|
return
|
|
end
|
|
|
|
local runeData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.RUNES_OPEN)
|
|
if not runeData:canSweep(id) then
|
|
return
|
|
end
|
|
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterRuneChallengeFarmReq, {chapter_weapon_id = id}, {}, self.rspSweep, BIReport.ITEM_GET_TYPE.DUNGEON_RUNE_SWEEP)
|
|
end
|
|
|
|
function DungeonRuneManager:rspSweep(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
GFunc.showRewardBox(result.rewards)
|
|
local runeData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.RUNES_OPEN)
|
|
runeData:setDirty()
|
|
end
|
|
end
|
|
|
|
function DungeonRuneManager:reqRebirth()
|
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterRuneAdReq, {}, {}, self.rspRebirth)
|
|
end
|
|
|
|
function DungeonRuneManager:rspRebirth(result)
|
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.BATTLE_REBIRTH)
|
|
end
|
|
end
|
|
|
|
return DungeonRuneManager |