diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index 6a516060..5c3238c3 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -14,10 +14,11 @@ end function ChapterManager:openBoxFinish(result) if result.err_code == GConst.ERROR_STR.SUCCESS then + local reqData = result.reqData GFunc.showRewardBox(result.rewards) - DataManager.ChapterData:openBox(result.reqData.chapter_id, result.reqData.wave) + DataManager.ChapterData:openBox(reqData.chapter_id, reqData.wave) - BIReport:postChapterOpenBox(result.reqData.chapter_id, DataManager.ChapterData:getChapterBoxNum(chapterId, index), result.rewards) + BIReport:postChapterOpenBox(reqData.chapter_id, DataManager.ChapterData:getChapterBoxNum(reqData.chapter_id, reqData.wave), result.rewards) end end @@ -36,10 +37,9 @@ function ChapterManager:startFight() return end local parmas = { - id = DataManager.ChapterData:getChapterId() + chapter_id = DataManager.ChapterData:getChapterId() } - -- self:sendMessage(ProtoMsgType.FromMsgEnum., parmas, {}, self.startFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START) - self:startFightFinish({err_code = "SUCCESS"}) + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterStartReq, parmas, {}, self.startFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START) end function ChapterManager:startFightFinish(result) @@ -63,16 +63,12 @@ function ChapterManager:endFightFinish(result) if result.err_code == GConst.ERROR_STR.SUCCESS then local reqData = result.reqData local maxChapter = DataManager.ChapterData:getNewChapterId() - if reqData.combatReport.victory and DataManager.ChapterData:getChapterId() == DataManager.ChapterData:getMaxChapterId() + 1 then - DataManager.ChapterData:goNextChapter() - end local newRewards = {} if result.rewards then GFunc.mergeRewards2(result.rewards, newRewards) end ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport) - -- DataManager.ChapterData:init(result.chapterData, true) - -- DataManager.ChapterData:setDirty() + DataManager.ChapterData:fightChapter(reqData.chapter_id, result.current_chapter_id, result.max_wave) -- 处理金猪 DataManager.GodPigData:addGoldPigCount() diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index 954000a5..469ea14f 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -295,4 +295,28 @@ function ChapterData:openBox(chapterId, index) self:setDirty() end +function ChapterData:fightChapter(chapterId, maxChapterId, maxWave) + if not self.data.chapterInfo[chapterId] then + self.data.chapterInfo[chapterId] = { + total_count = 0, + index = {} + } + end + self.data.chapterInfo[chapterId].total_count = (self.data.chapterInfo[chapterId].total_count or 0) + 1 + + if maxChapterId <= self.maxChapterId then + return + end + + self.data.chapterId = maxChapterId + self.maxWave = maxWave + if self.maxWave >= self:getChapterCfgMaxWave(maxChapterId) then + self.data.maxChapterId = maxChapterId + else + self.data.maxChapterId = maxChapterId - 1 + end + + self:setDirty() +end + return ChapterData \ No newline at end of file