local ChapterManager = class("ChapterManager", BaseModule) function ChapterManager:openBox(chapterId, index) if DataManager.ChapterData:getChapterBoxRewardGot(chapterId, index) then return end local parmas = { id = chapterId, index = index, } ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.OPEN_CHAPTER_BOX, parmas, function(result) if result.status == 0 then GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.CHAPTER_BOX) GFunc.showRewardBox(result.rewards) DataManager.ChapterData:init(result.chapterData, true) DataManager.ChapterData:setDirty() end end) end function ChapterManager:startFight() ---- 通信 ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE) end function ChapterManager:endFight(id, combatReport) local cfg = ConfigManager:getConfig("chapter")[id] local rewards = {} for i = 1, combatReport.wave do for _, reward in ipairs(cfg.wave_reward) do table.insert(rewards, reward) end end if combatReport.victory then for _, reward in ipairs(cfg.finish_reward) do table.insert(rewards, reward) end end local parmas = { id = id, combatReport = combatReport, rewards = GFunc.mergeRewards(rewards) } ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.END_FIGHT, parmas, function(result) if result.status == 0 then GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.FIGHT_END) ModuleManager.BattleManager:showBattleResultUI(result.rewards, combatReport) DataManager.ChapterData:init(result.chapterData, true) DataManager.ChapterData:setDirty() end end) end return ChapterManager