This commit is contained in:
chenxi 2023-05-17 22:28:26 +08:00
commit 0289de2d9a
2 changed files with 31 additions and 4 deletions

View File

@ -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

View File

@ -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