diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 238bbac5..14f9240f 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -95,7 +95,16 @@ function MainComp:refreshChapter(force) end end + local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId) + local mysteryBoxIcon = self.uiMap["main_comp.chapter.img.mystery_box_icon"] + mysteryBoxIcon:setVisible(mysteryBoxCount > 0) + if mysteryBoxCount > 0 then + local remainCount = math.max(mysteryBoxCount - DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId), 0) + self.uiMap["main_comp.chapter.img.mystery_box_icon.desc"]:setText(remainCount .. "/" .. mysteryBoxCount) + end + local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() + Logger.logHighlight("rewardChapterId " .. rewardChapterId) if rewardChapterId > chapterId then rewardChapterId = chapterId end diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index f1a81a60..3f1b3d72 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -328,10 +328,6 @@ function ChapterData:fightChapter(chapterId, maxChapterId, maxWave, mysteryBoxId self:setDirty() end -function ChapterData:getChapterMysteryBox(chapterId) - return self.data.chapterInfo[chapterId].mystery_box_idx -end - function ChapterData:getChapterMysteryBoxReward(chapterId) local cfg = self:getChapterCfg()[chapterId] if not cfg then @@ -340,6 +336,18 @@ function ChapterData:getChapterMysteryBoxReward(chapterId) return cfg.mystery_box_reward end +function ChapterData:getChapterMysteryBoxRewardCount(chapterId) + local cfg = self:getChapterCfg()[chapterId] + if not cfg then + return 0 + end + if cfg.mystery_box_reward then + return #cfg.mystery_box_reward + else + return 0 + end +end + function ChapterData:getChapterMysteryBoxIsGot(chapterId, index) if not self.data.chapterInfo[chapterId] then return false @@ -371,4 +379,14 @@ function ChapterData:getExpDrop() return info.idle_exp end +function ChapterData:getChapterMysteryBoxGotCount(chapterId) + if not self.data.chapterInfo[chapterId] then + return 0 + end + if not self.data.chapterInfo[chapterId].mystery_box_idx then + return 0 + end + return #self.data.chapterInfo[chapterId].mystery_box_idx +end + return ChapterData \ No newline at end of file