Commit da89807497f99247dab8949528a61278a7e374dd
1 parent
cfd68b3a
pvp 高级领奖
Showing
9 changed files
with
231 additions
and
63 deletions
Show diff stats
src/GlobalVar.lua
| 1 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" | 1 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" |
| 2 | RESET_TIME = 4 | 2 | RESET_TIME = 4 |
| 3 | -RESET_RANK_TIME = 8 | 3 | + |
| 4 | +START_RESET_TIME_BASE = 1584921600 -- 0时区 | ||
| 5 | +TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 | ||
| 6 | + | ||
| 7 | +START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600 | ||
| 8 | + | ||
| 9 | + | ||
| 4 | MAX_ROLE_NUM = 1000000 | 10 | MAX_ROLE_NUM = 1000000 |
| 5 | -- 属性枚举 | 11 | -- 属性枚举 |
| 6 | AttsEnum = { | 12 | AttsEnum = { |
| @@ -98,17 +104,31 @@ ItemId = { | @@ -98,17 +104,31 @@ ItemId = { | ||
| 98 | BreakCost = 10, -- 突破材料 | 104 | BreakCost = 10, -- 突破材料 |
| 99 | EquipUp = 11, -- 装备升级材料 | 105 | EquipUp = 11, -- 装备升级材料 |
| 100 | DinerCoin = 12, --后勤物资 | 106 | DinerCoin = 12, --后勤物资 |
| 101 | - LoveUp = 14, --好感度提升道具 | 107 | + PvpCoin = 14, --挑战货币 |
| 102 | OldCoin = 15, --古代金币 | 108 | OldCoin = 15, --古代金币 |
| 103 | AdvPoint = 16, -- 探险点 | 109 | AdvPoint = 16, -- 探险点 |
| 104 | DinerSpTask = 20, -- 餐厅任务采购券 | 110 | DinerSpTask = 20, -- 餐厅任务采购券 |
| 105 | LoveBreak = 21, --好感度突破道具 | 111 | LoveBreak = 21, --好感度突破道具 |
| 106 | PvpKey = 22, -- pvp钥匙 | 112 | PvpKey = 22, -- pvp钥匙 |
| 107 | LunchFragment = 23, | 113 | LunchFragment = 23, |
| 108 | - HeroFC = {700, 701, 702, 703}, -- 通用角色碎片 | 114 | + HeroFC = {700, 701, 702, 703}, --通用角色碎片 |
| 109 | AdvKey = 80, -- 冒险钥匙 | 115 | AdvKey = 80, -- 冒险钥匙 |
| 110 | BoxKey = 60, -- 拆解工具 | 116 | BoxKey = 60, -- 拆解工具 |
| 111 | } | 117 | } |
| 118 | + | ||
| 119 | +TimeReset = { | ||
| 120 | + CrossDay = 1, --通用跨天 | ||
| 121 | + CrossWeek = 2, --通用跨周 | ||
| 122 | + DinerRank = 1, -- 餐厅排行榜 | ||
| 123 | + PvpRank = 2, -- pvp排行榜 | ||
| 124 | + PvpHight = 11, --高级竞技场 | ||
| 125 | + PvpCross = 12, -- 跨服竞技场 | ||
| 126 | + PvpShop = 13, -- 竞技场商城 | ||
| 127 | + DailyBattle1 = 14, -- 特殊-每日副本(贴纸) | ||
| 128 | + DailyBattle2 = 15, -- 特殊-每日副本(装备) | ||
| 129 | + DailyBattle2 = 16, -- 特殊-每日副本(时钟箱) | ||
| 130 | +} | ||
| 131 | + | ||
| 112 | --客户端不需要知道这个 | 132 | --客户端不需要知道这个 |
| 113 | AdvSpecialStage = { | 133 | AdvSpecialStage = { |
| 114 | [1]= "In", | 134 | [1]= "In", |
src/ProtocolCode.lua
| @@ -160,6 +160,8 @@ actionCodes = { | @@ -160,6 +160,8 @@ actionCodes = { | ||
| 160 | Pvp_refreshMatchHRpc = 509, | 160 | Pvp_refreshMatchHRpc = 509, |
| 161 | Pvp_startBattleHRpc = 510, | 161 | Pvp_startBattleHRpc = 510, |
| 162 | Pvp_endBattleHRpc = 511, | 162 | Pvp_endBattleHRpc = 511, |
| 163 | + Pvp_highDivisionGiftRpc = 512, | ||
| 164 | + Pvp_shopBuyRpc = 513, | ||
| 163 | 165 | ||
| 164 | 166 | ||
| 165 | Store_rechargeRpc = 550, | 167 | Store_rechargeRpc = 550, |
src/RedisKeys.lua
| @@ -24,8 +24,10 @@ RANK_DINER = {"rank:diner1", "rank:diner2"} -- é¤åŽ…æŽ’è¡Œæ¦œ 两个æ¯å¤©äº’æ | @@ -24,8 +24,10 @@ RANK_DINER = {"rank:diner1", "rank:diner2"} -- é¤åŽ…æŽ’è¡Œæ¦œ 两个æ¯å¤©äº’æ | ||
| 24 | RANK_DINER_INFO = "rank:diner:info" | 24 | RANK_DINER_INFO = "rank:diner:info" |
| 25 | 25 | ||
| 26 | RANK_PVP_COMMON = "rank:pvpc" | 26 | RANK_PVP_COMMON = "rank:pvpc" |
| 27 | +RANK_PVP_COMMON_KEY = {"rank:pvpc1", "rank:pvpc2"} | ||
| 27 | RECORD_PVP_COMMON = "record:pvpc:%d" | 28 | RECORD_PVP_COMMON = "record:pvpc:%d" |
| 28 | RANK_PVP_HIGHT = "rank:pvph" | 29 | RANK_PVP_HIGHT = "rank:pvph" |
| 30 | +RANK_PVP_HIGHT_KEY = {"rank:pvph1", "rank:pvph2"} | ||
| 29 | RECORD_PVP_HIGH = "record:pvph:%d" | 31 | RECORD_PVP_HIGH = "record:pvph:%d" |
| 30 | 32 | ||
| 31 | 33 |
src/actions/HeroAction.lua
| @@ -245,7 +245,7 @@ function _M.commentHeroRpc(agent, data) | @@ -245,7 +245,7 @@ function _M.commentHeroRpc(agent, data) | ||
| 245 | result.status = 1 | 245 | result.status = 1 |
| 246 | else | 246 | else |
| 247 | local commentKey = getCommentKey(heroType) | 247 | local commentKey = getCommentKey(heroType) |
| 248 | - local SERV = string.format("NAMED%d", math.random(1, 5)) | 248 | + local SERV = string.format(".NAMED%d", math.random(1, 5)) |
| 249 | local legal, mod = skynet.call(SERV, "lua", "check", content) | 249 | local legal, mod = skynet.call(SERV, "lua", "check", content) |
| 250 | if not legal then | 250 | if not legal then |
| 251 | content = mod or "" | 251 | content = mod or "" |
src/actions/HttpAction.lua
| @@ -43,7 +43,7 @@ function _M.reload_csvdata(query, body) | @@ -43,7 +43,7 @@ function _M.reload_csvdata(query, body) | ||
| 43 | return "code error" | 43 | return "code error" |
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | - local ok, status = pcall(skynet.call, 'CSVDATA', "lua", "reload", body) | 46 | + local ok, status = pcall(skynet.call, '.CSVDATA', "lua", "reload", body) |
| 47 | if status == "ok" then | 47 | if status == "ok" then |
| 48 | skynet.error(string.format("reload_csvdata time: %s, code: %s", skynet.timex(), body)) | 48 | skynet.error(string.format("reload_csvdata time: %s, code: %s", skynet.timex(), body)) |
| 49 | return 'success' | 49 | return 'success' |
| @@ -69,7 +69,7 @@ function _M.hotfix_csvdata(query, body) | @@ -69,7 +69,7 @@ function _M.hotfix_csvdata(query, body) | ||
| 69 | if not ok or type(result) ~= 'table' then | 69 | if not ok or type(result) ~= 'table' then |
| 70 | return "decode error" | 70 | return "decode error" |
| 71 | end | 71 | end |
| 72 | - local ok, status = pcall(skynet.call, 'CSVDATA', "lua", "hotfix", result) | 72 | + local ok, status = pcall(skynet.call, '.CSVDATA', "lua", "hotfix", result) |
| 73 | 73 | ||
| 74 | if status == "ok" then | 74 | if status == "ok" then |
| 75 | skynet.error(string.format("hotfix_csvdata time: %s, code: %s", skynet.timex(), body)) | 75 | skynet.error(string.format("hotfix_csvdata time: %s, code: %s", skynet.timex(), body)) |
| @@ -150,7 +150,7 @@ function _M.hotfix_code(query, body) | @@ -150,7 +150,7 @@ function _M.hotfix_code(query, body) | ||
| 150 | 150 | ||
| 151 | skynet.error(string.format("hotfix_code time: %s, code: %s", skynet.timex(), body)) | 151 | skynet.error(string.format("hotfix_code time: %s, code: %s", skynet.timex(), body)) |
| 152 | 152 | ||
| 153 | - pcall(skynet.call, 'WATCHDOG', "lua", "hotfix", body) | 153 | + pcall(skynet.call, '.WATCHDOG', "lua", "hotfix", body) |
| 154 | return 'success' | 154 | return 'success' |
| 155 | end | 155 | end |
| 156 | 156 |
src/actions/PvpAction.lua
| @@ -103,6 +103,7 @@ end | @@ -103,6 +103,7 @@ end | ||
| 103 | 103 | ||
| 104 | local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, infoCache) | 104 | local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, infoCache) |
| 105 | table.clear(battleCache) | 105 | table.clear(battleCache) |
| 106 | + local dbKey = role:getPvpDBKey(dbKey) | ||
| 106 | local redret = redisproxy:pipelining(function(red) | 107 | local redret = redisproxy:pipelining(function(red) |
| 107 | for _, info in ipairs(pvpList) do | 108 | for _, info in ipairs(pvpList) do |
| 108 | if info.t == 1 then | 109 | if info.t == 1 then |
| @@ -125,8 +126,9 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf | @@ -125,8 +126,9 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf | ||
| 125 | if k == "battleInfo" then | 126 | if k == "battleInfo" then |
| 126 | battleCache[curInfo.roleId] = v | 127 | battleCache[curInfo.roleId] = v |
| 127 | else | 128 | else |
| 128 | - if k == "heros" and infoCache then | ||
| 129 | - infoCache[curInfo.roleId] = v | 129 | + if (k == "heros" or k == "battleV") and infoCache then |
| 130 | + infoCache[curInfo.roleId] = infoCache[curInfo.roleId] or {} | ||
| 131 | + infoCache[curInfo.roleId][k] = v | ||
| 130 | end | 132 | end |
| 131 | curInfo[k] = v | 133 | curInfo[k] = v |
| 132 | end | 134 | end |
| @@ -150,9 +152,10 @@ function _M.infoRpc(agent, data) | @@ -150,9 +152,10 @@ function _M.infoRpc(agent, data) | ||
| 150 | 152 | ||
| 151 | local response = {} | 153 | local response = {} |
| 152 | if ptype == 1 then -- 普通pvp | 154 | if ptype == 1 then -- 普通pvp |
| 155 | + local dbKey = role:getPvpDBKey(RANK_PVP_COMMON) | ||
| 153 | local redret = redisproxy:pipelining(function(red) | 156 | local redret = redisproxy:pipelining(function(red) |
| 154 | - red:zscore(RANK_PVP_COMMON, roleId) | ||
| 155 | - red:zrevrank(RANK_PVP_COMMON, roleId) | 157 | + red:zscore(dbKey, roleId) |
| 158 | + red:zrevrank(dbKey, roleId) | ||
| 156 | end) | 159 | end) |
| 157 | local score = role:unpackPvpScore(redret[1]) | 160 | local score = role:unpackPvpScore(redret[1]) |
| 158 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp | 161 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp |
| @@ -168,9 +171,11 @@ function _M.infoRpc(agent, data) | @@ -168,9 +171,11 @@ function _M.infoRpc(agent, data) | ||
| 168 | response.score = score | 171 | response.score = score |
| 169 | response.matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC, RANK_PVP_COMMON, "pvpCInfo") | 172 | response.matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC, RANK_PVP_COMMON, "pvpCInfo") |
| 170 | elseif ptype == 2 then -- 高级pvp | 173 | elseif ptype == 2 then -- 高级pvp |
| 174 | + if not role:isTimeResetOpen(TimeReset.PvpHight) then return end | ||
| 175 | + local dbKey = role:getPvpDBKey(RANK_PVP_HIGHT) | ||
| 171 | local redret = redisproxy:pipelining(function(red) | 176 | local redret = redisproxy:pipelining(function(red) |
| 172 | - red:zscore(RANK_PVP_HIGHT, roleId) | ||
| 173 | - red:zrevrank(RANK_PVP_HIGHT, roleId) | 177 | + red:zscore(dbKey, roleId) |
| 178 | + red:zrevrank(dbKey, roleId) | ||
| 174 | end) | 179 | end) |
| 175 | local score = role:unpackPvpScore(redret[1]) | 180 | local score = role:unpackPvpScore(redret[1]) |
| 176 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp | 181 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp |
| @@ -207,6 +212,8 @@ end | @@ -207,6 +212,8 @@ end | ||
| 207 | function _M.refreshMatchHRpc(agent, data) | 212 | function _M.refreshMatchHRpc(agent, data) |
| 208 | local role = agent.role | 213 | local role = agent.role |
| 209 | local msg = MsgPack.unpack(data) | 214 | local msg = MsgPack.unpack(data) |
| 215 | + if not role:isTimeResetOpen(TimeReset.PvpHight) then return end | ||
| 216 | + | ||
| 210 | role:refreshPvpMatchH() | 217 | role:refreshPvpMatchH() |
| 211 | 218 | ||
| 212 | local pvpMH = role:getProperty("pvpMH") | 219 | local pvpMH = role:getProperty("pvpMH") |
| @@ -397,9 +404,10 @@ function _M.startBattleHRpc(agent, data) | @@ -397,9 +404,10 @@ function _M.startBattleHRpc(agent, data) | ||
| 397 | 404 | ||
| 398 | local idx = msg.idx | 405 | local idx = msg.idx |
| 399 | local revenge = msg.revenge | 406 | local revenge = msg.revenge |
| 407 | + if not role:isTimeResetOpen(TimeReset.PvpHight) then return end | ||
| 400 | 408 | ||
| 401 | local pvpTH = role:getProperty("pvpTH") | 409 | local pvpTH = role:getProperty("pvpTH") |
| 402 | - if not pvpTH.heros or not next(pvpTH.heros) then return 1 end | 410 | + if not next(pvpTH) then return 1 end |
| 403 | 411 | ||
| 404 | -- 检查并记录玩家队伍 | 412 | -- 检查并记录玩家队伍 |
| 405 | local pvpTH = {} | 413 | local pvpTH = {} |
| @@ -460,7 +468,7 @@ function _M.startBattleHRpc(agent, data) | @@ -460,7 +468,7 @@ function _M.startBattleHRpc(agent, data) | ||
| 460 | if not pvpMH[idx] then return 3 end | 468 | if not pvpMH[idx] then return 3 end |
| 461 | if pvpMH[idx].t == 1 then | 469 | if pvpMH[idx].t == 1 then |
| 462 | enemyTeamRecord = _pvpBattleInfoCacheH[pvpMH[idx].id] | 470 | enemyTeamRecord = _pvpBattleInfoCacheH[pvpMH[idx].id] |
| 463 | - enemyT = _pvpHeroInfoCacheH[temp.id] | 471 | + enemyT = _pvpHeroInfoCacheH[pvpMH[idx].id] |
| 464 | elseif pvpMH[idx].t == 2 then | 472 | elseif pvpMH[idx].t == 2 then |
| 465 | enemyTeamRecord = {robot = pvpMH[idx].id} | 473 | enemyTeamRecord = {robot = pvpMH[idx].id} |
| 466 | end | 474 | end |
| @@ -581,7 +589,7 @@ function _M.endBattleHRpc(agent, data) | @@ -581,7 +589,7 @@ function _M.endBattleHRpc(agent, data) | ||
| 581 | local round = #_pvpStartBattleCacheH.result + 1 | 589 | local round = #_pvpStartBattleCacheH.result + 1 |
| 582 | local matchInfo = nil | 590 | local matchInfo = nil |
| 583 | if _pvpStartBattleCacheH.enemyTB.robot then | 591 | if _pvpStartBattleCacheH.enemyTB.robot then |
| 584 | - matchInfo = _pvpStartBattleCacheH.enemyTB.robot | 592 | + matchInfo = _pvpStartBattleCacheH.enemyTB |
| 585 | else | 593 | else |
| 586 | matchInfo = _pvpStartBattleCacheH.enemyTB[round] | 594 | matchInfo = _pvpStartBattleCacheH.enemyTB[round] |
| 587 | end | 595 | end |
| @@ -597,10 +605,12 @@ function _M.endBattleHRpc(agent, data) | @@ -597,10 +605,12 @@ function _M.endBattleHRpc(agent, data) | ||
| 597 | end | 605 | end |
| 598 | 606 | ||
| 599 | -- 战斗结束了发奖 | 607 | -- 战斗结束了发奖 |
| 600 | - local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) | 608 | + local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
| 601 | local reward = role:award({[temp[1]] = temp[2]}) | 609 | local reward = role:award({[temp[1]] = temp[2]}) |
| 602 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | ||
| 603 | - | 610 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 |
| 611 | + if role:isTimeResetOpen(TimeReset.PvpHight) then | ||
| 612 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | ||
| 613 | + end | ||
| 604 | 614 | ||
| 605 | -- 加入战斗记录 | 615 | -- 加入战斗记录 |
| 606 | local selfTeam = {} | 616 | local selfTeam = {} |
| @@ -608,7 +618,10 @@ function _M.endBattleHRpc(agent, data) | @@ -608,7 +618,10 @@ function _M.endBattleHRpc(agent, data) | ||
| 608 | for _idx, info in ipairs(_pvpStartBattleCacheH.result) do | 618 | for _idx, info in ipairs(_pvpStartBattleCacheH.result) do |
| 609 | info.winId = info.isWin and roleId or match.id | 619 | info.winId = info.isWin and roleId or match.id |
| 610 | info.isWin = nil | 620 | info.isWin = nil |
| 611 | - selfTeam[_idx] = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx].heros) | 621 | + selfTeam[_idx] = { |
| 622 | + heros = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx].heros), | ||
| 623 | + battleV = role:getTeamBattleValue(_pvpStartBattleCacheH.pvpTH[_idx].heros) | ||
| 624 | + } | ||
| 612 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then | 625 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then |
| 613 | enemyTeam[_idx] = _pvpStartBattleCacheH.enemyT[_idx] | 626 | enemyTeam[_idx] = _pvpStartBattleCacheH.enemyT[_idx] |
| 614 | end | 627 | end |
| @@ -681,10 +694,11 @@ function _M.rankListRpc(agent, data) | @@ -681,10 +694,11 @@ function _M.rankListRpc(agent, data) | ||
| 681 | 694 | ||
| 682 | local response = {} | 695 | local response = {} |
| 683 | if ptype == 1 then -- 普通pvp | 696 | if ptype == 1 then -- 普通pvp |
| 697 | + local dbKey = role:getPvpDBKey(RANK_PVP_COMMON) | ||
| 684 | local redret = redisproxy:pipelining(function(red) | 698 | local redret = redisproxy:pipelining(function(red) |
| 685 | - red:zscore(RANK_PVP_COMMON, roleId) | ||
| 686 | - red:zrevrank(RANK_PVP_COMMON, roleId) | ||
| 687 | - red:zrevrange(RANK_PVP_COMMON, 0, 99, "WITHSCORES") | 699 | + red:zscore(dbKey, roleId) |
| 700 | + red:zrevrank(dbKey, roleId) | ||
| 701 | + red:zrevrange(dbKey, 0, 99, "WITHSCORES") | ||
| 688 | end) | 702 | end) |
| 689 | local score = role:unpackPvpScore(redret[1]) | 703 | local score = role:unpackPvpScore(redret[1]) |
| 690 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp | 704 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp |
| @@ -703,10 +717,11 @@ function _M.rankListRpc(agent, data) | @@ -703,10 +717,11 @@ function _M.rankListRpc(agent, data) | ||
| 703 | response.rankList = rankList | 717 | response.rankList = rankList |
| 704 | 718 | ||
| 705 | elseif ptype == 2 then -- 高级pvp | 719 | elseif ptype == 2 then -- 高级pvp |
| 720 | + local dbKey = role:getPvpDBKey(RANK_PVP_HIGHT) | ||
| 706 | local redret = redisproxy:pipelining(function(red) | 721 | local redret = redisproxy:pipelining(function(red) |
| 707 | - red:zscore(RANK_PVP_HIGHT, roleId) | ||
| 708 | - red:zrevrank(RANK_PVP_HIGHT, roleId) | ||
| 709 | - red:zrevrange(RANK_PVP_HIGHT, 0, 99, "WITHSCORES") | 722 | + red:zscore(dbKey, roleId) |
| 723 | + red:zrevrank(dbKey, roleId) | ||
| 724 | + red:zrevrange(dbKey, 0, 99, "WITHSCORES") | ||
| 710 | end) | 725 | end) |
| 711 | local score = role:unpackPvpScore(redret[1]) | 726 | local score = role:unpackPvpScore(redret[1]) |
| 712 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp | 727 | local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp |
| @@ -714,7 +729,7 @@ function _M.rankListRpc(agent, data) | @@ -714,7 +729,7 @@ function _M.rankListRpc(agent, data) | ||
| 714 | for i = 1, #redret[3], 2 do | 729 | for i = 1, #redret[3], 2 do |
| 715 | local roleId = tonumber(redret[3][i]) | 730 | local roleId = tonumber(redret[3][i]) |
| 716 | local score = role:unpackPvpScore(redret[3][i + 1]) | 731 | local score = role:unpackPvpScore(redret[3][i + 1]) |
| 717 | - local online, curInfo = rpcRole(roleId, "friendSInfo") | 732 | + local online, curInfo = rpcRole(roleId, "pvpHRankInfo") |
| 718 | curInfo.score = score | 733 | curInfo.score = score |
| 719 | curInfo.roleId = roleId | 734 | curInfo.roleId = roleId |
| 720 | table.insert(rankList, curInfo) | 735 | table.insert(rankList, curInfo) |
| @@ -784,4 +799,69 @@ function _M.recordListRpc(agent, data) | @@ -784,4 +799,69 @@ function _M.recordListRpc(agent, data) | ||
| 784 | return true | 799 | return true |
| 785 | end | 800 | end |
| 786 | 801 | ||
| 802 | +function _M.highDivisionGiftRpc(agent, data) | ||
| 803 | + local role = agent.role | ||
| 804 | + local roleId = role:getProperty("id") | ||
| 805 | + | ||
| 806 | + local pvpHGTime = self:getProperty("pvpHGTime") | ||
| 807 | + if pvpHGTime == 0 then return end | ||
| 808 | + local score = role:unpackPvpScore(redisproxy:zscore(role:getPvpDBKey(RANK_PVP_HIGHT), roleId)) | ||
| 809 | + | ||
| 810 | + local divisionId = nil | ||
| 811 | + for _id, division in ipairs(csvdb["pvp_group_divisionCsv"]) do | ||
| 812 | + if score >= division.division then | ||
| 813 | + divisionId = _id | ||
| 814 | + else | ||
| 815 | + break | ||
| 816 | + end | ||
| 817 | + end | ||
| 818 | + | ||
| 819 | + local newTime, newReward = role:calculatePvpHGift(divisionId) | ||
| 820 | + if not next(newReward) then return end | ||
| 821 | + | ||
| 822 | + self:updateProperties({ | ||
| 823 | + pvpHGTime = newTime, | ||
| 824 | + pvpHGift = {}, | ||
| 825 | + }) | ||
| 826 | + | ||
| 827 | + local reward = role:award(newReward) | ||
| 828 | + | ||
| 829 | + SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack({reward = reward})) | ||
| 830 | + return true | ||
| 831 | +end | ||
| 832 | + | ||
| 833 | +function _M.shopBuyRpc(agent, data) | ||
| 834 | + local role = agent.role | ||
| 835 | + local roleId = role:getProperty("id") | ||
| 836 | + | ||
| 837 | + local msg = MsgPack.unpack(data) | ||
| 838 | + local id = msg.id | ||
| 839 | + local count = msg.count or 1 | ||
| 840 | + | ||
| 841 | + local csvData = csvdb["shop_pvpCsv"][id] | ||
| 842 | + if not csvData then return end | ||
| 843 | + | ||
| 844 | + local pvpShop = role:getProperty("pvpShop") | ||
| 845 | + if csvData.limit > 0 then | ||
| 846 | + if math.illegalNum(count, 1, csvData.limit - (pvpShop[id] or 0)) then return end | ||
| 847 | + end | ||
| 848 | + | ||
| 849 | + if not role:checkItemEnough({[ItemId.PvpCoin] = csvData.cost * count}) then return end | ||
| 850 | + | ||
| 851 | + role:costItems({[ItemId.PvpCoin] = csvData.cost * count}) | ||
| 852 | + if csvData.limit > 0 then | ||
| 853 | + role:changeUpdates({{type = "pvpShop", field = id, value = (pvpShop[id] or 0) + count}}) | ||
| 854 | + end | ||
| 855 | + | ||
| 856 | + local gift = csvData.gift:toNumMap() | ||
| 857 | + for id, c in pairs(gift) do | ||
| 858 | + gift[id] = c * count | ||
| 859 | + end | ||
| 860 | + local reward = role:award(gift) | ||
| 861 | + | ||
| 862 | + | ||
| 863 | + SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack({reward = reward})) | ||
| 864 | + return true | ||
| 865 | +end | ||
| 866 | + | ||
| 787 | return _M | 867 | return _M |
| 788 | \ No newline at end of file | 868 | \ No newline at end of file |
src/actions/RoleAction.lua
| @@ -22,7 +22,7 @@ local function validName(name) | @@ -22,7 +22,7 @@ local function validName(name) | ||
| 22 | local exist = redisproxy:exists(string_format("user:%s", name)) | 22 | local exist = redisproxy:exists(string_format("user:%s", name)) |
| 23 | if exist then return "existed" end | 23 | if exist then return "existed" end |
| 24 | 24 | ||
| 25 | - local SERV = string_format("NAMED%d", math.random(1, 5)) | 25 | + local SERV = string_format(".NAMED%d", math.random(1, 5)) |
| 26 | local legal = skynet.call(SERV, "lua", "check", name) | 26 | local legal = skynet.call(SERV, "lua", "check", name) |
| 27 | return legal and "ok" or "illegal" | 27 | return legal and "ok" or "illegal" |
| 28 | end | 28 | end |
| @@ -119,8 +119,7 @@ function _M.loginRpc( agent, data ) | @@ -119,8 +119,7 @@ function _M.loginRpc( agent, data ) | ||
| 119 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 | 119 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 |
| 120 | 120 | ||
| 121 | -- 跨天登陆事件 | 121 | -- 跨天登陆事件 |
| 122 | - role:onCrossDay(now) | ||
| 123 | - role:onResetRank(now) | 122 | + role:updateTimeReset(now) |
| 124 | role:setProperty("ltime", now) | 123 | role:setProperty("ltime", now) |
| 125 | redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) | 124 | redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) |
| 126 | 125 | ||
| @@ -217,7 +216,7 @@ function _M.loginRpc( agent, data ) | @@ -217,7 +216,7 @@ function _M.loginRpc( agent, data ) | ||
| 217 | 216 | ||
| 218 | -- 发下缓存的世界消息 | 217 | -- 发下缓存的世界消息 |
| 219 | local worldChatResponse = {worldChats = {}} | 218 | local worldChatResponse = {worldChats = {}} |
| 220 | - local ok, msgs = pcall(skynet.call, 'GLOBALD', "lua", "getWorldMsg", role._channelIdx) | 219 | + local ok, msgs = pcall(skynet.call, '.GLOBALD', "lua", "getWorldMsg", role._channelIdx) |
| 221 | if not ok then | 220 | if not ok then |
| 222 | msgs = {} | 221 | msgs = {} |
| 223 | end | 222 | end |
| @@ -246,7 +245,7 @@ function _M.loginRpc( agent, data ) | @@ -246,7 +245,7 @@ function _M.loginRpc( agent, data ) | ||
| 246 | role:saveHangTeam() | 245 | role:saveHangTeam() |
| 247 | role:savePvpCTeam() | 246 | role:savePvpCTeam() |
| 248 | 247 | ||
| 249 | - role:log("login", {ip = agent.ip}) | 248 | + role:log("login", {key1 = agent.ip:toArray(false, ":")[1]}) |
| 250 | 249 | ||
| 251 | return true | 250 | return true |
| 252 | end | 251 | end |
| @@ -297,7 +296,7 @@ function _M.createRpc(agent, data) | @@ -297,7 +296,7 @@ function _M.createRpc(agent, data) | ||
| 297 | -- 欢迎邮件 | 296 | -- 欢迎邮件 |
| 298 | redisproxy:insertEmail({roleId = roleId, emailId = 1}) | 297 | redisproxy:insertEmail({roleId = roleId, emailId = 1}) |
| 299 | 298 | ||
| 300 | - newRole:log("create", { ip = agent.ip}) | 299 | + newRole:log("create", {key1 = agent.ip:toArray(false, ":")[1]}) |
| 301 | 300 | ||
| 302 | SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) | 301 | SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) |
| 303 | return true | 302 | return true |
| @@ -357,7 +356,7 @@ function _M.changeIntroRpc(agent, data) | @@ -357,7 +356,7 @@ function _M.changeIntroRpc(agent, data) | ||
| 357 | local content = msg.content | 356 | local content = msg.content |
| 358 | if not content or type(content) ~= "string" then return end | 357 | if not content or type(content) ~= "string" then return end |
| 359 | 358 | ||
| 360 | - local SERV = string_format("CHATED%d", math.random(1, 5)) | 359 | + local SERV = string_format(".CHATED%d", math.random(1, 5)) |
| 361 | local legal, mod = skynet.call(SERV, "lua", "check", content) | 360 | local legal, mod = skynet.call(SERV, "lua", "check", content) |
| 362 | if not legal then | 361 | if not legal then |
| 363 | content = mod or "" | 362 | content = mod or "" |
| @@ -472,9 +471,8 @@ function _M.openTimeBoxRpc(agent, data) | @@ -472,9 +471,8 @@ function _M.openTimeBoxRpc(agent, data) | ||
| 472 | local boxId = boxL[slot].id | 471 | local boxId = boxL[slot].id |
| 473 | local itemData = csvdb["itemCsv"][boxId] | 472 | local itemData = csvdb["itemCsv"][boxId] |
| 474 | local randomData = csvdb["item_randomCsv"][itemData.id] | 473 | local randomData = csvdb["item_randomCsv"][itemData.id] |
| 475 | - reward = randomData.gift:toNumMap() -- 固定奖励 | ||
| 476 | -- 随机奖励 | 474 | -- 随机奖励 |
| 477 | - local reward = {} | 475 | + reward = {} |
| 478 | for i = 1, 10 do | 476 | for i = 1, 10 do |
| 479 | local num = randomData["num" .. i] | 477 | local num = randomData["num" .. i] |
| 480 | local gift = randomData["gift" .. i] | 478 | local gift = randomData["gift" .. i] |
| @@ -743,7 +741,7 @@ function _M.chatRpc(agent, data) | @@ -743,7 +741,7 @@ function _M.chatRpc(agent, data) | ||
| 743 | -- 判断禁言 | 741 | -- 判断禁言 |
| 744 | local result = nil | 742 | local result = nil |
| 745 | 743 | ||
| 746 | - local SERV = string_format("CHATED%d", math.random(1, 5)) | 744 | + local SERV = string_format(".CHATED%d", math.random(1, 5)) |
| 747 | local legal, mod = skynet.call(SERV, "lua", "check", content) | 745 | local legal, mod = skynet.call(SERV, "lua", "check", content) |
| 748 | if not legal then | 746 | if not legal then |
| 749 | content = mod or "" | 747 | content = mod or "" |
| @@ -798,7 +796,7 @@ function _M.chatRpc(agent, data) | @@ -798,7 +796,7 @@ function _M.chatRpc(agent, data) | ||
| 798 | end | 796 | end |
| 799 | end | 797 | end |
| 800 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) | 798 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) |
| 801 | - pcall(skynet.send, 'GLOBALD', "lua", "sendWorldMsg", role._channelIdx, response) | 799 | + pcall(skynet.send, '.GLOBALD', "lua", "sendWorldMsg", role._channelIdx, response) |
| 802 | end, | 800 | end, |
| 803 | -- 私聊 | 801 | -- 私聊 |
| 804 | [2] = function () | 802 | [2] = function () |
src/agent.lua
| @@ -5,7 +5,6 @@ require "GlobalVar" | @@ -5,7 +5,6 @@ require "GlobalVar" | ||
| 5 | require "RedisKeys" | 5 | require "RedisKeys" |
| 6 | require "skynet.manager" | 6 | require "skynet.manager" |
| 7 | 7 | ||
| 8 | -local harbor = require "skynet.harbor" | ||
| 9 | local queue = require "skynet.queue" | 8 | local queue = require "skynet.queue" |
| 10 | local netpack = require "skynet.netpack" | 9 | local netpack = require "skynet.netpack" |
| 11 | local socket = require "skynet.socket" | 10 | local socket = require "skynet.socket" |
| @@ -115,7 +114,11 @@ function rpcRole(roleId, funcName, ...) | @@ -115,7 +114,11 @@ function rpcRole(roleId, funcName, ...) | ||
| 115 | end | 114 | end |
| 116 | else | 115 | else |
| 117 | local roleCross = require("models.RoleCross") | 116 | local roleCross = require("models.RoleCross") |
| 118 | - return false, roleCross.handle(funcName, roleId, ...) | 117 | + if funcName == "getProperties" then |
| 118 | + return false, roleCross.handle(funcName, roleId, fields) | ||
| 119 | + else | ||
| 120 | + return false, roleCross.handle(funcName, roleId, ...) | ||
| 121 | + end | ||
| 119 | end | 122 | end |
| 120 | end | 123 | end |
| 121 | 124 | ||
| @@ -236,13 +239,12 @@ function CMD.close() | @@ -236,13 +239,12 @@ function CMD.close() | ||
| 236 | mcast_util.usub_union() | 239 | mcast_util.usub_union() |
| 237 | local role = agentInfo.role | 240 | local role = agentInfo.role |
| 238 | if not role then return end | 241 | if not role then return end |
| 239 | - role:log("logout", {online = skynet.timex()-role:getProperty("ltime")}) | 242 | + role:log("logout", {int1 = skynet.timex()-role:getProperty("ltime")}) |
| 240 | role:onOfflineEvent() | 243 | role:onOfflineEvent() |
| 241 | end | 244 | end |
| 242 | 245 | ||
| 243 | function CMD.exit() | 246 | function CMD.exit() |
| 244 | if agentInfo.role then | 247 | if agentInfo.role then |
| 245 | - -- role:log("logout", {online = skynet.timex()-role:getProperty("ltime")}) | ||
| 246 | datacenter.set("agent", agentInfo.role:getProperty("id"), nil) | 248 | datacenter.set("agent", agentInfo.role:getProperty("id"), nil) |
| 247 | end | 249 | end |
| 248 | skynet.exit() | 250 | skynet.exit() |
| @@ -298,9 +300,9 @@ skynet.start(function() | @@ -298,9 +300,9 @@ skynet.start(function() | ||
| 298 | end | 300 | end |
| 299 | end) | 301 | end) |
| 300 | 302 | ||
| 301 | - redisd = harbor.queryname("REDIS") | 303 | + redisd = skynet.localname(".REDIS") |
| 302 | if tonumber(skynet.getenv "logd") == 1 then | 304 | if tonumber(skynet.getenv "logd") == 1 then |
| 303 | - logd = harbor.queryname("LOGD") | 305 | + logd = skynet.localname(".LOGD") |
| 304 | end | 306 | end |
| 305 | 307 | ||
| 306 | cs = queue() | 308 | cs = queue() |
src/models/RolePvp.lua
| @@ -22,13 +22,14 @@ end | @@ -22,13 +22,14 @@ end | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | 24 | function Role:changePvpScore(rankKey, changeScoreCallback, matchId) |
| 25 | + local dbKey = self:getPvpDBKey(rankKey) | ||
| 25 | local roleId = self:getProperty("id") | 26 | local roleId = self:getProperty("id") |
| 26 | local isPlayer = matchId ~= -1 | 27 | local isPlayer = matchId ~= -1 |
| 27 | local redret = redisproxy:pipelining(function(red) | 28 | local redret = redisproxy:pipelining(function(red) |
| 28 | - red:zscore(rankKey, roleId) | ||
| 29 | - red:zrevrank(rankKey, roleId) | 29 | + red:zscore(dbKey, roleId) |
| 30 | + red:zrevrank(dbKey, roleId) | ||
| 30 | if isPlayer then | 31 | if isPlayer then |
| 31 | - red:zscore(rankKey, matchId) | 32 | + red:zscore(dbKey, matchId) |
| 32 | end | 33 | end |
| 33 | end) | 34 | end) |
| 34 | local myScore = self:unpackPvpScore(redret[1]) | 35 | local myScore = self:unpackPvpScore(redret[1]) |
| @@ -45,11 +46,11 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | @@ -45,11 +46,11 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | ||
| 45 | 46 | ||
| 46 | local now = skynet.timex() | 47 | local now = skynet.timex() |
| 47 | redret = redisproxy:pipelining(function(red) | 48 | redret = redisproxy:pipelining(function(red) |
| 48 | - red:zadd(rankKey, self:packPvpScore(myScore, now), roleId) | 49 | + red:zadd(dbKey, self:packPvpScore(myScore, now), roleId) |
| 49 | if isPlayer then | 50 | if isPlayer then |
| 50 | - red:zadd(rankKey, self:packPvpScore(matchScore, now), matchId) | 51 | + red:zadd(dbKey, self:packPvpScore(matchScore, now), matchId) |
| 51 | end | 52 | end |
| 52 | - red:zrevrank(rankKey, roleId) | 53 | + red:zrevrank(dbKey, roleId) |
| 53 | end) | 54 | end) |
| 54 | 55 | ||
| 55 | local myRank | 56 | local myRank |
| @@ -81,18 +82,42 @@ function Role:changePvpScoreCommon(matchId, isWin) | @@ -81,18 +82,42 @@ function Role:changePvpScoreCommon(matchId, isWin) | ||
| 81 | return table.unpack(result) | 82 | return table.unpack(result) |
| 82 | end | 83 | end |
| 83 | 84 | ||
| 85 | +function Role:calculatePvpHGift(division) | ||
| 86 | + local now = skynet.timex() | ||
| 87 | + local oldTime = self:getProperty("pvpHGTime") | ||
| 88 | + local oldReward = self:getProperty("pvpHGift") | ||
| 89 | + | ||
| 90 | + local newTime = oldTime | ||
| 91 | + local newReward = clone(oldReward) | ||
| 92 | + | ||
| 93 | + local divisionData = csvdb["pvp_group_divisionCsv"][division] | ||
| 94 | + if oldTime == 0 then | ||
| 95 | + newTime = now | ||
| 96 | + else | ||
| 97 | + local times = math.floor((now - oldTime) / globalCsv.pvp_high_reward_add_pre) | ||
| 98 | + newTime = oldTime + times * globalCsv.pvp_high_reward_add_pre | ||
| 99 | + | ||
| 100 | + for itemId, count in pairs(divisionData.reward:toNumMap()) do | ||
| 101 | + newReward[itemId] = math.min((newReward[itemId] or 0) + count, divisionData.limit) | ||
| 102 | + end | ||
| 103 | + end | ||
| 104 | + return newTime, newReward | ||
| 105 | +end | ||
| 106 | + | ||
| 84 | function Role:changePvpScoreHigh(matchId, isWin) | 107 | function Role:changePvpScoreHigh(matchId, isWin) |
| 108 | + local oldMyDivision | ||
| 85 | local function changeScoreCallback(myScore, matchScore) | 109 | local function changeScoreCallback(myScore, matchScore) |
| 86 | - local myMinScore = 0 | ||
| 87 | - local matchMinScore = 0 | ||
| 88 | - for _, division in ipairs(csvdb["pvp_group_divisionCsv"]) do | 110 | + local myMinId = 0 |
| 111 | + local matchMinId = 0 | ||
| 112 | + for _id, division in ipairs(csvdb["pvp_group_divisionCsv"]) do | ||
| 89 | if myScore >= division.division then | 113 | if myScore >= division.division then |
| 90 | - myMinScore = division.division | 114 | + myMinId = _id |
| 91 | end | 115 | end |
| 92 | if matchScore >= division.division then | 116 | if matchScore >= division.division then |
| 93 | - matchMinScore = division.division | 117 | + matchMinId = _id |
| 94 | end | 118 | end |
| 95 | end | 119 | end |
| 120 | + oldMyDivision = myMinId | ||
| 96 | if isWin then | 121 | if isWin then |
| 97 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) | 122 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
| 98 | myScore = myScore + scoreChange | 123 | myScore = myScore + scoreChange |
| @@ -102,10 +127,28 @@ function Role:changePvpScoreHigh(matchId, isWin) | @@ -102,10 +127,28 @@ function Role:changePvpScoreHigh(matchId, isWin) | ||
| 102 | myScore = myScore - scoreChange | 127 | myScore = myScore - scoreChange |
| 103 | matchScore = matchScore + scoreChange | 128 | matchScore = matchScore + scoreChange |
| 104 | end | 129 | end |
| 105 | - return math.max(myScore, myMinScore), math.max(matchScore, matchMinScore) | 130 | + return math.max(myScore, csvdb["pvp_group_divisionCsv"][myMinId].division), math.max(matchScore, csvdb["pvp_group_divisionCsv"][matchMinId].division) |
| 106 | end | 131 | end |
| 107 | 132 | ||
| 108 | local result = self:changePvpScore(RANK_PVP_HIGHT, changeScoreCallback, matchId) | 133 | local result = self:changePvpScore(RANK_PVP_HIGHT, changeScoreCallback, matchId) |
| 134 | + --{myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank} | ||
| 135 | + local newDivision = nil | ||
| 136 | + for _id, division in ipairs(csvdb["pvp_group_divisionCsv"]) do | ||
| 137 | + if result[1] >= division.division then | ||
| 138 | + newDivision = _id | ||
| 139 | + else | ||
| 140 | + break | ||
| 141 | + end | ||
| 142 | + end | ||
| 143 | + if newDivision ~= oldMyDivision then | ||
| 144 | + --刷新段位奖励 | ||
| 145 | + local newTime, newReward = self:calculatePvpHGift(oldMyDivision) | ||
| 146 | + self:updateProperties({ | ||
| 147 | + pvpHGTime = newTime, | ||
| 148 | + pvpHGift = newReward, | ||
| 149 | + }) | ||
| 150 | + end | ||
| 151 | + | ||
| 109 | self:refreshPvpMatchH(result[1]) | 152 | self:refreshPvpMatchH(result[1]) |
| 110 | return table.unpack(result) | 153 | return table.unpack(result) |
| 111 | end | 154 | end |
| @@ -122,20 +165,21 @@ function Role:refreshPvpMatch(score, rankKey) | @@ -122,20 +165,21 @@ function Role:refreshPvpMatch(score, rankKey) | ||
| 122 | } | 165 | } |
| 123 | local mField = Fields[rankKey] | 166 | local mField = Fields[rankKey] |
| 124 | local robotCsv = RobotCsvs[rankKey] | 167 | local robotCsv = RobotCsvs[rankKey] |
| 168 | + local dbKey = self:getPvpDBKey(rankKey) | ||
| 125 | 169 | ||
| 126 | local roleId = self:getProperty("id") | 170 | local roleId = self:getProperty("id") |
| 127 | - score = score or self:unpackPvpScore(redisproxy:zscore(rankKey, roleId)) | 171 | + score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) |
| 128 | 172 | ||
| 129 | local function getPlayers(levels) | 173 | local function getPlayers(levels) |
| 130 | local redret = redisproxy:pipelining(function(red) | 174 | local redret = redisproxy:pipelining(function(red) |
| 131 | for _, level in ipairs(levels) do | 175 | for _, level in ipairs(levels) do |
| 132 | local low, high = table.unpack(level) | 176 | local low, high = table.unpack(level) |
| 133 | - red:zadd(rankKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") | ||
| 134 | - red:zadd(rankKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | ||
| 135 | - red:ZREVRANK(rankKey, "std_temp1") | ||
| 136 | - red:ZREVRANK(rankKey, "std_temp2") | 177 | + red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") |
| 178 | + red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | ||
| 179 | + red:ZREVRANK(dbKey, "std_temp1") | ||
| 180 | + red:ZREVRANK(dbKey, "std_temp2") | ||
| 137 | end | 181 | end |
| 138 | - red:zrem(rankKey, "std_temp1", "std_temp2") | 182 | + red:zrem(dbKey, "std_temp1", "std_temp2") |
| 139 | end) | 183 | end) |
| 140 | 184 | ||
| 141 | local PreGetCount = 7 | 185 | local PreGetCount = 7 |
| @@ -147,7 +191,7 @@ function Role:refreshPvpMatch(score, rankKey) | @@ -147,7 +191,7 @@ function Role:refreshPvpMatch(score, rankKey) | ||
| 147 | rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) | 191 | rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) |
| 148 | rank1 = rank2 + PreGetCount - 1 | 192 | rank1 = rank2 + PreGetCount - 1 |
| 149 | end | 193 | end |
| 150 | - red:ZREVRANGE(rankKey, rank2, rank1) | 194 | + red:ZREVRANGE(dbKey, rank2, rank1) |
| 151 | end | 195 | end |
| 152 | end) | 196 | end) |
| 153 | return redret | 197 | return redret |
| @@ -288,6 +332,26 @@ function Role:refreshPvpMatchH(score) | @@ -288,6 +332,26 @@ function Role:refreshPvpMatchH(score) | ||
| 288 | self:refreshPvpMatch(score, RANK_PVP_HIGHT) | 332 | self:refreshPvpMatch(score, RANK_PVP_HIGHT) |
| 289 | end | 333 | end |
| 290 | 334 | ||
| 335 | +function Role:getPvpDBKey(ptype) | ||
| 336 | + local dbList | ||
| 337 | + local round | ||
| 338 | + if ptype == RANK_PVP_COMMON then | ||
| 339 | + dbList = RANK_PVP_COMMON_KEY | ||
| 340 | + round = self:getTimeResetRound(TimeReset.PvpRank) | ||
| 341 | + elseif ptype == RANK_PVP_HIGHT then | ||
| 342 | + dbList = RANK_PVP_HIGHT_KEY | ||
| 343 | + round = self:getTimeResetRound(TimeReset.PvpHight) | ||
| 344 | + end | ||
| 345 | + local idx = 1 | ||
| 346 | + if round % 2 == 1 then | ||
| 347 | + idx = 2 | ||
| 348 | + end | ||
| 349 | + return dbList[idx] | ||
| 350 | +end | ||
| 351 | + | ||
| 352 | + | ||
| 353 | + | ||
| 354 | + | ||
| 291 | end | 355 | end |
| 292 | 356 | ||
| 293 | 357 |