Commit ce0149f46be9083b43abd8cd058983919d136dc5

Authored by 熊润斐
2 parents 3fbbd115 4a4ea798

Merge branch 'tr/bugfix' into cn/develop

src/GlobalVar.lua
... ... @@ -16,6 +16,12 @@ TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t",
16 16  
17 17 START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600
18 18  
  19 +function weekday(now)
  20 + local day = math.ceil((now - START_RESET_TIME) % 604800 / 86400)
  21 + if day == 0 then day = 1 end
  22 + return day
  23 +end
  24 +
19 25 STRUCT_VERSION = 3 -- 数据结构版本
20 26  
21 27 IOS_SID = 4 -- 判断是不是ios设备
... ... @@ -158,6 +164,11 @@ TimeReset = {
158 164 DrawType1 = 17, -- 变异 抽卡加成
159 165 DrawType2 = 18, -- 通常 抽卡加成
160 166 DrawType3 = 19, -- 魔法 抽卡加成
  167 + WorkBattle1 = 22, -- 夜间玩法 1
  168 + WorkBattle2 = 23, -- 夜间玩法 2
  169 + WorkBattle3 = 24, -- 夜间玩法 3
  170 + WorkBattle4 = 25, -- 夜间玩法 4
  171 + WorkBattle5 = 26, -- 夜间玩法 5
161 172 }
162 173  
163 174 -- TimeReset 索引数组
... ...
src/ProtocolCode.lua
... ... @@ -121,6 +121,10 @@ actionCodes = {
121 121 Hang_bagFieldRpc = 263,
122 122 Hang_chatLineRpc = 264,
123 123 Hang_selectTeamRpc = 265,
  124 + Hang_startWorkBattleRpc = 266,
  125 + Hang_endWorkBattleRpc = 267,
  126 + Hang_workBattleInfoRpc = 268,
  127 + Hang_getWorkRewardRpc = 269,
124 128  
125 129 Diner_updateProperty = 300,
126 130 Diner_addSellRpc = 301,
... ...
src/RedisKeys.lua
... ... @@ -62,7 +62,7 @@ FRIEND_ENERGY = "role:%d:energy" -- set 送给我活动能量的好友
62 62 FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友
63 63 CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存
64 64  
65   -
  65 +WORK_BATTLE_COUNT = "global:workbattle" -- 世界次数统计
66 66 -- FRIEND_DINER_LIKE_KEY = "role:%d:diner:like" -- list
67 67  
68 68 -- UNION_SET = "global:union"
... ...
src/actions/HangAction.lua
... ... @@ -750,6 +750,251 @@ function _M.endBonusBattleRpc(agent, data)
750 750 return true
751 751 end
752 752  
  753 +
  754 +
  755 +local function workWinReward(role, bonusData, rewardType, count, sweep)
  756 + count = count or 1
  757 + local reward, change = {}
  758 +
  759 +
  760 + reward = bonusData.reward:toNumMap()
  761 + for itemId, c in pairs(reward) do
  762 + reward[itemId] = c * count
  763 + end
  764 + if rewardType == 2 or rewardType == 4 then
  765 + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do
  766 + reward[k] = (reward[k] or 0) + v
  767 + end
  768 + end
  769 + for i = 1, count do
  770 + local chance = bonusData.chance:randWeight(true)
  771 + if chance[1] ~= 0 then
  772 + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2]
  773 + end
  774 + end
  775 + reward, change = role:award(reward, {log = {desc = "workBattle", int1 = bonusData.id}})
  776 + return reward, change
  777 +end
  778 +
  779 +function _M.workBattleInfoRpc(agent, data)
  780 + local role = agent.role
  781 + local msg = MsgPack.unpack(data)
  782 + local workMainCsv = csvdb["work_mainCsv"][msg.type]
  783 + if not workMainCsv then return 1 end
  784 + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end
  785 + SendPacket(actionCodes.Hang_workBattleInfoRpc, MsgPack.pack({count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))}))
  786 + return true
  787 +end
  788 +
  789 +
  790 +function _M.getWorkRewardRpc(agent, data)
  791 + local role = agent.role
  792 + local msg = MsgPack.unpack(data)
  793 + local workMainCsv = csvdb["work_mainCsv"][msg.type]
  794 + if not workMainCsv then return 1 end
  795 + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end
  796 + local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))
  797 + if count < workMainCsv.target_num then return 3 end
  798 + local workBattle = role:getProperty("workBattle")
  799 + if workBattle[msg.type] ~= 1 then
  800 + return 4
  801 + end
  802 + workBattle[msg.type] = -1
  803 + role:updateProperty({field = "workBattle", value = workBattle})
  804 + local reward, change = role:award(workMainCsv.phase_award, {log = {desc = "workReward"}})
  805 + SendPacket(actionCodes.Hang_getWorkRewardRpc, MsgPack.pack({reward = reward, change = change}))
  806 + return true
  807 +end
  808 +
  809 +function _M.startWorkBattleRpc(agent, data)
  810 + local role = agent.role
  811 + local msg = MsgPack.unpack(data)
  812 + local id = msg.id
  813 + local count = msg.count or 1
  814 +
  815 + if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return 1 end
  816 +
  817 + local bonusData = csvdb["work_battleCsv"][id]
  818 +
  819 + if not bonusData then return 3 end
  820 +
  821 + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. bonusData.type]) then return 2 end
  822 +
  823 + local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket
  824 + local workStar = role:getProperty("workStar")
  825 +
  826 + if bonusData.unlock ~= 0 and (not workStar[bonusData.unlock] or workStar[bonusData.unlock] == 0) then return 4 end
  827 + local workBattle = role:getProperty("workBattle")
  828 + workBattle[bonusData.type] = workBattle[bonusData.type] or 0
  829 + local needCount = count - (workBattle[bonusData.type] == 0 and 1 or 0)
  830 + if needCount ~= 0 and not role:checkItemEnough({[ticketId] = needCount}) then return 11 end
  831 +
  832 + if workStar[id] and workStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then
  833 + if workBattle[bonusData.type] == 0 then
  834 + workBattle[bonusData.type] = 1
  835 + role:updateProperty({field = "workBattle", value = workBattle})
  836 + end
  837 + if needCount > 0 then
  838 + role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}})
  839 + end
  840 + redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add)
  841 + local reward, change = workWinReward(role, bonusData, 3, count, true)
  842 + SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({reward = reward, change = change}))
  843 + else
  844 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  845 + if not next(bTeam) then return 5 end
  846 + role.__bonusBattleCache = {
  847 + key = tostring(math.random()),
  848 + id = id,
  849 + }
  850 + SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
  851 + end
  852 +
  853 + return true
  854 +end
  855 +
  856 +function _M.endWorkBattleRpc(agent, data)
  857 + local role = agent.role
  858 + local msg = MsgPack.unpack(data)
  859 + local id = msg.id
  860 + local key = msg.key
  861 + local starNum = msg.starNum
  862 + if not role.__bonusBattleCache then return 1 end
  863 +
  864 +
  865 + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
  866 + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1}))
  867 + return true
  868 + end
  869 + role.__bonusBattleCache = nil
  870 +
  871 + -- 防作弊
  872 + if not role:checkBattleCheat("work", {
  873 + id = id,
  874 + isWin = starNum and starNum > 0,
  875 + info = msg.info
  876 + }) then
  877 + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1}))
  878 + return true
  879 + end
  880 +
  881 + local bonusData = csvdb["work_battleCsv"][id]
  882 + local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket
  883 + local reward, change = {}
  884 +
  885 + local workStar = role:getProperty("workStar")
  886 + local oldStar = workStar[id] or 0
  887 + local curStar = 0
  888 + if starNum and starNum > 0 then
  889 + -- 胜利扣除次数
  890 +
  891 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  892 + local herosInfo = role:getTeamHerosInfo(bTeam).heros
  893 +
  894 + local check = {}
  895 + -- 1 通关
  896 + check[1] = function(_)
  897 + return true
  898 + end
  899 + -- 2 阵亡人数 <= N
  900 + check[2] = function(_, cond)
  901 + return msg.info.dead and msg.info.dead <= cond
  902 + end
  903 + -- 3 全员存活
  904 + check[3] = function(_)
  905 + return msg.info.dead and msg.info.dead == 0
  906 + end
  907 + -- 4 指定种族 >= N
  908 + check[4] = function(_, cond)
  909 + local count = 0
  910 + for _, one in pairs(herosInfo) do
  911 + local heroData = csvdb["unitCsv"][one.type]
  912 + if heroData.camp == cond then
  913 + count = count + 1
  914 + end
  915 + end
  916 + return count >= cond
  917 + end
  918 + -- 5 指定职业 >= N
  919 + check[5] = function(_, cond)
  920 + local count = 0
  921 + for _, one in pairs(herosInfo) do
  922 + local heroData = csvdb["unitCsv"][one.type]
  923 + if heroData.job == cond then
  924 + count = count + 1
  925 + end
  926 + end
  927 + return count >= cond
  928 + end
  929 + -- 6 含有指定角色
  930 + check[6] = function(_, cond)
  931 + for _, one in pairs(herosInfo) do
  932 + if one.type == cond then
  933 + return true
  934 + end
  935 + end
  936 + return false
  937 + end
  938 + -- 7 通关耗时 <= X 秒 msg.info.atime
  939 + check[7] = function(_, cond)
  940 + return msg.info.atime and msg.info.atime <= cond
  941 + end
  942 + curStar = 0
  943 + local sweepConds = bonusData.sweep_condition:toTableArray(true)
  944 + for i, cond in ipairs(sweepConds) do
  945 + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
  946 + curStar = curStar + (1 << (i - 1))
  947 + end
  948 + end
  949 + local status
  950 + local rewardType = 0
  951 + if curStar >= (1 << #sweepConds) - 1 then -- 满星
  952 + rewardType = 2
  953 + if oldStar == 0 then --通关
  954 + rewardType = 4
  955 + end
  956 + elseif oldStar == 0 then --通关
  957 + rewardType = 1
  958 + end
  959 +
  960 + if rewardType ~= 0 then
  961 + local workBattle = role:getProperty("workBattle")
  962 + workBattle[bonusData.type] = workBattle[bonusData.type] or 0
  963 + local needCount = 1 - (workBattle[bonusData.type] == 0 and 1 or 0)
  964 + if workBattle[bonusData.type] == 0 then
  965 + workBattle[bonusData.type] = 1
  966 + role:updateProperty({field = "workBattle", value = workBattle})
  967 + end
  968 + if needCount > 0 then
  969 + role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}})
  970 + end
  971 + redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add)
  972 + reward, change = workWinReward(role, bonusData, rewardType)
  973 + end
  974 + else
  975 + curStar = oldStar
  976 + end
  977 + if curStar ~= oldStar then
  978 + workStar[id] = curStar
  979 + role:updateProperty({field = "workStar", value = workStar})
  980 + end
  981 +
  982 + role:checkBattle("work", {
  983 + id = id,
  984 + isWin = starNum and starNum > 0,
  985 + info = msg.info,
  986 + reward = reward,
  987 + })
  988 + role:mylog("hang_action", {desc = "workBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
  989 +
  990 + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({
  991 + starNum = starNum,
  992 + reward = reward,
  993 + change = change
  994 + }))
  995 + return true
  996 +end
  997 +
753 998 function _M.hangGiftRpc(agent, data)
754 999 local role = agent.role
755 1000 local msg = MsgPack.unpack(data)
... ...
src/actions/RoleAction.lua
... ... @@ -161,6 +161,9 @@ function _M.loginRpc( agent, data )
161 161 role:getAdvData(true) -- 清掉不合格的数据
162 162 role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查
163 163 role:checkSeaportTrade() -- 检查海港贸易季活动
  164 + if not next(role:getProperty("workBattle")) then
  165 + role:setProperty("workBattle", {round = math.floor((now - START_RESET_TIME) / 604800)})
  166 + end
164 167  
165 168 -- 跨天登陆事件
166 169 local resetMode = role:updateTimeReset(now)
... ... @@ -936,7 +939,15 @@ function _M.taskActiveRpc(agent, data)
936 939 return
937 940 end
938 941  
939   - local reward, change = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}})
  942 + local needReward = taskData.reward:toNumMap()
  943 + if taskData.reward_2 ~= 0 then
  944 + local day = weekday(skynet.timex())
  945 + local workMainCsv = csvdb["work_mainCsv"][day]
  946 + if workMainCsv then
  947 + needReward[workMainCsv.ticket] = taskData.reward_2
  948 + end
  949 + end
  950 + local reward, change = role:award(needReward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}})
