Commit 1b20cfdbbf56544c1a47b33f0ead1b2c473827f1

Authored by zhouhaihai
1 parent 71f716c4

赛季更新完善 无尽冒险排行榜

@@ -2,3 +2,4 @@ @@ -2,3 +2,4 @@
2 dump.rdb 2 dump.rdb
3 .DS_Store 3 .DS_Store
4 src/.idea 4 src/.idea
  5 +*.pyc
src/ProtocolCode.lua
@@ -61,6 +61,7 @@ actionCodes = { @@ -61,6 +61,7 @@ actionCodes = {
61 Adv_wearArtifactRpc = 166, 61 Adv_wearArtifactRpc = 166,
62 Adv_upArtifactRpc = 167, 62 Adv_upArtifactRpc = 167,
63 Adv_repayWheelSurfRpc = 168, 63 Adv_repayWheelSurfRpc = 168,
  64 + Adv_rankRpc = 169,
64 65
65 Hero_loadInfos = 201, 66 Hero_loadInfos = 201,
66 Hero_updateProperty = 202, 67 Hero_updateProperty = 202,
@@ -16,38 +16,18 @@ R_EMAIL_ITEM = "email:%d:%d" --邮件 @@ -16,38 +16,18 @@ R_EMAIL_ITEM = "email:%d:%d" --邮件
16 RANK_TOWER = "rank:tower" 16 RANK_TOWER = "rank:tower"
17 RANK_TOWER_INFO = "rank:tower:info" 17 RANK_TOWER_INFO = "rank:tower:info"
18 18
  19 +-- adv
  20 +RANK_ADV = "rank:adv"
  21 +RANK_ADV_INFO = "rank:adv:info"
  22 +
19 RANK_DINER = {"rank:diner1", "rank:diner2"} -- 餐厅排行榜 两个每天互换 23 RANK_DINER = {"rank:diner1", "rank:diner2"} -- 餐厅排行榜 两个每天互换
20 RANK_DINER_INFO = "rank:diner:info" 24 RANK_DINER_INFO = "rank:diner:info"
21 25
22 RANK_PVP_COMMON = "rank:pvpc" 26 RANK_PVP_COMMON = "rank:pvpc"
23 RECORD_PVP_COMMON = "record:pvpc:%d" 27 RECORD_PVP_COMMON = "record:pvpc:%d"
24 RANK_PVP_HIGHT = "rank:pvph" 28 RANK_PVP_HIGHT = "rank:pvph"
25 --- -- role  
26 --- R_FARM_KEY = "role:%d:farm"  
27 --- R_TOWER_KEY = "role:%d:tower"  
28 --- R_COOKLOG_KEY = "role:%d:cooklog"  
29 --- R_TRADELOG_KEY = "role:%d:tradelog"  
30 --- R_PVP_KEY = "role:%d:pvp"  
31 --- R_DINER_KEY = "role:%d:diner"  
32 --- -- rank  
33 --- RANK_PVP = "rank:pvp"  
34 --- RANK_TRADE = "rank:trade"  
35 --- RANK_TOWER = "rank:tower"  
36 --- RANK_BOX = "rank:box" -- 盒子舒适度排行榜  
37 --- MAP_LIKE = "map:box:like" --点赞个数  
38 --- RANK_LEVEL = "rank:level" --等级排名  
39 --- RANK_ITEM = "rank:item" --活动物品排行  
40 --- -- 日志  
41 --- NOTE_COOK_KEY = "note:cook:%d"  
42 -  
43 --- TRADE_KEY = "trade:%d"  
44 --- TRADE_ID_KEY = "tradeIDs"  
45 29
46 --- TASK_ACTIVE = "task:%d:active" -- 记录激活的任务  
47 --- TASK_FINISH = "task:%d:finish" -- 记录完成的任务  
48 30
49 --- BOSS_SET = "boss:%d:%d"  
50 --- BOSS_INFO = "boss:battle"  
51 31
52 FRIEND_KEY = "role:%d:friend" --哈希表 好友 32 FRIEND_KEY = "role:%d:friend" --哈希表 好友
53 FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 33 FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表
src/actions/AdvAction.lua
@@ -18,6 +18,23 @@ local AdvCommon = require "adv.AdvCommon" @@ -18,6 +18,23 @@ local AdvCommon = require "adv.AdvCommon"
18 18
19 local _M = {} 19 local _M = {}
20 20
  21 +-- 无尽模式是否开放
  22 +local function isOpenEndless(role)
  23 + if role.advOverTime ~= 0 and skynet.timex() >= role.advOverTime then
  24 + return false
  25 + end
  26 + return true
  27 +end
  28 +-- 冒险内的操作是否可以继续
  29 +local function isCanContinue(role)
  30 + local adv = role:getAdvData()
  31 + if not adv:isRunning() then return false end
  32 + if adv:isEndless() then
  33 + if not isOpenEndless(role) then return false end
  34 + end
  35 + return true
  36 +end
  37 +
21 38
22 local function checkFormat(role, format, checkAdvTeam) 39 local function checkFormat(role, format, checkAdvTeam)
23 local advHang = role:getProperty("advHang") 40 local advHang = role:getProperty("advHang")
@@ -69,7 +86,7 @@ function _M.startAdvRpc( agent, data ) @@ -69,7 +86,7 @@ function _M.startAdvRpc( agent, data )
69 local format = msg.format --编队 86 local format = msg.format --编队
70 87
71 --上一个关卡结束才可以开始新的关卡 88 --上一个关卡结束才可以开始新的关卡
72 - if next(role:getProperty("advInfo")) then return 8 end 89 + if role:getAdvData():isRunning() then return 8 end
73 90
74 local chapterData = csvdb["adv_chapterCsv"][chapterId] 91 local chapterData = csvdb["adv_chapterCsv"][chapterId]
75 if not chapterData or layer < 1 then return 1 end 92 if not chapterData or layer < 1 then return 1 end
@@ -79,6 +96,8 @@ function _M.startAdvRpc( agent, data ) @@ -79,6 +96,8 @@ function _M.startAdvRpc( agent, data )
79 96
80 local advPass = role:getProperty("advPass") 97 local advPass = role:getProperty("advPass")
81 if AdvCommon.isEndless(chapterId) then 98 if AdvCommon.isEndless(chapterId) then
  99 + if chapterId ~= role.advElChapter then return end -- 不是当前进行的章节
  100 + if not isOpenEndless(role) then return end
82 if role.dailyData:getProperty("advElC") >= role:getAdvElLimit() then return 2 end -- 是否有体力 101 if role.dailyData:getProperty("advElC") >= role:getAdvElLimit() then return 2 end -- 是否有体力
83 if not role:isFuncOpen(FuncOpenType.AdvEndless) or not role:isFuncOpen(FuncOpenType.AdvRelay) then return 11 end -- 开放了中继模式 和 无尽模式 才可以玩儿无尽模式 102 if not role:isFuncOpen(FuncOpenType.AdvEndless) or not role:isFuncOpen(FuncOpenType.AdvRelay) then return 11 end -- 开放了中继模式 和 无尽模式 才可以玩儿无尽模式
84 local maxl = math.floor(role:getProperty("advElM") / 10) * 10 103 local maxl = math.floor(role:getProperty("advElM") / 10) * 10
@@ -147,7 +166,7 @@ function _M.startHangRpc(agent, data) @@ -147,7 +166,7 @@ function _M.startHangRpc(agent, data)
147 166
148 if role.dailyData:getProperty("advC") >= role:getAdvHangLimit() then return end -- 是否有体力 167 if role.dailyData:getProperty("advC") >= role:getAdvHangLimit() then return end -- 是否有体力
149 168
150 - if not checkFormat(role, format, next(role:getProperty("advInfo"))) then return end --编队是否正确 169 + if not checkFormat(role, format, role:getAdvData():isRunning()) then return end --编队是否正确
151 170
152 local battleV = 0 171 local battleV = 0
153 for _, heroId in pairs(format.heros) do 172 for _, heroId in pairs(format.heros) do
@@ -167,7 +186,7 @@ function _M.startHangRpc(agent, data) @@ -167,7 +186,7 @@ function _M.startHangRpc(agent, data)
167 info.time = skynet.timex() + chapterData.idleTime --挂机时间 186 info.time = skynet.timex() + chapterData.idleTime --挂机时间
168 187
169 -- 没有在战斗 用team来挂机了 把team清掉 188 -- 没有在战斗 用team来挂机了 把team清掉
170 - if not next(role:getProperty("advInfo")) then 189 + if not role:getAdvData():isRunning() then
171 role:updateProperty({field = "advTeam", value = {}}) 190 role:updateProperty({field = "advTeam", value = {}})
172 end 191 end
173 192
@@ -248,6 +267,7 @@ function _M.finishTaskRpc(agent, data) @@ -248,6 +267,7 @@ function _M.finishTaskRpc(agent, data)
248 local role = agent.role 267 local role = agent.role
249 local msg = MsgPack.unpack(data) 268 local msg = MsgPack.unpack(data)
250 269
  270 + if not isCanContinue(role) then return end
251 local adv = role:getAdvData() 271 local adv = role:getAdvData()
252 local taskId = msg.taskId -- -1 则是主线任务 272 local taskId = msg.taskId -- -1 则是主线任务
253 local status, reward 273 local status, reward
@@ -270,7 +290,9 @@ function _M.clickBlockRpc(agent, data) @@ -270,7 +290,9 @@ function _M.clickBlockRpc(agent, data)
270 local role = agent.role 290 local role = agent.role
271 local msg = MsgPack.unpack(data) 291 local msg = MsgPack.unpack(data)
272 292
  293 + if not isCanContinue(role) then return end
273 local adv = role:getAdvData() 294 local adv = role:getAdvData()
  295 +
274 if adv:isWaitChooseArtifact() then return end 296 if adv:isWaitChooseArtifact() then return end
275 local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg) 297 local status, errorCode = adv:clickBlock(msg.roomId, msg.blockId, msg)
276 if not status then return errorCode end 298 if not status then return errorCode end
@@ -290,6 +312,7 @@ function _M.useItemRpc(agent, data) @@ -290,6 +312,7 @@ function _M.useItemRpc(agent, data)
290 local itemData = csvdb["adv_itemCsv"][itemId] 312 local itemData = csvdb["adv_itemCsv"][itemId]
291 if not itemData then return end 313 if not itemData then return end
292 314
  315 + if not isCanContinue(role) then return end
293 local adv = role:getAdvData() 316 local adv = role:getAdvData()
294 if adv:isWaitChooseArtifact() then return end 317 if adv:isWaitChooseArtifact() then return end
295 --重置数量 318 --重置数量
@@ -337,7 +360,8 @@ function _M.usePotionRpc(agent, data) @@ -337,7 +360,8 @@ function _M.usePotionRpc(agent, data)
337 local potionBag = role:getProperty("potionBag") 360 local potionBag = role:getProperty("potionBag")
338 local own = potionBag[potionId] or 0 361 local own = potionBag[potionId] or 0
339 if own <= 0 then return 4 end 362 if own <= 0 then return 4 end
340 - 363 +
  364 + if not isCanContinue(role) then return end
341 local adv = role:getAdvData() 365 local adv = role:getAdvData()
342 if adv:isWaitChooseArtifact() then return end 366 if adv:isWaitChooseArtifact() then return end
343 367
@@ -359,8 +383,10 @@ end @@ -359,8 +383,10 @@ end
359 function _M.chooseArtifactRpc(agent, data) 383 function _M.chooseArtifactRpc(agent, data)
360 local role = agent.role 384 local role = agent.role
361 local msg = MsgPack.unpack(data) 385 local msg = MsgPack.unpack(data)
362 - local adv = role:getAdvData()  
363 386
  387 + if not isCanContinue(role) then return end
  388 +
  389 + local adv = role:getAdvData()
364 if not msg.idx then return end 390 if not msg.idx then return end
365 if not adv:isWaitChooseArtifact() then return end 391 if not adv:isWaitChooseArtifact() then return end
366 local status = adv:chooseArtifact(msg.idx) 392 local status = adv:chooseArtifact(msg.idx)
@@ -378,6 +404,8 @@ function _M.wearArtifactRpc(agent, data) @@ -378,6 +404,8 @@ function _M.wearArtifactRpc(agent, data)
378 local slot = msg.slot 404 local slot = msg.slot
379 local id = msg.id 405 local id = msg.id
380 406
  407 + if not isCanContinue(role) then return end
  408 +
381 local adv = role:getAdvData() 409 local adv = role:getAdvData()
382 410
383 if math.illegalNum(slot, 1, 5) then return 1 end 411 if math.illegalNum(slot, 1, 5) then return 1 end
@@ -398,6 +426,8 @@ function _M.upArtifactRpc(agent, data) @@ -398,6 +426,8 @@ function _M.upArtifactRpc(agent, data)
398 local msg = MsgPack.unpack(data) 426 local msg = MsgPack.unpack(data)
399 local id = msg.id 427 local id = msg.id
400 428
  429 + if not isCanContinue(role) then return end
  430 +
401 local adv = role:getAdvData() 431 local adv = role:getAdvData()
402 if adv:isWaitChooseArtifact() then return 1 end 432 if adv:isWaitChooseArtifact() then return 1 end
403 local curLevel = adv:isHaveArtifact(id) 433 local curLevel = adv:isHaveArtifact(id)
@@ -421,6 +451,8 @@ end @@ -421,6 +451,8 @@ end
421 function _M.exitAdvRpc(agent, data) 451 function _M.exitAdvRpc(agent, data)
422 local role = agent.role 452 local role = agent.role
423 -- local msg = MsgPack.unpack(data) 453 -- local msg = MsgPack.unpack(data)
  454 + if not isCanContinue(role) then return end
  455 +
424 local adv = role:getAdvData() 456 local adv = role:getAdvData()
425 local status = adv:exit() -- target {roomId = 1, blockId = 1} 选择的目标 457 local status = adv:exit() -- target {roomId = 1, blockId = 1} 选择的目标
426 SendPacket(actionCodes.Adv_exitAdvRpc, MsgPack.pack({events = adv:popBackEvents()})) 458 SendPacket(actionCodes.Adv_exitAdvRpc, MsgPack.pack({events = adv:popBackEvents()}))
@@ -438,8 +470,10 @@ function _M.startBattleRpc(agent, data) @@ -438,8 +470,10 @@ function _M.startBattleRpc(agent, data)
438 local monsterId = msg.monsterId 470 local monsterId = msg.monsterId
439 local enemyId = msg.enemyId 471 local enemyId = msg.enemyId
440 if not enemyId then return end 472 if not enemyId then return end
  473 + if not isCanContinue(role) then return end
441 474
442 local adv = role:getAdvData() 475 local adv = role:getAdvData()
  476 +
443 if adv:isWaitChooseArtifact() then return end 477 if adv:isWaitChooseArtifact() then return end
444 local enemy = adv.battle:getEnemyById(enemyId) 478 local enemy = adv.battle:getEnemyById(enemyId)
445 479
@@ -467,6 +501,8 @@ function _M.endBattleRpc(agent, data) @@ -467,6 +501,8 @@ function _M.endBattleRpc(agent, data)
467 local bySkill = msg.bySkill --死于 技能 501 local bySkill = msg.bySkill --死于 技能
468 502
469 if not player or not player.hp or not player.sp or not enemyId or not key then return end 503 if not player or not player.hp or not player.sp or not enemyId or not key then return end
  504 + if not isCanContinue(role) then return end
  505 +
470 local adv = role:getAdvData() 506 local adv = role:getAdvData()
471 if adv:isWaitChooseArtifact() then return end 507 if adv:isWaitChooseArtifact() then return end
472 -- 校验 508 -- 校验
@@ -597,7 +633,7 @@ function _M.finishAchievRpc(agent, data) @@ -597,7 +633,7 @@ function _M.finishAchievRpc(agent, data)
597 local taskId = msg.taskId -- 领取id 633 local taskId = msg.taskId -- 领取id
598 634
599 local adv = role:getAdvData() 635 local adv = role:getAdvData()
600 - 636 +
601 local status, reward 637 local status, reward
602 -- if ctype == 1 then 638 -- if ctype == 1 then
603 -- status = adv:finishAchievement(chapterId, taskId) 639 -- status = adv:finishAchievement(chapterId, taskId)
@@ -610,5 +646,40 @@ function _M.finishAchievRpc(agent, data) @@ -610,5 +646,40 @@ function _M.finishAchievRpc(agent, data)
610 return true 646 return true
611 end 647 end
612 648
  649 +function _M.rankRpc(agent, data)
  650 + local role = agent.role
  651 +
  652 + local list = {}
  653 + local ids = redisproxy:zrevrange(RANK_ADV, 0 , 99)
  654 + local redret = {}
  655 + if ids and next(ids) then
  656 + redret = redisproxy:pipelining(function (red)
  657 + for i = 1, #ids do
  658 + local roleId = ids[i]
  659 + table.insert(list, {roleId = tonumber(roleId)})
  660 + red:hget(RANK_ADV_INFO, roleId)
  661 + end
  662 + end)
  663 + end
  664 + for i = 1, #redret do
  665 + local player = MsgPack.unpack(redret[i])
  666 + player.format = nil
  667 + list[i].player = player
  668 + end
  669 + local redret = redisproxy:pipelining(function(red)
  670 + red:ZREVRANK(RANK_ADV, role:getProperty("id"))
  671 + red:zscore(RANK_ADV, role:getProperty("id"))
  672 + end)
  673 + local rank = redret[1]
  674 + if not rank then
  675 + rank = -1
  676 + else
  677 + rank = redret[1] + 1
  678 + end
  679 + local score = tonum(redret[2], 0)
  680 +
  681 + SendPacket(actionCodes.Adv_rankRpc, MsgPack.pack({list = list, rank = rank, score = score}))
  682 + return true
  683 +end
613 684
614 return _M 685 return _M
615 \ No newline at end of file 686 \ No newline at end of file
src/actions/GmAction.lua
@@ -204,13 +204,7 @@ end @@ -204,13 +204,7 @@ end
204 204
205 table.insert(helpDes, {"冒险清除" , "advc"}) 205 table.insert(helpDes, {"冒险清除" , "advc"})
206 function _M.advc(role, pms) 206 function _M.advc(role, pms)
207 - role:updateProperty({field = "advInfo", value = {}})  
208 - role:updateProperty({field = "advTask", value = {}})  
209 - role:updateProperty({field = "advItems", value = ""})  
210 - role:updateProperty({field = "advTeam", value = {}})  
211 - role:updateProperty({field = "advAFGet", value = {}})  
212 - role:updateProperty({field = "advAFWear", value = {}})  
213 - role.advData = nil 207 + role:getAdvData():forceOver()
214 return "成功" 208 return "成功"
215 end 209 end
216 210
src/actions/RoleAction.lua
@@ -116,7 +116,7 @@ function _M.loginRpc( agent, data ) @@ -116,7 +116,7 @@ function _M.loginRpc( agent, data )
116 SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start") 116 SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start")
117 117
118 role:changeStructVersion() -- 数据结构 版本更新 118 role:changeStructVersion() -- 数据结构 版本更新
119 - role:advEndlessSeasonCheck() -- 冒险赛季更新检查 119 + role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查
120 120
121 -- 跨天登陆事件 121 -- 跨天登陆事件
122 role:onCrossDay(now) 122 role:onCrossDay(now)
@@ -99,9 +99,30 @@ function Adv:clear() @@ -99,9 +99,30 @@ function Adv:clear()
99 self.shopStatus = {} 99 self.shopStatus = {}
100 end 100 end
101 101
  102 +function Adv:isRunning()
  103 + if self.chapterId then return true end
  104 + return false
  105 +end
  106 +
  107 +-- 强制结束
  108 +function Adv:forceOver(notNotify)
  109 + if self:isRunning() then
  110 + self:clear()
  111 + local advTeam = self.owner:getProperty("advTeam")
  112 + advTeam.player = nil
  113 + self.owner:updateProperties({
  114 + advInfo = {},
  115 + advTeam = advTeam,
  116 + advItems = "",
  117 + advAFGet = {},
  118 + advAFWear = {},
  119 + }, notNotify)
  120 + end
  121 +end
  122 +
