Commit 05b8e0a14ec213f1c1c5db1ce415837f959faf87

Authored by zhouhaihai
2 parents ca60c395 5e6af9d6

Merge branch 'develop' into tr/cb

* develop:
  排队功能
  付费签到改为主动领取,战斗关卡不一定是当前挂机关卡
  推送
  挂机关卡可以选择,经验金币根据最高关卡计算
  bug
  挂机排除噩梦难度
  英雄帖任务bug
  被动技新
  英雄帖活动初始化
  日历活动 穿戴x个y品质铭文
  英雄令英雄收集相关任务
  英雄帖任务简单类型测试
config/develop.lua
@@ -6,6 +6,7 @@ codeurl = "192.168.8.223:9090" @@ -6,6 +6,7 @@ codeurl = "192.168.8.223:9090"
6 servId = 1 6 servId = 1
7 7
8 max_client = 64 8 max_client = 64
  9 +max_queue = 64
9 10
10 server_port = 12001 11 server_port = 12001
11 debug_port = 10001 12 debug_port = 10001
1 XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" 1 XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18"
2 -RESET_TIME = 0 2 +RESET_TIME = 4
3 3
4 -START_RESET_TIME_BASE = 1584316800 -- 0时区 4 +START_RESET_TIME_BASE = 1584316800 + RESET_TIME * 3600 -- 0时区
5 DAY_SEC = 86400 5 DAY_SEC = 86400
6 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 6 TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区
7 7
@@ -256,7 +256,7 @@ SettingStatus = { @@ -256,7 +256,7 @@ SettingStatus = {
256 }, 256 },
257 } 257 }
258 258
259 -EMAIL_LIMIT = 20 --邮件最大数量 259 +EMAIL_LIMIT = 50 --邮件最大数量
260 260
261 RedPointTags = { 261 RedPointTags = {
262 PvpCR = 1, 262 PvpCR = 1,
src/ProtocolCode.lua
@@ -7,6 +7,7 @@ actionCodes = { @@ -7,6 +7,7 @@ actionCodes = {
7 Sys_commonNotice = 5, 7 Sys_commonNotice = 5,
8 Sys_maintainNotice = 6, 8 Sys_maintainNotice = 6,
9 Sys_customNotice = 7, 9 Sys_customNotice = 7,
  10 + Sys_checkQueue = 8,
10 11
11 Gm_clientRequest = 20, 12 Gm_clientRequest = 20,
12 Gm_receiveResponse = 21, 13 Gm_receiveResponse = 21,
@@ -208,6 +209,8 @@ actionCodes = { @@ -208,6 +209,8 @@ actionCodes = {
208 Activity_sudokuRewardRpc = 652, 209 Activity_sudokuRewardRpc = 652,
209 Activity_actSignRpc = 653, 210 Activity_actSignRpc = 653,
210 Activity_actPaySignRewardNtf = 654, 211 Activity_actPaySignRewardNtf = 654,
  212 + Activity_actCalendaTaskRpc = 655,
  213 + Activity_actPaySignRpc = 656,
211 } 214 }
212 215
213 rpcResponseBegin = 10000 216 rpcResponseBegin = 10000
src/actions/ActivityAction.lua
@@ -183,19 +183,21 @@ end @@ -183,19 +183,21 @@ end
183 function _M.actPaySignRpc(agent, data) 183 function _M.actPaySignRpc(agent, data)
184 local role = agent.role 184 local role = agent.role
185 local msg = MsgPack.unpack(data) 185 local msg = MsgPack.unpack(data)
  186 + local dayIndex = msg.day
186 local actGoodsFlag = role.storeData:getProperty("actGoodsFlag") 187 local actGoodsFlag = role.storeData:getProperty("actGoodsFlag")
187 local index = GetActGoodsIndex("paySignIn") 188 local index = GetActGoodsIndex("paySignIn")
188 - local flag = actGoodsFlag[index] or 0  
189 - if flag == 0 then return 1 end 189 + local ts = actGoodsFlag[index] or 0
  190 + if ts == 0 then return 1 end
190 191
191 - if not role.activity:isOpen("PaySignIn") then return 2 end 192 + local open, actId = role.activity:isOpen("PaySignIn")
  193 + if not open then return 2 end
192 194
193 - local diffDay = diffFromOpen() + 1 195 + local diffDay = diffFromTs(ts) + 1
194 196
195 local curData = role.activity:getActData("PaySignIn") 197 local curData = role.activity:getActData("PaySignIn")
196 local reward, change = {} 198 local reward, change = {}
197 for day, csvData in ipairs(csvdb["pay_signInCsv"]) do 199 for day, csvData in ipairs(csvdb["pay_signInCsv"]) do
198 - if day <= diffDay then 200 + if day <= diffDay and day == dayIndex then
199 if not curData[day] then 201 if not curData[day] then
200 curData[day] = 1 202 curData[day] = 1
201 -- 奖励 203 -- 奖励
@@ -203,8 +205,8 @@ function _M.actPaySignRpc(agent, data) @@ -203,8 +205,8 @@ function _M.actPaySignRpc(agent, data)
203 reward[itemId] = (reward[itemId] or 0) + count 205 reward[itemId] = (reward[itemId] or 0) + count
204 end 206 end
205 end 207 end
206 - else  
207 - break 208 + --else
  209 + -- break
208 end 210 end
209 end 211 end
210 if next(reward) then 212 if next(reward) then
@@ -213,7 +215,7 @@ function _M.actPaySignRpc(agent, data) @@ -213,7 +215,7 @@ function _M.actPaySignRpc(agent, data)
213 end 215 end
214 216
215 role:log("activity", { 217 role:log("activity", {
216 - activity_id = curData[0], -- 活动ID(或活动指定任务的ID) 218 + activity_id = actId, -- 活动ID(或活动指定任务的ID)
217 activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 219 activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表
218 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} 220 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
219 }) 221 })
@@ -222,4 +224,42 @@ function _M.actPaySignRpc(agent, data) @@ -222,4 +224,42 @@ function _M.actPaySignRpc(agent, data)
222 return true 224 return true
223 end 225 end
224 226
  227 +function _M.actCalendaTaskRpc(agent, data)
  228 + local role = agent.role
  229 + local msg = MsgPack.unpack(data)
  230 + local taskId = msg.id
  231 + local calTask = role:getProperty("calTask") or {}
  232 + local record = calTask["r"] or {}
  233 + local flag = record[taskId] or 0
  234 + if flag == 1 then return 1 end
  235 + local open, actId = role.activity:isOpen("CalendaTask")
  236 + local actData = csvdb["activity_ctrlCsv"][actId]
  237 + if not open then return 2 end
  238 + if not actData then return 3 end
  239 +
  240 + local taskList = csvdb["activity_taskCsv"][actData.condition]
  241 + if not taskList then return 4 end
  242 + local taskCfg = taskList[taskId]
  243 + if not taskCfg then return 5 end
  244 + if taskCfg.key ~= actData.condition then return 6 end
  245 +
  246 + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end
  247 +
  248 + record[taskId] = 1
  249 + calTask["r"] = record
  250 +
  251 + role:updateProperty({field = "calTask", value = calTask})
  252 +
  253 + local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}})
  254 +
  255 + role:log("activity", {
  256 + activity_id = taskId, -- 活动ID(或活动指定任务的ID)
  257 + activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表
  258 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  259 + })
  260 +
  261 + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change)))
  262 + return true
  263 +end
  264 +
225 return _M 265 return _M
226 \ No newline at end of file 266 \ No newline at end of file
src/actions/AdvAction.lua
@@ -250,7 +250,7 @@ function _M.startHangRpc(agent, data) @@ -250,7 +250,7 @@ function _M.startHangRpc(agent, data)
250 if not role:getAdvData():isRunning() then 250 if not role:getAdvData():isRunning() then
251 role:updateProperty({field = "advTeam", value = {}}) 251 role:updateProperty({field = "advTeam", value = {}})
252 end 252 end
253 - 253 + role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time})
254 role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) 254 role:changeUpdates({{type = "advHang", field = chapterId, value = info}})
255 255
256 role:changeAdvCount(adv_idle_energy) 256 role:changeAdvCount(adv_idle_energy)
@@ -295,6 +295,7 @@ function _M.quickHangRpc(agent, data) @@ -295,6 +295,7 @@ function _M.quickHangRpc(agent, data)
295 info.time = 0 295 info.time = 0
296 role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) 296 role:changeUpdates({{type = "advHang", field = chapterId, value = info}})
297 297
  298 + role:pushCancel({type = "adv", slot = chapterId})