940 951 role:changeUpdates({
941 952 { type = roleField[taskType], field = {"at", taskId}, value = -1 }
942 953 })
... ...
src/actions/StoreAction.lua
... ... @@ -286,7 +286,7 @@ function _M.shopBuyRpc(agent , data)
286 286  
287 287 local cost = {[dataSet.icon] = dataSet.cost * count}
288 288  
289   - local desc = "unknown"
  289 + local desc = "unknowShop"
290 290 if dataSet.shop == 1 then -- 普通商店
291 291 desc = "dailyShop"
292 292 local dailySDD = role.dailyData:getProperty("dailySDD")
... ...
1   -Subproject commit ec92ed50d3d5ff9655b1715239e7fda48f8ef5cb
  1 +Subproject commit 2499d73adbdf6ea3562ce3a815d3189e3a3aab7c
... ...
src/models/Activity.lua
... ... @@ -884,6 +884,11 @@ function Activity:getBattleTicket(actId)
884 884 local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000
885 885  
886 886 local count = actData["ticket"] or init
  887 + if count >= limit then
  888 + actData["ts"] = timeNow
  889 + self:updateActData("ChallengeLevel", actData)
  890 + return
  891 + end
887 892 local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0)
888 893  
889 894 local newCount= math.min(count + add, limit)
... ...
src/models/Role.lua
... ... @@ -120,6 +120,8 @@ Role.schema = {
120 120 towerTeams = {"table", {}}, -- 四个电波塔的队伍
121 121  
122 122 bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1
  123 + workStar = {"table", {}}, -- 夜间玩法 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1
  124 + workBattle = {"table", {}}, -- 夜间玩法记录 {[1] = 1, [2] = 1, [3] = 1, [4] = 1, round = 10} -- 第N天打了多少次 round 轮次
123 125  
124 126 --引导相关
125 127 newerGuide = {"string","1=1"}, -- 新手引导 master=slave
... ... @@ -379,6 +381,8 @@ function Role:data()
379 381 towerTeams = self:getProperty("towerTeams"),
380 382  
381 383 bonusStar = self:getProperty("bonusStar"),
  384 + workStar = self:getProperty("workStar"),
  385 + workBattle = self:getProperty("workBattle"),
382 386  
383 387 newerGuide = self:getProperty("newerGuide"),
384 388 funcGuide = self:getProperty("funcGuide"),
... ...
src/models/RoleBattle.lua
... ... @@ -17,6 +17,7 @@ local BattleType = {
17 17 pvpc = 500,
18 18 pvph = 501,
19 19 act_battle = 502,
  20 + work = 301,
20 21 }
21 22  
22 23 RoleBattle.bind = function (Role)
... ... @@ -127,6 +128,18 @@ function Role:checkBattleCheat(battleType, params)
127 128 -- local carbonData = csvdb["bonus_battleCsv"][params.id]
128 129 -- enemyServer = packBattleEnemyCommon(carbonData)
129 130 end
  131 + cheat["work"] = function()
  132 + local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.BonusBattle))
  133 + for slot, hero in pairs(team.heros) do
  134 + local temp = {}
  135 + for arr, _ in pairs(checkCheatAttrs) do
  136 + temp[arr] = hero[arr]
  137 + end
  138 + selfTeamServer[hero.type] = temp
  139 + end
  140 + -- local carbonData = csvdb["bonus_battleCsv"][params.id]
  141 + -- enemyServer = packBattleEnemyCommon(carbonData)
  142 + end