102 function Adv:saveDB(notNotify) 123 function Adv:saveDB(notNotify)
103 local advInfo, advTeam = {}, self.owner:getProperty("advTeam") 124 local advInfo, advTeam = {}, self.owner:getProperty("advTeam")
104 - if self.chapterId then 125 + if self:isRunning() then
105 126
106 advInfo.chapterId = self.chapterId 127 advInfo.chapterId = self.chapterId
107 advInfo.level = self.level 128 advInfo.level = self.level
@@ -401,14 +422,33 @@ function Adv:over(success, isAllPass) @@ -401,14 +422,33 @@ function Adv:over(success, isAllPass)
401 self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId}) 422 self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId})
402 end 423 end
403 424
  425 + local roleId = self.owner:getProperty("id")
  426 + local oldMaxScore = tonum(redisproxy:zscore(RANK_ADV, roleId))
  427 + if score > oldMaxScore then
  428 + local team = self.owner:getProperty("advTeam")
  429 + local curInfo = {
  430 + name = self.owner:getProperty("name"),
  431 + headId = self.owner:getProperty("headId"),
  432 + lv = self.owner:getProperty("level"),
  433 + batteV = self:getTeamBattleValue(team.heros),
  434 + chapter = self.chapterId,
  435 + format = self.owner:getTeamHerosInfo(team.heros),
  436 + }
  437 + redisproxy:pipelining(function (red)
  438 + red:zadd(RANK_ADV, score, roleId) --更新分数
  439 + red:hset(RANK_ADV_INFO, roleId, MsgPack.pack(curInfo))
  440 + end)
  441 + end