298 role:mylog("adv_action", {desc = "advQuickHang", int1 = chapterId}) 299 role:mylog("adv_action", {desc = "advQuickHang", int1 = chapterId})
299 300
300 SendPacket(actionCodes.Adv_quickHangRpc, '') 301 SendPacket(actionCodes.Adv_quickHangRpc, '')
@@ -371,6 +372,7 @@ function _M.endHangRpc(agent, data) @@ -371,6 +372,7 @@ function _M.endHangRpc(agent, data)
371 -- else 372 -- else
372 -- role:updateProperty({field = "advC", delta = -chapterData.limitlevel}) 373 -- role:updateProperty({field = "advC", delta = -chapterData.limitlevel})
373 -- end 374 -- end
  375 + role:pushCancel({type = "adv", slot = chapterId})
374 else 376 else
375 return 377 return
376 end 378 end
@@ -380,6 +382,8 @@ function _M.endHangRpc(agent, data) @@ -380,6 +382,8 @@ function _M.endHangRpc(agent, data)
380 382
381 role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) 383 role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0})
382 384
  385 + role:checkTaskEnter("AdvHang", {})
  386 +
383 SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) 387 SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull}))
384 return true 388 return true
385 end 389 end
src/actions/DinerAction.lua
@@ -75,6 +75,9 @@ function _M.addSellRpc( agent, data ) @@ -75,6 +75,9 @@ function _M.addSellRpc( agent, data )
75 sells[slot].count = count 75 sells[slot].count = count
76 sells[slot].time = skynet.timex() - calSell.deltaTime 76 sells[slot].time = skynet.timex() - calSell.deltaTime
77 77
  78 + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex()
  79 + role:pushMsg({type = "food", slot = slot, time = needTime})
  80 +
78 -- 检查解锁的顾客 81 -- 检查解锁的顾客
79 local had = {} 82 local had = {}
80 for _, sell in pairs(sells) do 83 for _, sell in pairs(sells) do
@@ -155,6 +158,7 @@ function _M.removeSellRpc( agent, data ) @@ -155,6 +158,7 @@ function _M.removeSellRpc( agent, data )
155 reward, change = role:award(reward, {log = {desc = "removeSell"}}) 158 reward, change = role:award(reward, {log = {desc = "removeSell"}})
156 sells[slot].count = 0 159 sells[slot].count = 0
157 160
  161 + role:pushCancel({type = "food", slot = slot})
158 role:log("restaurant_sale", { 162 role:log("restaurant_sale", {
159 item_id = dish, -- 售卖物品ID 163 item_id = dish, -- 售卖物品ID
160 restaurant_sale_seat = slot, -- 售卖物品所在位置 164 restaurant_sale_seat = slot, -- 售卖物品所在位置
src/actions/HangAction.lua
@@ -22,6 +22,7 @@ local function checkReward(role) @@ -22,6 +22,7 @@ local function checkReward(role)
22 return false 22 return false
23 end 23 end
24 local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] 24 local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
  25 + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
25 local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) 26 local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0)
26 local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) 27 local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0)
27 28
@@ -39,9 +40,9 @@ local function checkReward(role) @@ -39,9 +40,9 @@ local function checkReward(role)
39 40
40 local items = role:getProperty("hangBag") 41 local items = role:getProperty("hangBag")
41 coinCount = coinCount + coinDoubleCount 42 coinCount = coinCount + coinDoubleCount
42 - items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * carbonData.money)  
43 - items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * carbonData.exp)  
44 - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) 43 + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money)
  44 + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp)
  45 + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp)
45 46
46 local pool = {} 47 local pool = {}
47 for _, temp in pairs(carbonData.item:toArray()) do 48 for _, temp in pairs(carbonData.item:toArray()) do
@@ -58,7 +59,8 @@ local function checkReward(role) @@ -58,7 +59,8 @@ local function checkReward(role)
58 59
59 -- 特权卡挂机额外栏位 60 -- 特权卡挂机额外栏位
60 local privExtraCnt = role.storeData:getHangSlotExtraCount() 61 local privExtraCnt = role.storeData:getHangSlotExtraCount()
61 - local selfFC = role:getProperty("hangBagLimit") + privExtraCnt 62 + --local selfFC = role:getProperty("hangBagLimit") + privExtraCnt
  63 + local selfFC = 50
62 local selfIC = selfFC * globalCsv.idle_field_limit 64 local selfIC = selfFC * globalCsv.idle_field_limit
63 65
64 local function randomItem() 66 local function randomItem()
@@ -139,6 +141,7 @@ function _M.startRpc( agent, data ) @@ -139,6 +141,7 @@ function _M.startRpc( agent, data )
139 local hangInfo = role:getProperty("hangInfo") 141 local hangInfo = role:getProperty("hangInfo")
140 local isNew = not hangInfo.carbonId 142 local isNew = not hangInfo.carbonId
141 hangInfo.carbonId = carbonId 143 hangInfo.carbonId = carbonId
  144 + hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId
142 local nowTime = skynet.timex() 145 local nowTime = skynet.timex()
143 if isNew then 146 if isNew then
144 hangInfo.coinTime = nowTime 147 hangInfo.coinTime = nowTime
@@ -149,11 +152,14 @@ function _M.startRpc( agent, data ) @@ -149,11 +152,14 @@ function _M.startRpc( agent, data )
149 hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime) 152 hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime)
150 hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime) 153 hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime)
151 end 154 end
  155 +
  156 + role:pushMsg({type = "hang", time = math.min(hangInfo.endCoinTime - nowTime, hangInfo.endItemTime - nowTime)})
152 if not role:checkHangPass(carbonId) then 157 if not role:checkHangPass(carbonId) then
153 hangInfo.bossTime = nowTime + carbonData.idle_time 158 hangInfo.bossTime = nowTime + carbonData.idle_time
154 else 159 else
155 hangInfo.bossTime = nil 160 hangInfo.bossTime = nil
156 end 161 end
  162 +
157 role:updateProperty({field = "hangInfo", value = hangInfo}) 163 role:updateProperty({field = "hangInfo", value = hangInfo})
158 164
159 -- 指定当前引导的步骤 165 -- 指定当前引导的步骤
@@ -193,12 +199,12 @@ function _M.startBattleRpc(agent, data) @@ -193,12 +199,12 @@ function _M.startBattleRpc(agent, data)
193 return 1 199 return 1
194 end 200 end
195 201
196 - local hangInfo = role:getProperty("hangInfo")  
197 - if curData.main ~= 1 then  
198 - if carbonId ~= hangInfo.carbonId then  
199 - return 2  
200 - end  
201 - end 202 + --local hangInfo = role:getProperty("hangInfo") or {}
  203 + --if curData.main ~= 1 then
  204 + -- if carbonId ~= hangInfo.carbonId then
  205 + -- return 2
  206 + -- end
  207 + --end