130 143 cheat["pvpc"] = function()
131 144 if not params.format then return end
132 145 local team = self:getTeamBattleInfo(params.format)
... ...
src/models/RoleLog.lua
... ... @@ -58,6 +58,7 @@ local ItemReason = {
58 58 newSign = 142,-- 新的活动签到
59 59 advLevelStage = 143, -- 拾荒活动阶段奖励
60 60 towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励
  61 + unknowShop = 145, -- 未知商店
61 62  
62 63  
63 64 advHang = 301, -- 拾荒挂机
... ... @@ -72,6 +73,8 @@ local ItemReason = {
72 73 towerBattle = 310, -- 电波塔战斗
73 74 advOver = 311, -- 冒险结算
74 75 advUnlock = 312, -- 拾荒解锁
  76 + workBattle = 313, -- workBattle夜间打工
  77 + workReward = 314, -- workBattle夜间打工 阶段奖励
75 78  
76 79 dinerFinishTask = 401, -- 餐厅完成任务
77 80 storybookReward = 402, -- 剧情奖励
... ...
src/models/RolePlugin.lua
... ... @@ -144,7 +144,9 @@ function RolePlugin.bind(Role)
144 144 self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log})
145 145 end,
146 146 [ItemType.BossTicket] = function ()
147   - if not self.activity:isOpen("ChallengeLevel") then return end
  147 + local isOpen, actId = self.activity:isOpen("ChallengeLevel")
  148 + if not isOpen then return end
  149 + self.activity:getBattleTicket(actId)
