fix bug
This commit is contained in:
parent
bf3b283034
commit
77d01818ed
@ -1,14 +1,12 @@
|
|||||||
local ChapterManager = class("ChapterManager", BaseModule)
|
local ChapterManager = class("ChapterManager", BaseModule)
|
||||||
|
|
||||||
function ChapterManager:openBox(chapterId, index)
|
function ChapterManager:openBox(chapterId, index)
|
||||||
if DataManager.ChapterData:getChapterBoxRewardGot(chapterId, index) then
|
if not DataManager.ChapterData:getChapterBoxCanGet() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local parmas = {
|
local parmas = {}
|
||||||
chapter_id = chapterId,
|
parmas.boxes = DataManager.ChapterData:getChapterBoxCanGetInfo()
|
||||||
wave = index,
|
|
||||||
}
|
|
||||||
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterBoxRewardReq, parmas, {}, self.openBoxFinish, BIReport.ITEM_GET_TYPE.CHAPTER_BOX)
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterBoxRewardReq, parmas, {}, self.openBoxFinish, BIReport.ITEM_GET_TYPE.CHAPTER_BOX)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -16,9 +14,9 @@ function ChapterManager:openBoxFinish(result)
|
|||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
local reqData = result.reqData
|
local reqData = result.reqData
|
||||||
GFunc.showRewardBox(result.rewards)
|
GFunc.showRewardBox(result.rewards)
|
||||||
DataManager.ChapterData:openBox(reqData.chapter_id, reqData.wave)
|
DataManager.ChapterData:openBox()
|
||||||
|
|
||||||
BIReport:postChapterOpenBox(reqData.chapter_id, DataManager.ChapterData:getChapterBoxNum(reqData.chapter_id, reqData.wave), result.rewards)
|
-- BIReport:postChapterOpenBox(reqData.chapter_id, DataManager.ChapterData:getChapterBoxNum(reqData.chapter_id, reqData.wave), result.rewards)
|
||||||
|
|
||||||
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_OPEN_CHAPTER_BOX)
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_OPEN_CHAPTER_BOX)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -15,7 +15,7 @@ function ChapterBoxCell:init()
|
|||||||
self.claimImgTx:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_DONE))
|
self.claimImgTx:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_DONE))
|
||||||
|
|
||||||
self.claimBtn:addClickListener(function()
|
self.claimBtn:addClickListener(function()
|
||||||
ModuleManager.ChapterManager:openBox(self.chapterId, self.idx)
|
ModuleManager.ChapterManager:openBox()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -117,8 +117,13 @@ function MainComp:init()
|
|||||||
-- MaincityManager:showChapterBoxUI(chapterId)
|
-- MaincityManager:showChapterBoxUI(chapterId)
|
||||||
|
|
||||||
uiMap["main_comp.middle_bg.box_btn"]:addClickListener(function()
|
uiMap["main_comp.middle_bg.box_btn"]:addClickListener(function()
|
||||||
|
local canGet = DataManager.ChapterData:getChapterBoxCanGet()
|
||||||
|
if canGet then
|
||||||
|
ModuleManager.ChapterManager:openBox()
|
||||||
|
else
|
||||||
local chapterId = DataManager.ChapterData:getChapterId()
|
local chapterId = DataManager.ChapterData:getChapterId()
|
||||||
ModuleManager.MaincityManager:showChapterBoxUI(chapterId)
|
ModuleManager.MaincityManager:showChapterBoxUI(chapterId)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
uiMap["main_comp.middle_bg.info_btn"]:addClickListener(function()
|
uiMap["main_comp.middle_bg.info_btn"]:addClickListener(function()
|
||||||
local chapterId = DataManager.ChapterData:getChapterId()
|
local chapterId = DataManager.ChapterData:getChapterId()
|
||||||
@ -306,7 +311,7 @@ function MainComp:refreshRedPoint()
|
|||||||
self.dailyChallengeBtn:removeRedPoint()
|
self.dailyChallengeBtn:removeRedPoint()
|
||||||
end
|
end
|
||||||
|
|
||||||
if DataManager.ChapterData:showRedPoint() then
|
if DataManager.ChapterData:getChapterBoxCanGet() then
|
||||||
self.chapterBoxBtn:addRedPoint(20, 20, 1)
|
self.chapterBoxBtn:addRedPoint(20, 20, 1)
|
||||||
else
|
else
|
||||||
self.chapterBoxBtn:removeRedPoint()
|
self.chapterBoxBtn:removeRedPoint()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
local BaseTips = require "app/ui/tips/base_tips"
|
local BaseTips = require "app/ui/tips/base_tips"
|
||||||
local RewardBox = class("RewardBox", BaseTips)
|
local RewardBox = class("RewardBox", BaseTips)
|
||||||
|
|
||||||
local CELL_WIDTH = 130
|
local CELL_WIDTH = 120
|
||||||
local CELL_NUM = 5
|
local CELL_NUM = 5
|
||||||
|
|
||||||
function RewardBox:ctor(params)
|
function RewardBox:ctor(params)
|
||||||
@ -39,16 +39,16 @@ function RewardBox:onLoadRootComplete()
|
|||||||
uiMap["reward_box.continue_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_CLOSE_DESC))
|
uiMap["reward_box.continue_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_CLOSE_DESC))
|
||||||
|
|
||||||
self:_refreshScrollRect()
|
self:_refreshScrollRect()
|
||||||
uiMap["reward_box.effect_node.ui_spine_obj"]:playAnim("idle", false, false)
|
uiMap["reward_box.effect_node.ui_spine_obj"]:playAnim("idle", true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function RewardBox:_refreshScrollRect()
|
function RewardBox:_refreshScrollRect()
|
||||||
if #self.params.rewards <= 5 then
|
if #self.params.rewards <= 5 then
|
||||||
self.scrollView:setSizeDeltaX(#self.params.rewards*CELL_WIDTH)
|
self.scrollView:setSizeDelta(#self.params.rewards*CELL_WIDTH, 120)
|
||||||
self.scrollRect:setPerLineNum(#self.params.rewards)
|
self.scrollRect:setPerLineNum(#self.params.rewards)
|
||||||
self.scrollRect:refillCells(#self.params.rewards, true)
|
self.scrollRect:refillCells(#self.params.rewards, true)
|
||||||
else
|
else
|
||||||
self.scrollView:setSizeDeltaX(CELL_WIDTH*5)
|
self.scrollView:setSizeDelta(CELL_WIDTH*5, 314)
|
||||||
self.scrollRect:setPerLineNum(CELL_NUM)
|
self.scrollRect:setPerLineNum(CELL_NUM)
|
||||||
self.scrollRect:refillCells(#self.params.rewards, true)
|
self.scrollRect:refillCells(#self.params.rewards, true)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,6 +16,8 @@ function ChapterData:clear()
|
|||||||
self.trailHeroId = nil
|
self.trailHeroId = nil
|
||||||
self.trailChapterId = nil
|
self.trailChapterId = nil
|
||||||
self.trailAtkInfo = nil
|
self.trailAtkInfo = nil
|
||||||
|
self.boxCanGetState = nil
|
||||||
|
self.canGetBoxInfo = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChapterData:init(data, notChangeChapterId)
|
function ChapterData:init(data, notChangeChapterId)
|
||||||
@ -47,6 +49,8 @@ function ChapterData:init(data, notChangeChapterId)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.data.chapterInfo = data.chapter_info or {}
|
self.data.chapterInfo = data.chapter_info or {}
|
||||||
|
self.boxCanGetState = nil
|
||||||
|
self.canGetBoxInfo = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChapterData:getIsFirstChapter(chapterId)
|
function ChapterData:getIsFirstChapter(chapterId)
|
||||||
@ -150,6 +154,45 @@ function ChapterData:getChapterBoxNum(chapterId, index)
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ChapterData:getChapterBoxCanGet()
|
||||||
|
if self.boxCanGetState == nil then
|
||||||
|
self:calcChapterBoxCanGet()
|
||||||
|
end
|
||||||
|
return self.boxCanGetState or false
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChapterData:calcChapterBoxCanGet()
|
||||||
|
for chapterId = 1, self.data.maxChapterId do
|
||||||
|
for ii = 1, 3 do
|
||||||
|
local canGet = not self:getChapterBoxRewardGot(chapterId, ii)
|
||||||
|
if canGet then
|
||||||
|
self.boxCanGetState = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.boxCanGetState = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChapterData:getChapterBoxCanGetInfo()
|
||||||
|
self.canGetBoxInfo = {}
|
||||||
|
local maxChapterId = self:getNextChapter(self.data.maxChapterId)
|
||||||
|
for chapterId = 1, maxChapterId do
|
||||||
|
local boxes = {}
|
||||||
|
for i = 1, 3 do
|
||||||
|
local canGet = not self:getChapterBoxRewardGot(chapterId, i) and self:boxCanGet(chapterId, i)
|
||||||
|
Logger.logHighlight("chapterId: = %s i = %s canGet = %s", chapterId, i, canGet)
|
||||||
|
if canGet then
|
||||||
|
table.insert(boxes, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #boxes > 0 then
|
||||||
|
table.insert(self.canGetBoxInfo, {id = chapterId, boxes = boxes})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self.canGetBoxInfo
|
||||||
|
end
|
||||||
|
|
||||||
function ChapterData:getChapterBoxRewardGot(chapterId, index)
|
function ChapterData:getChapterBoxRewardGot(chapterId, index)
|
||||||
chapterId = chapterId or self:getChapterId()
|
chapterId = chapterId or self:getChapterId()
|
||||||
local info = self.data.chapterInfo[chapterId]
|
local info = self.data.chapterInfo[chapterId]
|
||||||
@ -297,21 +340,14 @@ function ChapterData:getChapterPassed(chapterId)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChapterData:openBox(chapterId, index)
|
function ChapterData:openBox()
|
||||||
if not self.data.chapterInfo[chapterId] then
|
for chapterId = 1, self.data.maxChapterId do
|
||||||
self.data.chapterInfo[chapterId] = {
|
self.data.chapterInfo[chapterId] = self.data.chapterInfo[chapterId] or {total_count = 0, index = {}, mystery_box_idx = {}}
|
||||||
total_count = 0,
|
for i = 1, 3 do
|
||||||
index = {},
|
self.data.chapterInfo[chapterId].index[i] = i
|
||||||
mystery_box_idx = {}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
for _, idx in ipairs(self.data.chapterInfo[chapterId].index) do
|
|
||||||
if idx == index then
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.boxCanGetState = nil
|
||||||
table.insert(self.data.chapterInfo[chapterId].index, index)
|
|
||||||
|
|
||||||
self:setDirty()
|
self:setDirty()
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user