202 208
203 if role:checkHangPass(carbonId) then 209 if role:checkHangPass(carbonId) then
204 return 3 210 return 3
@@ -214,7 +220,7 @@ end @@ -214,7 +220,7 @@ end
214 function _M.endBattleRpc(agent, data) 220 function _M.endBattleRpc(agent, data)
215 local role = agent.role 221 local role = agent.role
216 local msg = MsgPack.unpack(data) 222 local msg = MsgPack.unpack(data)
217 - local hangInfo = role:getProperty("hangInfo") 223 + local hangInfo = role:getProperty("hangInfo") or {}
218 if not msg.key or msg.key ~= _BattleKey then 224 if not msg.key or msg.key ~= _BattleKey then
219 SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) 225 SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
220 return true 226 return true
@@ -225,11 +231,12 @@ function _M.endBattleRpc(agent, data) @@ -225,11 +231,12 @@ function _M.endBattleRpc(agent, data)
225 if not carbonData then 231 if not carbonData then
226 return 2 232 return 2
227 end 233 end
228 - if carbonData.main ~= 1 then  
229 - if carbonId ~= hangInfo.carbonId then  
230 - return 3  
231 - end  
232 - end 234 +
  235 + --if carbonData.main ~= 1 then
  236 + -- if carbonId ~= hangInfo.carbonId then
  237 + -- return 3
  238 + -- end
  239 + --end
233 240
234 if role:checkHangPass(carbonId) then 241 if role:checkHangPass(carbonId) then
235 return 4 242 return 4
@@ -273,8 +280,8 @@ function _M.endBattleRpc(agent, data) @@ -273,8 +280,8 @@ function _M.endBattleRpc(agent, data)
273 end 280 end
274 local nextCarbonId = role:getNextCarbonId(carbonId) 281 local nextCarbonId = role:getNextCarbonId(carbonId)
275 -- 设置挂机关卡 282 -- 设置挂机关卡
276 - if isWin and hangInfo.carbonId < nextCarbonId then  
277 - hangInfo.carbonId = nextCarbonId 283 + if isWin and (hangInfo.carbonId or 0) < nextCarbonId then
  284 + hangInfo.expCarbonId = nextCarbonId
278 local cfg = csvdb["idle_battleCsv"][nextCarbonId] 285 local cfg = csvdb["idle_battleCsv"][nextCarbonId]
279 if cfg then 286 if cfg then
280 hangInfo.bossTime = skynet.timex() + cfg.idle_time 287 hangInfo.bossTime = skynet.timex() + cfg.idle_time
@@ -354,7 +361,9 @@ function _M.getRewardRpc(agent , data) @@ -354,7 +361,9 @@ function _M.getRewardRpc(agent , data)
354 hangInfo.itemTime = nowTime 361 hangInfo.itemTime = nowTime
355 role:updateProperty({field = "hangBag", value = items}) 362 role:updateProperty({field = "hangBag", value = items})
356 role:updateProperty({field = "hangInfo", value = hangInfo}) 363 role:updateProperty({field = "hangInfo", value = hangInfo})
357 - role:checkTaskEnter("HangGet") 364 + role:pushMsg({type = "hang", time = globalCsv.idle_producetime_max})
  365 +
  366 + role:checkTaskEnter("HangGet", {reward = reward})
358 if reward[ItemId.Gold] then 367 if reward[ItemId.Gold] then
359 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) 368 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
360 end 369 end
@@ -382,6 +391,7 @@ function _M.quickRpc(agent , data) @@ -382,6 +391,7 @@ function _M.quickRpc(agent , data)
382 local hangInfo = role:getProperty("hangInfo") 391 local hangInfo = role:getProperty("hangInfo")
383 if not hangInfo.carbonId then return end 392 if not hangInfo.carbonId then return end
384 local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] 393 local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]
  394 + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
385 395
386 local curCount = role.dailyData:getProperty("hangQC") + 1 396 local curCount = role.dailyData:getProperty("hangQC") + 1
387 local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") 397 local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=")
@@ -398,9 +408,9 @@ function _M.quickRpc(agent , data) @@ -398,9 +408,9 @@ function _M.quickRpc(agent , data)
398 408
399 local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) 409 local coinCount = math.floor(time / globalCsv.idle_money_produce_cd)
400 local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) 410 local itemCount = math.floor(time / globalCsv.idle_item_produce_cd)
401 - reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money)  
402 - reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp)  
403 - reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) 411 + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money)
  412 + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp)
  413 + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp)
404 414
405 local pool = {} 415 local pool = {}
406 for _, temp in pairs(carbonData.item:toArray()) do 416 for _, temp in pairs(carbonData.item:toArray()) do
src/actions/HeroAction.lua
@@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data ) @@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data )
60 hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) 60 hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")})
61 61
62 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) 62 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
  63 +
  64 + role:checkTaskEnter("HeroLvlCollect", {})
63 SendPacket(actionCodes.Hero_levelUpRpc, '') 65 SendPacket(actionCodes.Hero_levelUpRpc, '')
64 return true 66 return true
65 end 67 end
@@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data) @@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data)
128 }) 130 })
129 131
130 SendPacket(actionCodes.Hero_wakeRpc, '') 132 SendPacket(actionCodes.Hero_wakeRpc, '')
  133 +
  134 + role:checkTaskEnter("HeroStarCollect", {})
131 return true 135 return true
132 end 136 end
133 137
@@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data) @@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data)
595 }) 599 })
596 end 600 end
597 end 601 end
  602 +
  603 + role:checkTaskEnter("RuneQualityCollect", {})
598 604
599 SendPacket(actionCodes.Hero_referRunesRpc, "") 605 SendPacket(actionCodes.Hero_referRunesRpc, "")
600 return true 606 return true
@@ -728,6 +734,13 @@ function _M.drawHeroRpc(agent, data) @@ -728,6 +734,13 @@ function _M.drawHeroRpc(agent, data)
728 if btype ~= 1 then 734 if btype ~= 1 then
729 subType = 1 735 subType = 1
730 end 736 end
  737 +
  738 + if btype == 1 then
  739 + -- 判断定向卡池活动开启
  740 + if not role.activity:isOpen("RaceDraw") then
  741 + return
  742 + end
  743 + end
731 744
732 local buildTypeData = csvdb["build_typeCsv"][btype] 745 local buildTypeData = csvdb["build_typeCsv"][btype]
733 if not buildTypeData then return 2 end 746 if not buildTypeData then return 2 end
@@ -835,7 +848,7 @@ function _M.drawHeroRpc(agent, data) @@ -835,7 +848,7 @@ function _M.drawHeroRpc(agent, data)
835 848
836 local guideHero 849 local guideHero
837 if role:getProperty("newerGuide") == "11=1" then 850 if role:getProperty("newerGuide") == "11=1" then
838 - guideHero = 613 851 + guideHero = globalCsv.newdraw_hero_item_id or 613
839 end 852 end
840 853
841 local ssrCount = 0 854 local ssrCount = 0
src/actions/RoleAction.lua
@@ -121,6 +121,9 @@ function _M.loginRpc( agent, data ) @@ -121,6 +121,9 @@ function _M.loginRpc( agent, data )
121 role:setProperty("device", device) 121 role:setProperty("device", device)
122 end 122 end
123 end 123 end
  124 + if msg.token then
  125 + role._pushToken = msg.token
  126 + end
124 127
125 if not msg.isGMlogin then 128 if not msg.isGMlogin then
126 local banTime = role:getProperty("banTime") 129 local banTime = role:getProperty("banTime")
@@ -550,7 +553,7 @@ function _M.openTimeBoxRpc(agent, data) @@ -550,7 +553,7 @@ function _M.openTimeBoxRpc(agent, data)
550 if boxL[slot] then return end 553 if boxL[slot] then return end
551 role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}}) 554 role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}})
552 boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} 555 boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime}
553 - 556 + role:pushMsg({type = "box", slot = slot, time = randomData.openTime})
554 elseif oper == 2 then -- 领取 557 elseif oper == 2 then -- 领取
555 local quick = msg.quick 558 local quick = msg.quick
556 if not boxL[slot] then return end 559 if not boxL[slot] then return end
@@ -561,6 +564,7 @@ function _M.openTimeBoxRpc(agent, data) @@ -561,6 +564,7 @@ function _M.openTimeBoxRpc(agent, data)
561 costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] 564 costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2]
562 if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end 565 if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end
563 role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) 566 role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}})
  567 + role:pushCancel({type = "box", slot = slot})
