This commit is contained in:
chenxi 2023-05-22 21:23:07 +08:00
parent 3f747de9aa
commit 78e03328ce
22 changed files with 198 additions and 73 deletions

View File

@ -79,6 +79,7 @@ BIReport.ADS_CLICK_TYPE = {
TASK_DAILY_REFRESH = "TaskDailyRefresh", TASK_DAILY_REFRESH = "TaskDailyRefresh",
TASK_DAILY_TASK = "TaskDailyTask", TASK_DAILY_TASK = "TaskDailyTask",
IDLE_QUICK_DROP = "IdleQuickDrop", IDLE_QUICK_DROP = "IdleQuickDrop",
MAIL = "Mail",
} }
BIReport.FIGHT_OPT_TYPE = { BIReport.FIGHT_OPT_TYPE = {

View File

@ -15,7 +15,7 @@ function DataManager:init()
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data") self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
self:initManager("MailData", "app/userdata/mail/mail_data") self:initManager("MailData", "app/userdata/mail/mail_data")
self:initManager("ActivityData", "app/userdata/activity/activity_data") self:initManager("ActivityData", "app/userdata/activity/activity_data")
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data") self:initManager("GoldPigData", "app/userdata/activity/gold_pig/gold_pig_data")
self:initManager("BountyData", "app/userdata/bounty/bounty_data") self:initManager("BountyData", "app/userdata/bounty/bounty_data")
self:initManager("DailyTaskData", "app/userdata/task/daily_task_data") self:initManager("DailyTaskData", "app/userdata/task/daily_task_data")
self:initManager("IdleData", "app/userdata/idle/idle_data") self:initManager("IdleData", "app/userdata/idle/idle_data")
@ -84,7 +84,7 @@ function DataManager:clear()
self.FormationData:clear() self.FormationData:clear()
self.ActivityData:clear() self.ActivityData:clear()
self.MailData:clear() self.MailData:clear()
self.GodPigData:clear() self.GoldPigData:clear()
self.BountyData:clear() self.BountyData:clear()
self.DailyTaskData:clear() self.DailyTaskData:clear()
self.IdleData:clear() self.IdleData:clear()
@ -114,7 +114,7 @@ function DataManager:initWithServerData(data)
self.TutorialData:init(data.guide) self.TutorialData:init(data.guide)
self.MailData:init(data.mail_info) self.MailData:init(data.mail_info)
self.ActivityData:init() self.ActivityData:init()
self.GodPigData:init(data.pig) self.GoldPigData:init(data.pig)
self.BountyData:init(data.bounty) self.BountyData:init(data.bounty)
-- 任务要在BountyData之后初始化依赖BountyData的数据 -- 任务要在BountyData之后初始化依赖BountyData的数据
self.DailyTaskData:init(data.task_daily) self.DailyTaskData:init(data.task_daily)

View File

@ -25,6 +25,7 @@ EventManager.CUSTOM_EVENT = {
LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS", LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS",
DAILY_TASK_ADD_PROGRESS = "DAILY_TASK_ADD_PROGRESS", DAILY_TASK_ADD_PROGRESS = "DAILY_TASK_ADD_PROGRESS",
BOSS_ENTER_ANI_OVER = "BOSS_ENTER_ANI_OVER", BOSS_ENTER_ANI_OVER = "BOSS_ENTER_ANI_OVER",
TIME_TRIGGERED_NEW_EMAIL = "TIME_TRIGGERED_NEW_EMAIL" -- 邮件到时间请求是否有新邮件
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN", -- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER" -- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
} }

View File

@ -191,6 +191,13 @@ function Time:getDayofWeek(time)
return day return day
end end
function Time:getDayofWeekUTC(time)
local curTime = time or self:getServerTime()
local day = tonumber(os.date("!%w", curTime))
day = day == 0 and 7 or day
return day
end
-- 00:00:00 -- 00:00:00
function Time:formatNumTime(time) function Time:formatNumTime(time)
if time <= 0 then if time <= 0 then

View File

@ -91,7 +91,7 @@ function ChapterManager:endFightFinish(result)
ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx) ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx)
DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx) DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx)
-- 处理金猪 -- 处理金猪
-- DataManager.GodPigData:addGoldPigCount() -- DataManager.GoldPigData:addGoldPigCount()
local newMaxChapter = DataManager.ChapterData:getNewChapterId() local newMaxChapter = DataManager.ChapterData:getNewChapterId()
if maxChapter ~= newMaxChapter then if maxChapter ~= newMaxChapter then