148 150 local actData = self.activity:getActData("ChallengeLevel")
149 151 actData["ticket"] = (actData["ticket"] or 0) + count
150 152 self.activity:updateActData("ChallengeLevel", actData)
... ... @@ -861,7 +863,6 @@ function RolePlugin.bind(Role)
861 863 if not params.notNotify then
862 864 local response = {}
863 865 table.insert(response, newSpark:data())
864   - dump(response)
865 866 SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response))
866 867 end
867 868 --self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify)
... ... @@ -1352,7 +1353,7 @@ function RolePlugin.bind(Role)
1352 1353 for idx, set in ipairs(csvdb["seaport_purchaseCsv"]) do
1353 1354 local done = true
1354 1355 for id, data in ipairs(set) do
1355   - if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then
  1356 + if donate[idx] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then
1356 1357 done = false
1357 1358 break
1358 1359 end
... ...
src/models/RoleTimeReset.lua
... ... @@ -33,6 +33,38 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
33 33 self:checkReturner()
34 34 end
35 35  
  36 + -- 检查 夜间打工
  37 + local workBattle = self:getProperty("workBattle")
  38 + local need = {}
  39 + for i = 1, 5 do
  40 + if workBattle[i] == 1 then
  41 + need[#need + 1] = workBattle.round * 10 + i
  42 + end
  43 + end
  44 + local change = false
  45 + if next(need) then
  46 + local ret = redisproxy:hmget(WORK_BATTLE_COUNT, table.unpack(need))
  47 + for idx, v in ipairs(need) do
  48 + local ctype = v % 10
  49 + local ccount = tonum(ret[idx])
  50 + local workMainCsv = csvdb["work_mainCsv"][ctype]
  51 + if ccount >= workMainCsv.target_num then
  52 + self:sendMail(workMainCsv.email, nil, workMainCsv.phase_award)
  53 + end
  54 + workBattle[ctype] = -1
  55 + end
  56 + change = true
  57 + end
  58 + local newRound = math.floor((now - START_RESET_TIME) / 604800)
  59 + if newRound ~= workBattle.round then
  60 + workBattle = {round = newRound}
  61 + change = true
  62 + end
  63 + if change then
  64 + self:setProperty("workBattle", workBattle)
  65 + response.workBattle = workBattle
  66 + end
  67 +
36 68 response.dTask = {}
37 69 response.advSup = self:getProperty("advSup")
38 70 self:log("onLogin")
... ...
src/services/globald.lua
... ... @@ -245,6 +245,23 @@ local function check_trade_seaport_donate()
245 245 skynet.timeout(interval * 100, check_trade_seaport_donate)
246 246 end
247 247  
  248 +local function check_work_battle()
  249 + local csvdb = require "shared.csvdata"
  250 + local now = skynet.timex()
  251 + local day = weekday(now)
  252 + local workMainCsv = csvdb["work_mainCsv"][day]
  253 + if workMainCsv and isSpecTime(now - RESET_TIME * 3600, csvdb["time_resetCsv"][TimeReset["WorkBattle1"]].start / 3600, 24) then
  254 + local round = math.floor((now - START_RESET_TIME) / 604800)
  255 + local field = round * 10 + day
  256 + local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, field))
  257 + if count < workMainCsv.target_num then
  258 + local add = math.floor(workMainCsv.target_num * math.randomInt(3125, 5000) / 100000)
  259 + redisproxy:hincrby(WORK_BATTLE_COUNT, field, add)
  260 + end
  261 + end
  262 + skynet.timeout(math.randomInt(10 * 60, 15 * 60) * 100, check_work_battle)
  263 +end
  264 +
248 265 local CMD = {}
249 266  
250 267  
... ... @@ -266,10 +283,12 @@ end
266 283  
267 284  
268 285 function CMD.start()
  286 + math.randomInit(skynet.timex())
269 287 check_mail_queue()
270 288 --check_battle_act_close()
271 289 check_trade_seaport_status()
272 290 check_trade_seaport_donate()
  291 + check_work_battle()
273 292 end
274 293  
275 294 local function __init__()
... ...
src/utils/CommonFunc.lua
... ... @@ -235,8 +235,9 @@ function specMonday(now)
235 235 return time - (wday - 1) * 86400
236 236 end
237 237  
238   -function isSpecTime(startHour, endHour, specday)
239   - local tm = os.date("*t", skynet.timex())
  238 +function isSpecTime(ctime, startHour, endHour, specday)
  239 + ctime = ctime or skynet.timex()
  240 + local tm = os.date("*t", ctime)
240 241 if specday then
241 242 local day = (tm.wday+6)%7
242 243 if day == 0 then day = 7 end
... ...