564 end 568 end
565 local boxId = boxL[slot].id 569 local boxId = boxL[slot].id
566 local itemData = csvdb["itemCsv"][boxId] 570 local itemData = csvdb["itemCsv"][boxId]
@@ -615,52 +619,57 @@ end @@ -615,52 +619,57 @@ end
615 function _M.openSpeedUpBoxRpc(agent, data) 619 function _M.openSpeedUpBoxRpc(agent, data)
616 local role = agent.role 620 local role = agent.role
617 local msg = MsgPack.unpack(data) 621 local msg = MsgPack.unpack(data)
618 -  
619 - local id = msg.id  
620 - local count = msg.count  
621 - local itemData = csvdb["itemCsv"][id]  
622 - if not itemData or itemData.type ~= ItemType.SpeedBox then return end  
623 -  
624 - if math.illegalNum(count, 1, role:getItemCount(id)) then return end  
625 - local useType, hour = table.unpack(itemData.use_effect:toArray(true, "="))  
626 - local time = hour * 60 * 60 622 + local itemInfo = msg.itemInfo
627 623
628 local reward = {} 624 local reward = {}
629 - if useType == 1 then -- 挂机齿轮  
630 - local hangInfo = role:getProperty("hangInfo")  
631 - if not hangInfo.carbonId then  
632 - return  
633 - end  
634 - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]  
635 - reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count  
636 - elseif useType == 2 then -- 挂机经验  
637 - local hangInfo = role:getProperty("hangInfo")  
638 - if not hangInfo.carbonId then  
639 - return  
640 - end  
641 - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId]  
642 - reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count  
643 - elseif useType == 3 then -- 食材商人收入  
644 - local buildType = 6  
645 - local level = role.dinerData:getProperty("buildL"):getv(buildType, 1)  
646 - local buildingData = csvdb["diner_buildingCsv"][buildType][level]  
647 - if not buildingData then  
648 - return 1  
649 - end  
650 - local gfood = role.dinerData:getProperty("gfood")  
651 - if not next(gfood) then return end  
652 - for k , v in pairs(gfood) do  
653 - local itemId = v.id  
654 - local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100  
655 - reward[itemId] = math.floor(time / speed) * count 625 + for i = 1, #itemInfo do
  626 + local pair = itemInfo[i]
  627 + local id = pair[1]
  628 + local count = pair[2]
  629 + local itemData = csvdb["itemCsv"][id]
  630 + if not itemData or itemData.type ~= ItemType.SpeedBox then return end
  631 +
  632 + if math.illegalNum(count, 1, role:getItemCount(id)) then return 1 end
  633 + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "="))
  634 + local time = hour * 60 * 60
  635 +
  636 + if useType == 1 then -- 挂机齿轮
  637 + local hangInfo = role:getProperty("hangInfo")
  638 + if not hangInfo.expCarbonId then
  639 + return 2
  640 + end
  641 + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
  642 + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count
  643 + elseif useType == 2 then -- 挂机经验
  644 + local hangInfo = role:getProperty("hangInfo")
  645 + if not hangInfo.expCarbonId then
  646 + return 3
  647 + end
  648 + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId]
  649 + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count
  650 + elseif useType == 3 then -- 食材商人收入
  651 + local buildType = 6
  652 + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1)
  653 + local buildingData = csvdb["diner_buildingCsv"][buildType][level]
  654 + if not buildingData then
  655 + return 4
  656 + end
  657 + local gfood = role.dinerData:getProperty("gfood")
  658 + if not next(gfood) then return 5 end
  659 + for k , v in pairs(gfood) do
  660 + local itemId = v.id
  661 + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100
  662 + reward[itemId] = (reward[itemId] or 0) + math.floor((time / speed) * count)
  663 + end
  664 + else
  665 + return 6
656 end 666 end
657 - else  
658 - return 667 +
  668 + role:costItems({[id] = count}, {log = {desc = "speedUpBox"}})
659 end 669 end
660 670
661 - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}})  
662 local change 671 local change
663 - reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) 672 + reward, change = role:award(reward, {log = {desc = "speedUpBox"}})
664 673
665 SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) 674 SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change)))
666 return true 675 return true
1 -Subproject commit 9bb26cfdb11f81dbfe6abbc468b44ca9f814deb2 1 +Subproject commit 29d26c6e3083676ddaa828f8d0b22cd1d0ee48cf
1 local skynet = require "skynet" 1 local skynet = require "skynet"
2 2
3 local max_client = tonumber(skynet.getenv("max_client")) 3 local max_client = tonumber(skynet.getenv("max_client"))
  4 +local max_queue = tonumber(skynet.getenv("max_queue"))