View File

@ -66,6 +66,13 @@ Example: chapter 5 10 参数1 章节 参数2 波次]],
Example: reset_bounty]], Example: reset_bounty]],
type = "reset_bounty" type = "reset_bounty"
}, },
{
title = "添加邮件",
desc = [[ type:add_mail
arg1:id
Example: add_mail 1]],
type = "add_mail"
},
} }
return GMConst return GMConst

View File

@ -148,7 +148,7 @@ function LoginManager:loginFinish(data)
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS) EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS)
-- ModuleManager.MailManager:getMailList(true) ModuleManager.MailManager:getMailList(true)
DataManager:setLoginSuccess(true) DataManager:setLoginSuccess(true)
BIReport:postGameLoginFinish() BIReport:postGameLoginFinish()

View File

@ -128,8 +128,8 @@ function MailManager:readMailFinish(result)
end end
function MailManager:needUpdateMail() function MailManager:needUpdateMail()
DataManager.MailData:setNeedGetNewMail(true) -- 收到推送后不一定是有新邮件,要去拉一下
DataManager.MailData:setDirty() self:getMailList(true)
end end
return MailManager return MailManager

View File

@ -23,7 +23,7 @@ MainCityConst.LEFT_SIDE_BARS = {
} }
MainCityConst.RIGHT_SIDE_BARS = { MainCityConst.RIGHT_SIDE_BARS = {
"app/ui/main_city/cell/side_bar_god_pig_cell", "app/ui/main_city/cell/side_bar_gold_pig_cell",
} }
return MainCityConst return MainCityConst

View File