404 end 442 end
405 self:clearAdvUnlockCache() 443 self:clearAdvUnlockCache()
406 self:clear() 444 self:clear()
407 self.owner:checkTaskEnter("AdvScore", {score = score}) 445 self.owner:checkTaskEnter("AdvScore", {score = score})
408 - self.owner:updateProperty({field = "advItems", value = ""})  
409 - self.owner:updateProperty({field = "advAFGet", value = {}})  
410 - self.owner:updateProperty({field = "advAFWear", value = {}})  
411 446
  447 + self.owner:updateProperties({
  448 + advItems = "",
  449 + advAFGet = {},
  450 + advAFWear = {},
  451 + })
412 self:backEnd(success, score, scoreInfo, reward) 452 self:backEnd(success, score, scoreInfo, reward)
413 end 453 end
414 454
src/models/Role.lua
@@ -21,6 +21,9 @@ function Role:ctor( properties ) @@ -21,6 +21,9 @@ function Role:ctor( properties )
21 self.heros = {} 21 self.heros = {}
22 self.runeBag = {} 22 self.runeBag = {}
23 self.advData = nil 23 self.advData = nil
  24 +
  25 + self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节
  26 + self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳
24 end 27 end
25 28
26 Role.schema = { 29 Role.schema = {
@@ -64,7 +67,7 @@ Role.schema = { @@ -64,7 +67,7 @@ Role.schema = {
64 advAchiev = {"table", {}}, -- 冒险成就 {chapterId = {achievId = status, -1 = pt, pts = {}}, } 67 advAchiev = {"table", {}}, -- 冒险成就 {chapterId = {achievId = status, -1 = pt, pts = {}}, }
65 advL = {"table", {0, 0}}, -- 冒险队等级 {lv, exp} 68 advL = {"table", {0, 0}}, -- 冒险队等级 {lv, exp}
66 advElM = {"number", 0}, -- 无尽模式通关的最高层数 endless max layer 69 advElM = {"number", 0}, -- 无尽模式通关的最高层数 endless max layer
67 - advElS = {"number", globalCsv.adv_endless_season}, -- 无尽模式记录的赛季 endless season 70 + advElS = {"number", 0}, -- 无尽模式记录的赛季 endless season
68 advAFOpen = {"table", {}}, -- 解锁的神器 {[id] = 1} 71 advAFOpen = {"table", {}}, -- 解锁的神器 {[id] = 1}
69 advAFGet = {"table", {}}, -- 当前拥有的神器 {[id] = 等级} 72 advAFGet = {"table", {}}, -- 当前拥有的神器 {[id] = 等级}
70 advAFWear = {"table", {}}, -- 当前拥有的神器 {[slot] = id} 73 advAFWear = {"table", {}}, -- 当前拥有的神器 {[slot] = id}
@@ -254,6 +257,8 @@ function Role:data() @@ -254,6 +257,8 @@ function Role:data()
254 advAchiev = self:getProperty("advAchiev"), 257 advAchiev = self:getProperty("advAchiev"),
255 advL = self:getProperty("advL"), 258 advL = self:getProperty("advL"),
256 advElM = self:getProperty("advElM"), 259 advElM = self:getProperty("advElM"),
  260 + advElChapter = self.advElChapter,
  261 + advOverTime = self.advOverTime,
257 advAFGet = self:getProperty("advAFGet"), 262 advAFGet = self:getProperty("advAFGet"),
258 advAFWear = self:getProperty("advAFWear"), 263 advAFWear = self:getProperty("advAFWear"),
259 advDrawB = self:getProperty("advDrawB"), 264 advDrawB = self:getProperty("advDrawB"),
src/models/RolePlugin.lua
@@ -772,12 +772,36 @@ function RolePlugin.bind(Role) @@ -772,12 +772,36 @@ function RolePlugin.bind(Role)
772 end 772 end
773 773
774 -- 赛季检查 774 -- 赛季检查
775 - function Role:advEndlessSeasonCheck()  
776 - if self:getProperty("advElS") ~= globalCsv.adv_endless_season then 775 + function Role:advEndlessSeasonCheck(notNotify)
  776 + -- 重置一下冒险
  777 + local nowSeason = tonum(redisproxy:hget("adv_season", "idx"))
  778 + if self:getProperty("advElS") ~= nowSeason then
777 local ml = self:getProperty("advElM") 779 local ml = self:getProperty("advElM")
  780 +
778 local nl = math.max(0, ml - (math.floor(ml / 50) + 2) * 10) 781 local nl = math.max(0, ml - (math.floor(ml / 50) + 2) * 10)
779 self:setProperty("advElM", math.floor(nl / 10) * 10) 782 self:setProperty("advElM", math.floor(nl / 10) * 10)
780 - self:setProperty("advElS", globalCsv.adv_endless_season) 783 + self:setProperty("advElS", nowSeason)
  784 +
  785 + -- 正在无尽冒险清掉
  786 + local adv = self:getAdvData()
  787 + if adv:isRunning() and adv:isEndless() then
  788 + adv:forceOver()
  789 + end
  790 +
  791 + -- 重新设定冒险章节和冒险结束时间
  792 + self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter)
  793 + self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime"))
  794 +
  795 + if not notNotify then
  796 + SendPacket(actionCodes.Role_updateProperties, MsgPack.pack({
  797 + advElChapter = self.advElChapter,
  798 + advOverTime = self.advOverTime,
  799 + }))
  800 + end
  801 + -- 清掉冒险手册
  802 + self:updateProperties({
  803 + advEAchiev = {},
  804 + }, notNotify)
781 end 805 end
782 end 806 end
783 807
src/python/adv_season.py 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +
  2 +from redisCommon import redis, pipe, decode, encode
  3 +
  4 +import time, datetime
  5 +
  6 +
  7 +lastOverTime = int(time.mktime(datetime.date.today().timetuple())) + 3600 * 24 * 14 #取当天0点
  8 +
  9 +
  10 +
  11 +
  12 +
src/python/redisCommon.py 0 → 100644
@@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
  1 +from redis import Redis
  2 +import msgpack
  3 +
  4 +redisConf = {
  5 + "host" : "127.0.0.1",
  6 + "port" : 6100,
  7 + "db" : 1,
  8 + "password" : None,
  9 +}
  10 +
  11 +
  12 +def numberUnpack(n) :
  13 + if isinstance(n, bytes) :
  14 + try:
  15 + return int(n)
  16 + except ValueError:
  17 + try:
  18 + return float(n)
  19 + except ValueError:
  20 + pass
  21 + return n.decode()
  22 + else :
  23 + return n
  24 +
  25 +def stringUnpack(s) :
  26 + if isinstance(s, bytes) :
  27 + return n.decode()
  28 + else :
  29 + return s
  30 +
  31 +def tableUnpack(t) :
  32 + if isinstance(t, bytes) :
  33 + return msgpack.unpackb(t, raw = False) #解包
  34 + else :
  35 + return t
  36 +
  37 +redisUnpack = {
  38 + "number" : numberUnpack,
  39 + "string" : stringUnpack,
  40 + "table" : tableUnpack,
  41 + "default" : numberUnpack,
  42 +}
  43 +def commonPack(w) :
  44 + return w
  45 +
  46 +def tablePack(t):
  47 + return msgpack.packb(t, use_bin_type = True)
  48 +
  49 +redisPack = {
  50 + "default" : commonPack,
  51 + "table" : tablePack,
  52 +}
  53 +
  54 +
  55 +
  56 +
  57 +redis = Redis(
  58 + host = redisConf["host"],
  59 + port = redisConf["port"],
  60 + db = redisConf["db"],
  61 + password = redisConf["password"]
  62 +)
  63 +
  64 +pipe = redis.pipeline()
  65 +
  66 +def decode(w, t = "default"):
  67 + return redisUnpack[t](w)
  68 +
  69 +def encode(w, t = "default") :
  70 + return redisPack[t](w)
  71 +
  72 +
  73 +
  74 +
  75 +
  76 +
  77 +
  78 +
src/python/requirements.txt 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +redis
  2 +msgpack
0 \ No newline at end of file 3 \ No newline at end of file
src/services/dbseed.lua
@@ -23,6 +23,9 @@ local function initRedisDb( ... ) @@ -23,6 +23,9 @@ local function initRedisDb( ... )
23 redisproxy:hsetnx("autoincrement_set", "email", 0) 23 redisproxy:hsetnx("autoincrement_set", "email", 0)
24 redisproxy:hsetnx("autoincrement_set", "emailTimestamp", 0) 24 redisproxy:hsetnx("autoincrement_set", "emailTimestamp", 0)
25 redisproxy:hsetnx("autoincrement_set", "delay_email", 0) 25 redisproxy:hsetnx("autoincrement_set", "delay_email", 0)
  26 + redisproxy:hsetnx("adv_season", "idx", 0)
  27 + redisproxy:hsetnx("adv_season", "chapter", globalCsv.adv_endless_default_chapter)
  28 + redisproxy:hsetnx("adv_season", "overTime", 0)
26 end 29 end
27 end 30 end
28 31