4 5
5 skynet.start(function() 6 skynet.start(function()
6 print("Server start") 7 print("Server start")
@@ -11,7 +12,7 @@ skynet.start(function() @@ -11,7 +12,7 @@ skynet.start(function()
11 12
12 skynet.call(watchdog, "lua", "start", { 13 skynet.call(watchdog, "lua", "start", {
13 port = tonumber(skynet.getenv("server_port")), 14 port = tonumber(skynet.getenv("server_port")),
14 - maxclient = max_client, 15 + maxclient = max_client + max_queue + 10,
15 httpd = httpd, 16 httpd = httpd,
16 17
17 redishost = skynet.getenv("redis_host"), 18 redishost = skynet.getenv("redis_host"),
src/models/Activity.lua
@@ -18,6 +18,7 @@ Activity.ActivityType = { @@ -18,6 +18,7 @@ Activity.ActivityType = {
18 DrawHero = 12, --抽卡周 招募 18 DrawHero = 12, --抽卡周 招募
19 AdvDraw = 13, --拾荒抽周 资助 19 AdvDraw = 13, --拾荒抽周 资助
20 OpenBox = 14, --拆解周 时钟箱 20 OpenBox = 14, --拆解周 时钟箱
  21 + RaceDraw = 15, -- 定向招募活动
21 } 22 }
22 23
23 24
@@ -344,8 +345,9 @@ activityFunc[Activity.ActivityType.PaySignIn] = { @@ -344,8 +345,9 @@ activityFunc[Activity.ActivityType.PaySignIn] = {
344 ["init"] = function(self, actType, isCrossDay, notify) 345 ["init"] = function(self, actType, isCrossDay, notify)
345 self:updateActData(actType, {}, not notify) 346 self:updateActData(actType, {}, not notify)
346 end, 347 end,
347 - -- ["close"] = function(self, actType, notify)  
348 - -- end, 348 + ["close"] = function(self, actType, notify)
  349 + self.owner.storeData:SetActGoodsFlag("paySignIn", 0)
  350 + end,
349 } 351 }
350 352
351 -- 充值反馈 353 -- 充值反馈
@@ -367,6 +369,37 @@ activityFunc[Activity.ActivityType.PayBack] = { @@ -367,6 +369,37 @@ activityFunc[Activity.ActivityType.PayBack] = {
367 -- end, 369 -- end,
368 } 370 }
369 371
  372 +-- 英雄帖
  373 +activityFunc[Activity.ActivityType.CalendaTask] = {
  374 + ["init"] = function(self, actType, isCrossDay, notify)
  375 + local calTask = self.owner:getProperty("CalTask")
  376 + calTask = {}
  377 + local role = self.owner
  378 + local buildL = role.dinerData:getProperty("buildL")
  379 + local curLevel = buildL:getv(1, 1)
  380 + role:checkTaskEnter("DinerLevelUp", {level = curLevel})
  381 +
  382 + role:checkTaskEnter("HeroLvlCollect", {})
  383 + role:checkTaskEnter("HeroQualityCollect", {})
  384 +
  385 + local curPopular = role.dinerData:getProperty("popular")
  386 + role:checkTaskEnter("DinerPopular", {count = curPopular})
  387 +
  388 + local rLevel = role:getProperty("level")
  389 + role:checkTaskEnter("RoleLevelUp", {level = rLevel})
  390 +
  391 + local towerInfo = role:getProperty("towerInfo")
  392 + role:checkTaskEnter("TowerPass", {level = towerInfo.l})
  393 + --"PvpWin"
  394 + role:checkTaskEnter("HangPass", {})
  395 + role:checkTaskEnter("HeroStarCollect", {})
  396 + role:checkTaskEnter("RuneQualityCollect", {})
  397 +
  398 + end,
  399 + -- ["close"] = function(self, actType, notify)
  400 + -- end,
  401 +}
  402 +
370 function Activity:initActivity(actId, isCrossDay, notify) 403 function Activity:initActivity(actId, isCrossDay, notify)
371 local actData = csvdb["activity_ctrlCsv"][actId] 404 local actData = csvdb["activity_ctrlCsv"][actId]
372 if not actData then return end 405 if not actData then return end
src/models/Diner.lua
@@ -298,6 +298,9 @@ function Diner:expediteSell(slot) @@ -298,6 +298,9 @@ function Diner:expediteSell(slot)
298 self:checkDinerTask(DinerTask.SellDishType, expediteCount, math.ceil(sell.dish / 100)) 298 self:checkDinerTask(DinerTask.SellDishType, expediteCount, math.ceil(sell.dish / 100))
299 self:checkDinerTask(DinerTask.SellDishRare, expediteCount, dishData.rarity) 299 self:checkDinerTask(DinerTask.SellDishRare, expediteCount, dishData.rarity)
300 self.owner:checkTaskEnter("FoodSell", {count = expediteCount}) 300 self.owner:checkTaskEnter("FoodSell", {count = expediteCount})
  301 +
  302 + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex()
  303 + self.owner:pushMsg({type = "food", slot = slot, time = needTime})
301 end 304 end
302 return { 305 return {
303 expediteCount = expediteCount, 306 expediteCount = expediteCount,
src/models/Role.lua
@@ -27,6 +27,7 @@ function Role:ctor( properties ) @@ -27,6 +27,7 @@ function Role:ctor( properties )
27 self.runeBag = {} 27 self.runeBag = {}
28 self.advData = nil 28 self.advData = nil
29 self.activity = nil 29 self.activity = nil
  30 + self._pushToken = nil
30 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 31 self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
31 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 32 self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
32 if self.advOverTime == 0 then 33 if self.advOverTime == 0 then
@@ -174,6 +175,8 @@ Role.schema = { @@ -174,6 +175,8 @@ Role.schema = {
174 175
175 downCvR = {"number", 0}, -- 下载cv扩展包奖励 176 downCvR = {"number", 0}, -- 下载cv扩展包奖励
176 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 177 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数
  178 +
  179 + calTask = {"table", {}}, -- 英雄令活动 日历任务活动
177 } 180 }
178 181
179 182
@@ -395,6 +398,7 @@ function Role:data() @@ -395,6 +398,7 @@ function Role:data()
395 downCvR = self:getProperty("downCvR"), -- 下载cv扩展包奖励 398 downCvR = self:getProperty("downCvR"), -- 下载cv扩展包奖励
396 feedback = self:getProperty("feedback"), 399 feedback = self:getProperty("feedback"),
397 ctime = self:getProperty("ctime"), 400 ctime = self:getProperty("ctime"),
  401 + calTask = self:getProperty("calTask"),
398 } 402 }
399 end 403 end
400 404
src/models/RoleLog.lua
@@ -81,6 +81,7 @@ local ItemReason = { @@ -81,6 +81,7 @@ local ItemReason = {
81 birth = 1006, -- 出生奖励 81 birth = 1006, -- 出生奖励
82 actSign = 1007, -- 活动签到 82 actSign = 1007, -- 活动签到
83 actPaySign = 1008, -- 活动付费签到 83 actPaySign = 1008, -- 活动付费签到
  84 + calendaTask = 1009, -- 英雄帖
84 85
85 -- 餐厅 86 -- 餐厅
86 greenHourse = 1101, -- 食材获得 87 greenHourse = 1101, -- 食材获得
src/models/RolePlugin.lua
@@ -453,6 +453,7 @@ function RolePlugin.bind(Role) @@ -453,6 +453,7 @@ function RolePlugin.bind(Role)
453 newHero:saveBattleValue() 453 newHero:saveBattleValue()
454 self.heros[heroId] = newHero 454 self.heros[heroId] = newHero
455 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) 455 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify)
  456 + self:checkTaskEnter("HeroQualityCollect", {})
456 if not params.notNotify then 457 if not params.notNotify then
457 local heroResponse = {} 458 local heroResponse = {}
458 table.insert(heroResponse, newHero:data()) 459 table.insert(heroResponse, newHero:data())
@@ -1742,7 +1743,36 @@ function RolePlugin.bind(Role) @@ -1742,7 +1743,36 @@ function RolePlugin.bind(Role)
1742 end) 1743 end)
1743 return gift, checkPoint 1744 return gift, checkPoint
1744 end 1745 end
  1746 + --[[
  1747 + "hang" : "挂机资源满",
  1748 + "box" : "箱子拆解完毕",
  1749 + "food" : "食物出售完毕",
  1750 + "adv" : "代理拾荒完毕",
  1751 + --]]
  1752 + function Role:pushMsg(params)
  1753 + if not self._pushToken or self._pushToken == "" then return end
  1754 + if params.time <= 0 then
  1755 + self:pushCancel(params)
  1756 + return
  1757 + end
  1758 + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken)
  1759 + notifyClient({content = content, time = math.floor(params.time)})
  1760 + end
1745 1761
  1762 + function Role:pushCancel(params)
  1763 + if not self._pushToken or self._pushToken == "" then return end
  1764 + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken)
  1765 + deleteNotify({content = content})
  1766 + end
  1767 +
  1768 + function Role:pushCancelAll(ptype)
  1769 + if not self._pushToken or self._pushToken == "" then return end
  1770 + local pattern = string.format("push:%d:*", self:getProperty("id"))
  1771 + if ptype then
  1772 + pattern = string.format("push:%d:%s:*", self:getProperty("id"), ptype)
  1773 + end
  1774 + deleteNotify({pattern = pattern})
  1775 + end
1746 end 1776 end
1747 1777
1748 return RolePlugin 1778 return RolePlugin
1749 \ No newline at end of file 1779 \ No newline at end of file
src/models/RoleTask.lua
@@ -255,11 +255,11 @@ local CalendaTaskListener = { @@ -255,11 +255,11 @@ local CalendaTaskListener = {
255 [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, 255 [TaskType.RoleLevelUp]= {{12, 2, f("level")}},
256 [TaskType.TowerPass]= {{13, 2, f("level")}}, 256 [TaskType.TowerPass]= {{13, 2, f("level")}},
257 [TaskType.HeroTalent]= {{14, 1}}, 257 [TaskType.HeroTalent]= {{14, 1}},
258 - [TaskType.HangPass]= {{15, 2, f("id")}}, 258 + [TaskType.HangPass]= {{15, 3}},
259 [TaskType.HeroStarCollect]= {{16, 3}}, 259 [TaskType.HeroStarCollect]= {{16, 3}},
260 [TaskType.FoodSell]= {{17, 1, f("count")}}, 260 [TaskType.FoodSell]= {{17, 1, f("count")}},
261 [TaskType.HangGet]= {{18, 3, f("reward")}}, 261 [TaskType.HangGet]= {{18, 3, f("reward")}},
262 - [TaskType.RuneQualityCollect]= {{19, 3, f("id")}}, 262 + [TaskType.RuneQualityCollect]= {{19, 3}},
263 [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, 263 [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}},
264 } 264 }
265 } 265 }
@@ -272,6 +272,7 @@ local TaskListeners = { @@ -272,6 +272,7 @@ local TaskListeners = {
272 SudokuListener, 272 SudokuListener,
273 ActivityListener, 273 ActivityListener,
274 StoreListener, 274 StoreListener,
  275 + CalendaTaskListener,
275 } 276 }
276 277
277 local RoleTask = {} 278 local RoleTask = {}
@@ -587,6 +588,8 @@ function RoleTask.bind(Role) @@ -587,6 +588,8 @@ function RoleTask.bind(Role)
587 end 588 end
588 589
589 function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) 590 function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2)
  591 + --print("check calenda taskl", mainType, subType, param1, param2)
  592 + if not self.activity then return end
590 local open, actId = self.activity:isOpen("CalendaTask") 593 local open, actId = self.activity:isOpen("CalendaTask")
591 local actData = csvdb["activity_ctrlCsv"][actId] 594 local actData = csvdb["activity_ctrlCsv"][actId]
592 if not actData then return end 595 if not actData then return end
@@ -606,11 +609,86 @@ function RoleTask.bind(Role) @@ -606,11 +609,86 @@ function RoleTask.bind(Role)
606 elseif subType == 2 then -- 直接赋值 609 elseif subType == 2 then -- 直接赋值
607 calTask[id] = param1 610 calTask[id] = param1
608 elseif subType == 3 then -- 自定义类型 611 elseif subType == 3 then -- 自定义类型
  612 + if cfg.type == 7 then -- 英雄品质收集进度
  613 + local count = 0
  614 + for _, hero in pairs(self.heros) do
  615 + local unitData = csvdb["unitCsv"][hero:getProperty("type")]
  616 + if unitData then
  617 + if cfg.condition2 <= unitData.rare then
  618 + count = count + 1
  619 + end
  620 + end
  621 + end
  622 + if (calTask[id] or 0) < count then
  623 + calTask[id] = count
  624 + end
  625 + elseif cfg.type == 5 then -- 英雄等级收集进度
  626 + local count = 0
  627 + for _, hero in pairs(self.heros) do
  628 + if cfg.condition2 <= hero:getProperty("level") then
  629 + count = count + 1
  630 + end
  631 + end
  632 + if calTask[id] < count then
  633 + calTask[id] = count
  634 + end
  635 + elseif cfg.type == 16 then -- 英雄星级收集进度
  636 + local count = 0
  637 + for _, hero in pairs(self.heros) do
  638 + if cfg.condition2 <= hero:getProperty("wakeL") then
  639 + count = count + 1
  640 + end
  641 + end
  642 + if calTask[id] < count then
  643 + calTask[id] = count
  644 + end
  645 + elseif cfg.type == 18 then -- 挂机累计收获id,y个
  646 + for rid, v in pairs(param1) do
  647 + if cfg.condition2 == rid then
  648 + calTask[id] = (calTask[id] or 0) + v
  649 + end
  650 + end
  651 + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装
  652 + local count = 0
  653 + for _, hero in pairs(self.heros) do
  654 + local rcount = 0
  655 + for _,uid in pairs(hero:getRunes()) do
  656 + if uid > 0 then
  657 + local runeData = self.runeBag[uid]
  658 + if runeData then
  659 + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")]
  660 +
  661 + if csvData and cfg.condition2 <= csvData.rarity then
  662 + rcount = rcount + 1
  663 + end
  664 + end
  665 + end
  666 + end
  667 + if rcount == 6 then
  668 + count = count + 1
  669 + end
  670 + end
  671 + calTask[id] = count
  672 + elseif cfg.type == 20 then -- 开启x品质时钟箱子
  673 + if cfg.condition2 <= (param2 or 0) then
  674 + calTask[id] = (calTask[id] or 0) + param2
  675 + end
  676 + elseif cfg.type == 15 then -- 通关关卡
  677 + if (calTask[id] or 0) == 0 then
  678 + local hangPass = self:getProperty("hangPass")
  679 + local diff = math.floor(cfg.condition2 / 10000)
  680 + if (hangPass[diff] or 0) >= cfg.condition1 then
  681 + calTask[id] = 1
  682 + end
  683 + end
  684 + end
609 end 685 end
610 end 686 end
611 end 687 end
612 end 688 end
613 end 689 end
  690 + self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify})
  691 + --dump(calTask)