@ -45,6 +45,8 @@ local ProtoMsgType = {
[2118853729] = "HeroUpgradeRsp", [2118853729] = "HeroUpgradeRsp",
[2285872137] = "ChapterBoxRewardReq", [2285872137] = "ChapterBoxRewardReq",
[2285873970] = "ChapterBoxRewardRsp", [2285873970] = "ChapterBoxRewardRsp",
[2429586383] = "MailCycleReq",
[2429588216] = "MailCycleRsp",
[2515553923] = "BuyMallDailyReq", [2515553923] = "BuyMallDailyReq",
[2515555756] = "BuyMallDailyRsp", [2515555756] = "BuyMallDailyRsp",
[2581180989] = "MailListReq", [2581180989] = "MailListReq",
@ -86,6 +88,8 @@ local ProtoMsgType = {
[3663247602] = "MallDailyResetNtf", [3663247602] = "MallDailyResetNtf",
[3663314292] = "MallDailyResetReq", [3663314292] = "MallDailyResetReq",
[3663316125] = "MallDailyResetRsp", [3663316125] = "MallDailyResetRsp",
[3741702491] = "MallDailyOverDayReq",
[3741704324] = "MallDailyOverDayRsp",
[3757169544] = "BountyRewardReq", [3757169544] = "BountyRewardReq",
[3757171377] = "BountyRewardRsp", [3757171377] = "BountyRewardRsp",
[3763117270] = "HeartbeatReq", [3763117270] = "HeartbeatReq",
@ -145,6 +149,8 @@ local ProtoMsgType = {
HeroUpgradeRsp = 2118853729, HeroUpgradeRsp = 2118853729,
ChapterBoxRewardReq = 2285872137, ChapterBoxRewardReq = 2285872137,
ChapterBoxRewardRsp = 2285873970, ChapterBoxRewardRsp = 2285873970,
MailCycleReq = 2429586383,
MailCycleRsp = 2429588216,
BuyMallDailyReq = 2515553923, BuyMallDailyReq = 2515553923,
BuyMallDailyRsp = 2515555756, BuyMallDailyRsp = 2515555756,
MailListReq = 2581180989, MailListReq = 2581180989,
@ -186,6 +192,8 @@ local ProtoMsgType = {
MallDailyResetNtf = 3663247602, MallDailyResetNtf = 3663247602,
MallDailyResetReq = 3663314292, MallDailyResetReq = 3663314292,
MallDailyResetRsp = 3663316125, MallDailyResetRsp = 3663316125,
MallDailyOverDayReq = 3741702491,
MallDailyOverDayRsp = 3741704324,
BountyRewardReq = 3757169544, BountyRewardReq = 3757169544,
BountyRewardRsp = 3757171377, BountyRewardRsp = 3757171377,
HeartbeatReq = 3763117270, HeartbeatReq = 3763117270,
@ -245,6 +253,8 @@ local ProtoMsgType = {
HeroUpgradeRsp = "HeroUpgradeRsp", HeroUpgradeRsp = "HeroUpgradeRsp",
ChapterBoxRewardReq = "ChapterBoxRewardReq", ChapterBoxRewardReq = "ChapterBoxRewardReq",
ChapterBoxRewardRsp = "ChapterBoxRewardRsp", ChapterBoxRewardRsp = "ChapterBoxRewardRsp",
MailCycleReq = "MailCycleReq",
MailCycleRsp = "MailCycleRsp",
BuyMallDailyReq = "BuyMallDailyReq", BuyMallDailyReq = "BuyMallDailyReq",
BuyMallDailyRsp = "BuyMallDailyRsp", BuyMallDailyRsp = "BuyMallDailyRsp",
MailListReq = "MailListReq", MailListReq = "MailListReq",
@ -286,6 +296,8 @@ local ProtoMsgType = {
MallDailyResetNtf = "MallDailyResetNtf", MallDailyResetNtf = "MallDailyResetNtf",
MallDailyResetReq = "MallDailyResetReq", MallDailyResetReq = "MallDailyResetReq",
MallDailyResetRsp = "MallDailyResetRsp", MallDailyResetRsp = "MallDailyResetRsp",
MallDailyOverDayReq = "MallDailyOverDayReq",
MallDailyOverDayRsp = "MallDailyOverDayRsp",
BountyRewardReq = "BountyRewardReq", BountyRewardReq = "BountyRewardReq",
BountyRewardRsp = "BountyRewardRsp", BountyRewardRsp = "BountyRewardRsp",
HeartbeatReq = "HeartbeatReq", HeartbeatReq = "HeartbeatReq",

View File

@ -5,14 +5,35 @@ function GoldPigUI:isFullScreen()
end end
function GoldPigUI:getPrefabPath() function GoldPigUI:getPrefabPath()
return "assets/prefabs/ui/activity/god_pig/gold_pig_ui.prefab" return "assets/prefabs/ui/activity/gold_pig/gold_pig_ui.prefab"
end end
function GoldPigUI:onLoadRootComplete() function GoldPigUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["gold_pig_ui.gift_bg.buy_btn"]:addClickListener(function() uiMap["gold_pig_ui.bg.close_btn"]:addClickListener(function()
self:closeUI() self:closeUI()
end) end)
uiMap["gold_pig_ui.bg.title_tx"]:setText("临时文本:超值金猪")
uiMap["gold_pig_ui.bg.desc_tx"]:setText("临时文本:挑战关卡并收集钻石,你就可以获得一笔划算的交易。")
uiMap["gold_pig_ui.bg.value_bg.tx"]:setText("临时文本:300%")
local currGem = DataManager.GoldPigData:getGoldPigGemCount()
local maxGem = DataManager.GoldPigData:getGoldPigGemMaxCount()
local nowGemTx = uiMap["gold_pig_ui.bg.slider.now_gem_bg.gem_tx"]
nowGemTx:setText(GFunc.intToString(currGem))
local nowGemImg = uiMap["gold_pig_ui.bg.slider.now_gem_bg.gem_img"]
GFunc.centerImgAndTx(nowGemImg, nowGemTx, 0, -4)
local maxGemTx = uiMap["gold_pig_ui.bg.slider.max_gem_bg.gem_tx"]
maxGemTx:setText(GFunc.intToString(maxGem))
local maxGemImg = uiMap["gold_pig_ui.bg.slider.max_gem_bg.gem_img"]
GFunc.centerImgAndTx(maxGemImg, maxGemTx, 0, -4)
uiMap["gold_pig_ui.bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = currGem / maxGem
uiMap["gold_pig_ui.bg.buy_btn"]:addClickListener(function()
end)
local rechargeId = DataManager.GoldPigData:getRechargeId()
uiMap["gold_pig_ui.bg.buy_btn.text"]:setText(GFunc.getFormatPrice(rechargeId))
end end
return GoldPigUI return GoldPigUI

View File

@ -81,7 +81,7 @@ function BountyBuyUI:initBtns()
local buyProBountyAddLevels = DataManager.BountyData:getBuyProBountyAddLevelCount() local buyProBountyAddLevels = DataManager.BountyData:getBuyProBountyAddLevelCount()
if level > maxLevel - buyProBountyAddLevels then if level > maxLevel - buyProBountyAddLevels then
local params = { local params = {
content = "购买此通行证会超过通行证等级上限,会造成损失,是否购买?", content = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_4),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
okFunc = function() okFunc = function()
self:closeUI() self:closeUI()

View File

@ -70,7 +70,7 @@ function MessageBox:showMessageBox(params)
uiMap["message_box.title_bg_img.title_text"]:setText(titleTx) uiMap["message_box.title_bg_img.title_text"]:setText(titleTx)
uiMap["message_box.title_bg_img.bg.content_tx"]:setText(content) uiMap["message_box.title_bg_img.bg.content_tx"]:setText(content)
uiMap["message_box.title_bg_img.btn.cancel_btn.text"]:setText(cancelText or I18N:getGlobalText(I18N.GlobalConst.CANCEL_1)) uiMap["message_box.title_bg_img.btn.cancel_btn.text"]:setText(cancelText or I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL))
if boxType == GConst.MESSAGE_BOX_TYPE.MB_OK then if boxType == GConst.MESSAGE_BOX_TYPE.MB_OK then
uiMap["message_box.title_bg_img.btn.cancel_btn"]:setVisible(false) uiMap["message_box.title_bg_img.btn.cancel_btn"]:setVisible(false)

View File

@ -1,16 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarGodPigCell = class("SideBarGodPigCell", SideBarBaseCellComp)
function SideBarGodPigCell:getIsOpen()
return false
end
function SideBarGodPigCell:getIconRes()
return "main_btn_pig"
end
function SideBarGodPigCell:onClick()
ModuleManager.ActivityManager:showGoldPigUI()
end
return SideBarGodPigCell

View File

@ -0,0 +1,16 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarGoldPigCell = class("SideBarGoldPigCell", SideBarBaseCellComp)
function SideBarGoldPigCell:getIsOpen()
return true
end
function SideBarGoldPigCell:getIconRes()
return "main_btn_pig"
end
function SideBarGoldPigCell:onClick()
ModuleManager.ActivityManager:showGoldPigUI()
end
return SideBarGoldPigCell

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4997d640a2606ed4288d0d6d708d7cea guid: 93980678bfb82024380ec443e5da7099
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -110,6 +110,13 @@ function MainCityUI:_display()
end end
function MainCityUI:_addListeners() function MainCityUI:_addListeners()
self:addEventListener(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL, function()
local time = math.random(10000, 30000) / 20000
ModuleManager.MailManager:performWithDelayGlobal(function()
ModuleManager.MailManager:getTriggeredTimeMail()
end, time)
end)
DataManager.MailData:checkNewMail()
end end
function MainCityUI:_bind() function MainCityUI:_bind()

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 97616c4602b36c14eb280f12d16bdd56 guid: 1f9faf25e847f994892adf3d644b9969
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,6 +1,6 @@
local GodPigData = class("GodPigData", BaseData) local GoldPigData = class("GoldPigData", BaseData)
function GodPigData:init(data) function GoldPigData:init(data)
data = data or GConst.EMPTY_TABLE data = data or GConst.EMPTY_TABLE
self.data.id = data.id or 0 self.data.id = data.id or 0
if self.data.id == 0 then if self.data.id == 0 then
@ -12,11 +12,11 @@ function GodPigData:init(data)
self.data.isOpen = false self.data.isOpen = false
end end
function GodPigData:getIsOpen() function GoldPigData:getIsOpen()
return self.data.isOpen return self.data.isOpen
end end
function GodPigData:addGoldPigCount() function GoldPigData:addGoldPigCount()
if not self.data.isOpen then if not self.data.isOpen then
self:tryActiveGoldPig() self:tryActiveGoldPig()
return return
@ -34,47 +34,67 @@ function GodPigData:addGoldPigCount()
end end
end end
function GodPigData:getFirstLevelId() function GoldPigData:getGoldPigGemCount()
return self.data.count
end
function GoldPigData:getGoldPigGemMaxCount()
local info = self:getCurrLevelInfo()
if info == nil then
return 1
end
return info.max_diamond
end
function GoldPigData:getRechargeId()
local info = self:getCurrLevelInfo()
if info == nil then
return 0
end
return info.recharge_id
end
function GoldPigData:getFirstLevelId()
if self.firstLevelId == nil then if self.firstLevelId == nil then
self.firstLevelId = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value self.firstLevelId = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value
end end
return self.firstLevelId return self.firstLevelId
end end
function GodPigData:getTimeOverCD() function GoldPigData:getTimeOverCD()
if self.timeOverCD == nil then if self.timeOverCD == nil then
self.timeOverCD = ConfigManager:getConfig("const")["act_gold_pig_cd"].value * 3600 self.timeOverCD = ConfigManager:getConfig("const")["act_gold_pig_cd"].value * 3600
end end
return self.timeOverCD return self.timeOverCD
end end
function GodPigData:getBoughtCD() function GoldPigData:getBoughtCD()
if self.boughtCD == nil then if self.boughtCD == nil then
self.boughtCD = ConfigManager:getConfig("const")["act_gold_pig_buy_cd"].value * 3600 self.boughtCD = ConfigManager:getConfig("const")["act_gold_pig_buy_cd"].value * 3600
end end
return self.boughtCD return self.boughtCD
end end
function GodPigData:getCfg() function GoldPigData:getCfg()
if self.cfg == nil then if self.cfg == nil then
self.cfg = ConfigManager:getConfig("act_god_pig") self.cfg = ConfigManager:getConfig("act_gold_pig")
end end
return self.cfg return self.cfg
end end
function GodPigData:getDuration() function GoldPigData:getDuration()
if self.duration == nil then if self.duration == nil then
self.duration = ConfigManager:getConfig("const")["act_gold_pig_full_cd"].value * 3600 self.duration = ConfigManager:getConfig("const")["act_gold_pig_full_cd"].value * 3600
end end
return self.duration return self.duration
end end
function GodPigData:getCurrLevelInfo() function GoldPigData:getCurrLevelInfo()
local cfg = self:getCfg() local cfg = self:getCfg()
return cfg[self.data.id] return cfg[self.data.id]
end end
function GodPigData:tryActiveGoldPig() function GoldPigData:tryActiveGoldPig()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.GOLD_PIG, true) then if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.GOLD_PIG, true) then
return return
end end
@ -89,7 +109,7 @@ function GodPigData:tryActiveGoldPig()
end end
-- 时间到了,消失并降档 -- 时间到了,消失并降档
function GodPigData:onTimeOver() function GoldPigData:onTimeOver()
if not self.data.isOpen then if not self.data.isOpen then
return return
end end
@ -105,7 +125,7 @@ function GodPigData:onTimeOver()
end end
-- 购买后,消失并升档位 -- 购买后,消失并升档位
function GodPigData:onBought(id) function GoldPigData:onBought(id)
if not self.data.isOpen then if not self.data.isOpen then
return return
end end
@ -118,4 +138,4 @@ function GodPigData:onBought(id)
self.data.cd = self:getBoughtCD() self.data.cd = self:getBoughtCD()
end end
return GodPigData return GoldPigData

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: b67c66ef72d69404bba1a01a2e3c400a guid: f25fb374307a0744fbe9ea15052f86c5
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -173,10 +173,6 @@ function BountyData:getMaxLevel()
return #self.bountyLevelCfg return #self.bountyLevelCfg
end end
function BountyData:getBountyLevelCfg()
return self.bountyLevelCfg
end
function BountyData:getAllProRewards() function BountyData:getAllProRewards()
if self.proRewards and #self.proRewards > 0 then if self.proRewards and #self.proRewards > 0 then
return self.proRewards return self.proRewards

View File

@ -9,6 +9,7 @@ local TIME_TYPE = {
} }
function MailData:ctor() function MailData:ctor()
self.mails = {} self.mails = {}
self.checkNewMailTimsList = {}
self.needGetNewMail = false self.needGetNewMail = false
self.data.isDirty = false self.data.isDirty = false
self.data.redPoint = false self.data.redPoint = false
@ -20,6 +21,8 @@ function MailData:clear()
self.data.redPoint = false self.data.redPoint = false
self.lastMailId = nil self.lastMailId = nil
self.mailIsOpen = false self.mailIsOpen = false
DataManager:unregisterDataCd("MailData")
DataManager:unregisterCrossDayFunc("MailData")
end end
function MailData:init(data) function MailData:init(data)
@ -30,48 +33,98 @@ function MailData:init(data)
self:updateRedPointCd() self:updateRedPointCd()
DataManager:registerDataCd("MailData") DataManager:registerDataCd("MailData")
DataManager:registerCrossDayFunc("MailData", function()
self:updateRedPointCd()
end)
end end
function MailData:updateRedPointCd() function MailData:updateRedPointCd()
self.needUpdateRedPointInfo = {} for i = 1, #self.checkNewMailTimsList do
table.remove(self.checkNewMailTimsList)
end
local cfg = ConfigManager:getConfig("mail") local cfg = ConfigManager:getConfig("mail")
for i,v in ipairs(cfg) do for i,v in ipairs(cfg) do
if v.time_type == TIME_TYPE.DAY then if v.time_type == TIME_TYPE.DAY then
for ii = 1, 7 do if #v.time_send == 3 then
self.needUpdateRedPointInfo[ii] = self.needUpdateRedPointInfo[ii] or {} local time = v.time_send[1] * 3600 + v.time_send[2] * 60 + v.time_send[3] + 1
if #v.time_send == 3 then local currTime = Time:getServerTime() % 86400
local time = v.time_send[1] * 3600 + v.time_send[2] * 60 + v.time_send[3] if time >= currTime then
if not table.containValue(self.needUpdateRedPointInfo[ii], time) then local find = false
table.insert(self.needUpdateRedPointInfo[ii], time) for k, v in ipairs(self.checkNewMailTimsList) do
if v == time then
find = true
break
end
end
if not find then
table.insert(self.checkNewMailTimsList, time)
end end
end end
end end
elseif v.time_type == TIME_TYPE.WEEK then elseif v.time_type == TIME_TYPE.WEEK then
if #v.time_send == 4 then if #v.time_send == 4 then -- 周几,时,分,秒
local day = v.time_send[1] local day = v.time_send[1]
self.needUpdateRedPointInfo[day] = self.needUpdateRedPointInfo[day] or {} if day == Time:getDayofWeekUTC() then
local time = v.time_send[2] * 3600 + v.time_send[3] * 60 + v.time_send[4] local time = v.time_send[2] * 3600 + v.time_send[3] * 60 + v.time_send[4] + 1
if not table.containValue(self.needUpdateRedPointInfo[day], time) then local currTime = Time:getServerTime() % 86400
table.insert(self.needUpdateRedPointInfo[day], time) if time >= currTime then
local find = false
for k, v in ipairs(self.checkNewMailTimsList) do
if v == time then
find = true
break
end
end
if not find then
table.insert(self.checkNewMailTimsList, time)
end
end
end end
end end
elseif v.time_type == TIME_TYPE.MONTH then elseif v.time_type == TIME_TYPE.MONTH then
--TODO 暂时没有 无数据格式 if #v.time_send == 4 then -- 几号,时,分,秒
local offsetSeconds = math.floor(Time:getClientTimeZone() * 3600)
local time = Time:getServerTime()
local utcNow = os.date('!*t', time)
local targetTime = math.floor(os.time({day = v.time_send[1], month = utcNow.month, year = utcNow.year, hour = v.time_send[2], min = v.time_send[3], sec = v.time_send[4]})) + offsetSeconds
if targetTime >= time then -- 还没到目标时间
local diff = targetTime - time
local todayRemainTime = time % 86400 -- 到今天24点还剩余的秒数
if diff <= todayRemainTime then -- 今天内就能达到目标时间
local targetRemainTime = targetTime % 86400
local find = false
for k, v in ipairs(self.checkNewMailTimsList) do
if v == targetRemainTime then
find = true
break
end
end
if not find then
table.insert(self.checkNewMailTimsList, targetRemainTime)
end
end
end
end
end
end
end
function MailData:checkNewMail()
if #self.checkNewMailTimsList <= 0 then
return
end
local nowTime = Time:getServerTime() % 86400
for i = #self.checkNewMailTimsList, 1, -1 do
if self.checkNewMailTimsList[i] <= nowTime then
table.remove(self.checkNewMailTimsList, i)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL)
break
end end
end end
end end
function MailData:updateCd() function MailData:updateCd()
local nowTime = Time:getServerTime() self:checkNewMail()
local today = Time:getDayofWeek()
local times = self.needUpdateRedPointInfo[today] or {}
local curTime = nowTime % 86400
for i, v in ipairs(times) do
if v == curTime then
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL)
break
end
end
end end
function MailData:addMails(mails) function MailData:addMails(mails)