diff --git a/lua/app/module/activity/fourteen_day/fourteen_day_manager.lua b/lua/app/module/activity/fourteen_day/fourteen_day_manager.lua index 452321ab..d09529fa 100644 --- a/lua/app/module/activity/fourteen_day/fourteen_day_manager.lua +++ b/lua/app/module/activity/fourteen_day/fourteen_day_manager.lua @@ -1,6 +1,10 @@ local FourteenDayManager = class("FourteenDayManager", BaseModule) function FourteenDayManager:showFourteenDayUI() + if DataManager.FourteenDayData:getNeedSyncData() then + self:reqSyncData() + end + local time = DataManager.FourteenDayData:getEndRemainTime() if time > 0 then UIManager:showUI("app/ui/activity/fourteen_day/fourteen_day_entrance_ui") @@ -56,4 +60,16 @@ function FourteenDayManager:rspExchangeReward(result) end end +function FourteenDayManager:reqSyncData() + self:sendMessage(ProtoMsgType.FromMsgEnum.FourteenDayInfoReq, {}, {}, self.rspSyncData) +end + +function FourteenDayManager:rspSyncData(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + DataManager.FourteenDayData:setSyncData() + DataManager.FourteenDayData:initData(result.info) + DataManager.FourteenDayData:setDirty() + end +end + return FourteenDayManager \ No newline at end of file diff --git a/lua/app/proto/proto_msg_type.lua b/lua/app/proto/proto_msg_type.lua index 45a6b8f4..d785e5ca 100644 --- a/lua/app/proto/proto_msg_type.lua +++ b/lua/app/proto/proto_msg_type.lua @@ -111,6 +111,8 @@ local ProtoMsgType = { [2285873970] = "ChapterBoxRewardRsp", [2314118791] = "ChapterWeaponLatestPlayerInfoReq", [2314120624] = "ChapterWeaponLatestPlayerInfoRsp", + [2420360424] = "FourteenDayInfoReq", + [2420362257] = "FourteenDayInfoRsp", [2429586383] = "MailCycleReq", [2429588216] = "MailCycleRsp", [2467213182] = "ChapterWeaponChallengeFarmReq", @@ -356,6 +358,8 @@ local ProtoMsgType = { ChapterBoxRewardRsp = 2285873970, ChapterWeaponLatestPlayerInfoReq = 2314118791, ChapterWeaponLatestPlayerInfoRsp = 2314120624, + FourteenDayInfoReq = 2420360424, + FourteenDayInfoRsp = 2420362257, MailCycleReq = 2429586383, MailCycleRsp = 2429588216, ChapterWeaponChallengeFarmReq = 2467213182, @@ -601,6 +605,8 @@ local ProtoMsgType = { ChapterBoxRewardRsp = "ChapterBoxRewardRsp", ChapterWeaponLatestPlayerInfoReq = "ChapterWeaponLatestPlayerInfoReq", ChapterWeaponLatestPlayerInfoRsp = "ChapterWeaponLatestPlayerInfoRsp", + FourteenDayInfoReq = "FourteenDayInfoReq", + FourteenDayInfoRsp = "FourteenDayInfoRsp", MailCycleReq = "MailCycleReq", MailCycleRsp = "MailCycleRsp", ChapterWeaponChallengeFarmReq = "ChapterWeaponChallengeFarmReq", diff --git a/lua/app/userdata/activity/fourteen_day/fourteen_day_data.lua b/lua/app/userdata/activity/fourteen_day/fourteen_day_data.lua index 31e76006..c6aacd62 100644 --- a/lua/app/userdata/activity/fourteen_day/fourteen_day_data.lua +++ b/lua/app/userdata/activity/fourteen_day/fourteen_day_data.lua @@ -25,12 +25,7 @@ function FourteenDayData:init(data) Logger.logHighlight("新手14天乐数据初始化") Logger.printTable(data) end - - self.openTs = GFunc.formatTimeStep(data.open_at or 0) - self.activeDays = data.active_days or 0-- 活动开启后的登陆天数、阶段数 - self.bountyStatus = data.funds - self.tasksStatus = data.tasks - self.exchangeStatus = data.exchange_info + self:initData(data) -- 活动开启 DataManager:registerTryOpenFunc("FourteenDayData", function() @@ -47,19 +42,51 @@ function FourteenDayData:init(data) if not self:isActiveTime() then return end + if not self.openStatus then + self.needSyncTaskInfo = true + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_SIDE_BAR) + end + self.openStatus = true + -- Logger.logHighlight("14天乐跨天") self.activeDays = self.activeDays + 1 self:setDirty() end) - -- 注册任务进度监听 - for id, data in ipairs(self:getTaskCfg()) do - if data.quest then - ModuleManager.TaskManager:registerTask("FourteenDayData", data.quest, function(count) - self:addTaskProgress(data.quest, count) - end) + + local endTime = self:getEndTime() + local nowTime = Time:getServerTime() + if endTime > nowTime then + -- 注册任务进度监听 + for id, data in ipairs(self:getTaskCfg()) do + if data.quest then + ModuleManager.TaskManager:registerTask("FourteenDayData", data.quest, function(count) + self:addTaskProgress(data.quest, count) + end) + end end end + + self.openStatus = false + if self:isOpen() and self:isActiveTime() then + self.openStatus = true + end +end + +function FourteenDayData:initData(data) + self.openTs = GFunc.formatTimeStep(data.open_at or 0) + self.activeDays = data.active_days or 0-- 活动开启后的登陆天数、阶段数 + self.bountyStatus = data.funds + self.tasksStatus = data.tasks + self.exchangeStatus = data.exchange_info +end + +function FourteenDayData:getNeedSyncData() + return self.needSyncTaskInfo +end + +function FourteenDayData:setSyncData() + self.needSyncTaskInfo = true end function FourteenDayData:isOpen() @@ -395,6 +422,12 @@ end -- 添加任务进度 function FourteenDayData:addTaskProgress(taskType, count) -- Logger.logHighlight("任务进度改变:"..tostring(taskType)..","..tostring(count)) + if not self:isOpen() then + return + end + if not self:isActiveTime() then + return + end for id, data in ipairs(self:getTaskCfg()) do if data.quest == taskType then