614 end 692 end
615 693
616 end 694 end
src/models/Store.lua
@@ -57,7 +57,7 @@ end @@ -57,7 +57,7 @@ end
57 function Store:onCrossDay() 57 function Store:onCrossDay()
58 self:sendMonthCardEmail() 58 self:sendMonthCardEmail()
59 self:deleteExpireLimitGoods() 59 self:deleteExpireLimitGoods()
60 - self:checkPaySignReward() 60 + --self:checkPaySignReward()
61 end 61 end
62 62
63 -- 删除过期商品 63 -- 删除过期商品
@@ -356,32 +356,46 @@ function GetActGoodsIndex(goodsType) @@ -356,32 +356,46 @@ function GetActGoodsIndex(goodsType)
356 return ActGoodsType[goodsType] or 0 356 return ActGoodsType[goodsType] or 0
357 end 357 end
358 358
359 --- 购买付费签到 按开服时间算奖励  
360 -function Store:onBuyPaySignCard(dur)  
361 - local curTs = skynet.timex() 359 +function Store:SetActGoodsFlag(goodsType, flag)
362 local actGoodsFlag = self:getProperty("actGoodsFlag") or {} 360 local actGoodsFlag = self:getProperty("actGoodsFlag") or {}
363 - local goodsIndex = GetActGoodsIndex("paySignIn") 361 + local goodsIndex = GetActGoodsIndex(goodsType)
364 if goodsIndex == 0 then 362 if goodsIndex == 0 then
365 print("get act goods index fail :paySignIn") 363 print("get act goods index fail :paySignIn")
366 return 364 return
367 end 365 end
368 - actGoodsFlag[goodsIndex] = 1 366 + actGoodsFlag[goodsIndex] = flag
369 self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) 367 self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag})
370 - -- 发钱  
371 - local change  
372 - local reward, curData = self.owner.activity:getPaySignReward()  
373 - if next(reward) then  
374 - self.owner.activity:updateActData("PaySignIn", curData)  
375 - reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}})  
376 - end 368 +end
  369 +
  370 +-- 购买付费签到 按开服时间算奖励
  371 +function Store:onBuyPaySignCard(dur)
  372 + local curTs = skynet.timex()
377 373
378 - self.owner:log("activity", {  
379 - activity_id = 0, -- 活动ID(或活动指定任务的ID)  
380 - activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表  
381 - activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}  
382 - }) 374 + self:SetActGoodsFlag("paySignIn", curTs)
383 375
384 - SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) 376 + --local actGoodsFlag = self:getProperty("actGoodsFlag") or {}
  377 + --local goodsIndex = GetActGoodsIndex("paySignIn")
  378 + --if goodsIndex == 0 then
  379 + -- print("get act goods index fail :paySignIn")
  380 + -- return
  381 + --end
  382 + --actGoodsFlag[goodsIndex] = 1
  383 + --self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag})
  384 + -- 发钱
  385 + --local change
  386 + --local reward, curData = self.owner.activity:getPaySignReward()
  387 + --if next(reward) then
  388 + -- self.owner.activity:updateActData("PaySignIn", curData)
  389 + -- reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}})
  390 + --end
  391 +
  392 + --self.owner:log("activity", {
  393 + -- activity_id = 0, -- 活动ID(或活动指定任务的ID)
  394 + -- activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表
  395 + -- activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  396 + --})
  397 +
  398 + --SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change)))
385 end 399 end
386 400
387 function Store:checkPaySignReward() 401 function Store:checkPaySignReward()
src/services/agent_ctrl.lua
@@ -58,7 +58,14 @@ function _M:exit_agent(fd) @@ -58,7 +58,14 @@ function _M:exit_agent(fd)
58 local agent = get_a(pack) 58 local agent = get_a(pack)
59 59
60 pcall(skynet.send, agent, "lua", "exit") 60 pcall(skynet.send, agent, "lua", "exit")
61 - pcall(skynet.send, poold, "lua", "feed") 61 +
  62 + -- 这里检查是否有排队用户
  63 + local nuid, nfd = skynet.call(queued_serv, "lua", "pop")
  64 + if not nuid then
  65 + pcall(skynet.send, poold, "lua", "feed")
  66 + else
  67 + self:query_agent(nfd, nuid, true)
  68 + end
62 69
63 self.f2u[fd] = nil 70 self.f2u[fd] = nil
64 self.u2f[uid] = nil 71 self.u2f[uid] = nil
@@ -73,7 +80,11 @@ end @@ -73,7 +80,11 @@ end
73 function _M:socket_close(fd) 80 function _M:socket_close(fd)
74 self.f2i[fd] = nil 81 self.f2i[fd] = nil
75 local uid = self.f2u[fd] 82 local uid = self.f2u[fd]
76 - if not uid then return end 83 + if not uid then
  84 + -- 排队中?
  85 + pcall(skynet.call, queued_serv, "lua", "socket_close", fd)
  86 + return
  87 + end
77 self.f2e[fd] = skynet.timex() + AGENT_EXPIRE_TIME 88 self.f2e[fd] = skynet.timex() + AGENT_EXPIRE_TIME
78 89
79 if not self.u2f[uid] then 90 if not self.u2f[uid] then
@@ -89,7 +100,11 @@ end @@ -89,7 +100,11 @@ end
89 function _M:socket_error(fd) 100 function _M:socket_error(fd)
90 self.f2i[fd] = nil 101 self.f2i[fd] = nil
91 local uid = self.f2u[fd] 102 local uid = self.f2u[fd]
92 - if not uid then return end 103 + if not uid then
  104 + -- 排队中?
  105 + pcall(skynet.call, queued_serv, "lua", "socket_close", fd)
  106 + return
  107 + end
93 108
94 if not self.u2f[uid] then 109 if not self.u2f[uid] then
95 self.f2u[fd] = nil 110 self.f2u[fd] = nil
@@ -151,7 +166,7 @@ local function query_agent_response(fd, response) @@ -151,7 +166,7 @@ local function query_agent_response(fd, response)
151 end 166 end
152 167
153 -- @desc: 玩家登陆第一个包,queryLogin,watchdog为客户端分配一个agent,并告诉gate分配成功,之后的消息直接走agent 168 -- @desc: 玩家登陆第一个包,queryLogin,watchdog为客户端分配一个agent,并告诉gate分配成功,之后的消息直接走agent
154 -function _M:query_agent(fd, uid) 169 +function _M:query_agent(fd, uid, isQueue)
155 local pack = self.u2f[uid] 170 local pack = self.u2f[uid]
156 if pack then 171 if pack then
157 local f = get_f(pack) 172 local f = get_f(pack)
@@ -159,7 +174,6 @@ function _M:query_agent(fd, uid) @@ -159,7 +174,6 @@ function _M:query_agent(fd, uid)
159 skynet.error(string.format("%s same fd %d", uid, fd)) 174 skynet.error(string.format("%s same fd %d", uid, fd))
160 return 175 return
161 end 176 end
162 -  
163 -- self.f2u[f] 肯定存在;self.f2e[f]不存在,则说明在线,则需要踢下线 177 -- self.f2u[f] 肯定存在;self.f2e[f]不存在,则说明在线,则需要踢下线
164 if not self.f2e[f] then 178 if not self.f2e[f] then
165 local head = string.pack("H", actionCodes.Sys_maintainNotice) 179 local head = string.pack("H", actionCodes.Sys_maintainNotice)
@@ -183,11 +197,18 @@ function _M:query_agent(fd, uid) @@ -183,11 +197,18 @@ function _M:query_agent(fd, uid)
183 self.u2f[uid] = set_pack(fd, agent) 197 self.u2f[uid] = set_pack(fd, agent)
184 else 198 else
185 -- 该uid未存储,则说明至少超过10分钟未登陆,由agent池服务pop出一个agent 199 -- 该uid未存储,则说明至少超过10分钟未登陆,由agent池服务pop出一个agent
186 - local agent = self.factory:pop()  
187 - if not agent then  
188 - -- 服务器满  
189 - query_agent_response(fd, {ret = "RET_SERVER_FULL"})  
190 - return 200 + local agent
  201 + if isQueue then
  202 + agent = skynet.newservice("agent")
  203 + else
  204 + agent = self.factory:pop()
  205 + if not agent then
  206 + -- 服务器满
  207 + -- 开始排队
  208 + local ok, rank = pcall(skynet.call, queued_serv, "lua", "push", uid, fd)
  209 + query_agent_response(fd, {ret = "RET_SERVER_FULL", rank = rank})
  210 + return
  211 + end
191 end 212 end
192 213
193 local ok = pcall(skynet.call, agent, "lua", "start", gate_serv, fd, self.f2i[fd], hotfixList) 214 local ok = pcall(skynet.call, agent, "lua", "start", gate_serv, fd, self.f2i[fd], hotfixList)
src/services/poold.lua
@@ -7,14 +7,15 @@ local deque = require &quot;deque&quot; @@ -7,14 +7,15 @@ local deque = require &quot;deque&quot;
7 local CMD = {} 7 local CMD = {}
8 local factory 8 local factory
9 9
  10 +local PRE_FEED_COUNT = 1
10 local dead = 0 11 local dead = 0
11 -- agent死亡,通知poold补充,当累计到5个agent时,马上生成5个agent放入poold中 12 -- agent死亡,通知poold补充,当累计到5个agent时,马上生成5个agent放入poold中
12 -- 当然这里也可以写得更复杂,参考redis落地规则 13 -- 当然这里也可以写得更复杂,参考redis落地规则
13 function CMD.feed() 14 function CMD.feed()
14 dead = dead + 1 15 dead = dead + 1
15 - if dead == 5 then 16 + if dead == PRE_FEED_COUNT then
16 dead = 0 17 dead = 0
17 - for i=1, 5 do 18 + for i=1, PRE_FEED_COUNT do
18 factory:push(skynet.newservice("agent")) 19 factory:push(skynet.newservice("agent"))
19 end 20 end
20 end 21 end
src/services/queued.lua 0 → 100644
@@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
  1 +-- 排队系统
  2 +
  3 +require "ProtocolCode"
  4 +require "shared.init"
  5 +require "utils.init"
  6 +require "GlobalVar"
  7 +require "RedisKeys"
  8 +require "skynet.manager"
  9 +
  10 +local queue = require "skynet.queue"
  11 +local netpack = require "skynet.netpack"
  12 +local socket = require "skynet.socket"
  13 +local xxtea = require "xxtea"
  14 +
  15 +skynet = require "skynet"
  16 +
  17 +local MAX_COUNT = tonumber(skynet.getenv("max_queue"))
  18 +-- 心跳定时间隔
  19 +local HEART_TIMER_INTERVAL = 30
  20 +local HEART_TIMEOUT_COUNT_MAX = 3
  21 +local gate_serv
  22 +
  23 +local CMD = {}
  24 +local f2u = {}
  25 +local u2i = {} -- {idx, fd, {lastHeart, timeOutCount, nextCheck}}
  26 +local idx2u = {}
  27 +local curIdx = 0 -- 下一个即将进入游戏的玩家索引
  28 +local nextIdx = 0 -- 新加的位置
  29 +
  30 +
  31 +
  32 +local function getRank(uid)
  33 + local info = u2i[uid]
  34 + if not info then return -1 end
  35 + return (info[1] + MAX_COUNT - curIdx) % MAX_COUNT + 1
  36 +end
  37 +
  38 +
  39 +function SendPacket(actionCode, bin, client_fd)
  40 + if #bin > 0 then bin = xxtea.encrypt(bin, XXTEA_KEY) end
  41 + local head = string.pack("H", actionCode)
  42 + return socket.write(client_fd, netpack.pack(head .. bin))
  43 +end
  44 +
  45 +local function checkQueue(fd)
  46 + if not f2u[fd] then return end
  47 + local info = u2i[f2u[fd]]
  48 + if info then
  49 + info[3][1] = skynet.timex()
  50 + end
  51 + local rank = getRank(f2u[fd])
  52 + SendPacket(actionCodes.Sys_checkQueue, MsgPack.pack({rank = rank}), fd)
  53 +end
  54 +
  55 +
  56 +skynet.register_protocol {
  57 + name = "client",
  58 + id = skynet.PTYPE_CLIENT,
  59 + unpack = function (msg, sz)
  60 + local data = skynet.tostring(msg, sz)
  61 + local cmd = string.unpack("H", string.sub(data, 1, 2))
  62 + return cmd, string.sub(data, 3)
  63 + end,
  64 + dispatch = function(session, address, cmd, data)
  65 + skynet.ignoreret()
  66 + cs(function()
  67 + if cmd == actionCodes.Sys_checkQueue then
  68 + checkQueue(session)
  69 + end
  70 + end)
  71 + end
  72 +}
  73 +
  74 +function CMD.open(serv)
  75 + gate_serv = serv
  76 +end
  77 +
  78 +function CMD.push(uid, fd)
  79 + uid = tostring(uid)
  80 + if u2i[uid] then -- 存在]
  81 + local oldfd = u2i[uid][2]
  82 + if oldfd and oldfd ~= fd then
  83 + -- 踢掉老的
  84 + SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({body = "server_accountOccupied", iskey = true}), oldfd)
  85 + skynet.timeout(10, function ()
  86 + skynet.call(gate_serv, "lua", "kick", oldfd)
  87 + end)
  88 + f2u[oldfd] = nil
  89 + end
  90 + u2i[uid][2] = fd
  91 + f2u[fd] = uid
  92 + u2i[uid][3] = {skynet.timex(), 0, skynet.timex() + HEART_TIMER_INTERVAL}
  93 + else -- 新排队的用户
  94 + if nextIdx == curIdx and next(idx2u) then -- 满了
  95 + return
  96 + end
  97 + u2i[uid] = {nextIdx, fd, {skynet.timex(), 0, skynet.timex() + HEART_TIMER_INTERVAL}}
  98 + f2u[fd] = uid
  99 + idx2u[nextIdx] = uid
  100 + nextIdx = (nextIdx + 1) % MAX_COUNT
  101 + end
  102 + skynet.call(gate_serv, "lua", "forward", fd, 0, skynet.self())
  103 +
  104 + return getRank(uid)
  105 +end
  106 +
  107 +function CMD.pop()
  108 + while true do
  109 + local uid = idx2u[curIdx]
  110 + if not uid then return end -- 空的
  111 + local info = u2i[uid]
  112 + if not info then
  113 + idx2u[curIdx] = nil
  114 + else
  115 + if info[2] then
  116 + -- 找到合适的了
  117 + u2i[uid] = nil
  118 + idx2u[curIdx] = nil
  119 + f2u[info[2]] = nil
  120 +
  121 + curIdx = (curIdx + 1) % MAX_COUNT
  122 + return uid, info[2]
  123 + else
  124 + idx2u[curIdx] = nil
  125 + u2i[uid] = nil
  126 + end
  127 + end
  128 + curIdx = (curIdx + 1) % MAX_COUNT
  129 + end
  130 +end
  131 +
  132 +-- 下线了
  133 +function CMD.socket_close(fd)
  134 + local uid = f2u[fd]
  135 + if not uid then return end
  136 + f2u[fd] = nil
  137 + local info = u2i[uid]
  138 + info[2] = nil
  139 +end
  140 +
  141 +
  142 +local function handle_timeout()
  143 + local now = skynet.timex()
  144 + for uid, info in pairs(u2i) do
  145 + if info[2] and info[3] and now >= info[3][3] then --存在fd 检查心跳
  146 + if info[3][1] - now > HEART_TIMER_INTERVAL or now - info[3][1] > HEART_TIMER_INTERVAL then
  147 + info[3][2] = info[3][2] + 1
  148 + info[3][3] = now + HEART_TIMER_INTERVAL
  149 + if info[3][2] >= HEART_TIMEOUT_COUNT_MAX then
  150 + skynet.error("timeout! then queued will closed", info[2], uid)
  151 + skynet.call(gate_serv, "lua", "kick", info[2])
  152 + end
  153 + end
  154 + end
  155 + end
  156 + skynet.timeout(100, handle_timeout)
  157 +end
  158 +
  159 +
  160 +skynet.start(function()
  161 + skynet.dispatch("lua", function(session, source, command, ...)
  162 + -- skynet.trace() --执行序的跟踪统计
  163 + local f = CMD[command]
  164 + if f then
  165 + skynet.ret(skynet.pack(f(...)))
  166 + end
  167 + end)
  168 +
  169 + skynet.info_func(function()
  170 + local info = {}
  171 + info.count = (nextIdx + MAX_COUNT - curIdx) % MAX_COUNT
  172 + return info
  173 + end)
  174 +
  175 + cs = queue()
  176 +
  177 + skynet.timeout(100, handle_timeout)
  178 +end)
0 \ No newline at end of file 179 \ No newline at end of file
src/services/watchdog.lua
@@ -66,6 +66,7 @@ end @@ -66,6 +66,7 @@ end
66 function CMD.start(conf) 66 function CMD.start(conf)
67 skynet.call(gate_serv, "lua", "open" , conf) 67 skynet.call(gate_serv, "lua", "open" , conf)
68 skynet.call(redisd, "lua", "open", conf) 68 skynet.call(redisd, "lua", "open", conf)
  69 + skynet.call(queued_serv, "lua", "open", gate_serv)
69 70
70 if use_logd == 1 then 71 if use_logd == 1 then
71 skynet.call(logd, "lua", "open") 72 skynet.call(logd, "lua", "open")
@@ -137,4 +138,5 @@ skynet.start(function() @@ -137,4 +138,5 @@ skynet.start(function()
137 skynet.newservice("services/chated") 138 skynet.newservice("services/chated")
138 -- 网关服务 139 -- 网关服务
139 gate_serv = skynet.newservice("gate") 140 gate_serv = skynet.newservice("gate")
  141 + queued_serv = skynet.newservice("services/queued")
140 end) 142 end)
src/utils/CommonFunc.lua
@@ -161,6 +161,18 @@ function diffFromOpen() @@ -161,6 +161,18 @@ function diffFromOpen()
161 return math.floor((now - openTime) / DAY_SEC) 161 return math.floor((now - openTime) / DAY_SEC)
162 end 162 end
163 163
  164 +function diffFromTs(ts)
  165 + local now = skynet.timex()
  166 + local tm = os.date("*t", ts)
  167 +
  168 + local time = os.time({year = tm.year, month = tm.month, day = tm.day, hour = RESET_TIME})
  169 + if now < time then
  170 + return -1
  171 + end
  172 +
  173 + return math.floor((now - time) / DAY_SEC)
  174 +end
  175 +
164 function getServerOpenTs() 176 function getServerOpenTs()
165 local openTime = os.time{ 177 local openTime = os.time{
166 year = tonum(SERV_OPEN:sub(1,4)), 178 year = tonum(SERV_OPEN:sub(1,4)),
@@ -298,7 +310,7 @@ function notifyClient(params) @@ -298,7 +310,7 @@ function notifyClient(params)
298 params.key = "zhaolugame20170831" 310 params.key = "zhaolugame20170831"
299 311
300 local status, body = httpc.get(skynet.getenv("codeurl"), 312 local status, body = httpc.get(skynet.getenv("codeurl"),
301 - "/mipush/notify_user?" .. httpGetFormatData(params), {}, {}) 313 + "/push/notify_user?" .. httpGetFormatData(params), {}, {})
302 if tonumber(status) ~= 200 then 314 if tonumber(status) ~= 200 then
303 skynet.error(status, body) 315 skynet.error(status, body)
304 return 316 return
@@ -313,7 +325,7 @@ function deleteNotify(params) @@ -313,7 +325,7 @@ function deleteNotify(params)
313 params.key = "zhaolugame20170831" 325 params.key = "zhaolugame20170831"
314 326
315 local status, body = httpc.get(skynet.getenv("codeurl"), 327 local status, body = httpc.get(skynet.getenv("codeurl"),
316 - "/mipush/delete_notify?" .. httpGetFormatData(params), {}, {}) 328 + "/push/delete_notify?" .. httpGetFormatData(params), {}, {})
317 if tonumber(status) ~= 200 then 329 if tonumber(status) ~= 200 then
318 skynet.error(status, body) 330 skynet.error(status, body)
319 return 331 return