From 53227d9c2f3b86eb471baaa5c73885d46c625bd9 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Mon, 7 Dec 2020 14:51:40 +0800 Subject: [PATCH] pvp 编队胜利推送 --- src/actions/PvpAction.lua | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- src/models/RolePvp.lua | 22 ++++++++++++++++++---- 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/src/actions/PvpAction.lua b/src/actions/PvpAction.lua index c72c33d..ee2c295 100644 --- a/src/actions/PvpAction.lua +++ b/src/actions/PvpAction.lua @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 local RevengeWaitTime = 60 function _M.formatCommonRpc(agent , data) + if true then return end local role = agent.role local roleId = role:getProperty("id") local msg = MsgPack.unpack(data) @@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) local role = agent.role local roleId = role:getProperty("id") local msg = MsgPack.unpack(data) - + + if not role:isCrossServerPvpPlayer() then return end local pvpTH = {} local had = {} -- 上阵的角色 local supportHad = {} @@ -258,6 +260,36 @@ function _M.startBattleRpc(agent, data) local pvpTC = role:getProperty("pvpTC") if not pvpTC.heros or not next(pvpTC.heros) then return 1 end + local team = msg.team + if not team then return end + + for slot, heroId in pairs(team.heros or {}) do + if not role.heros[heroId] then + return + end + end + if not team.heros or not next(team.heros) then + return + end + local supports = {} + for slot, support in pairs(team.supports) do + if slot ~= 1 and slot ~= 2 then return end + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) + if level <= 0 then return end + supports[slot] = support + end + + local pvpTC = {} + pvpTC.heros = {} + for slot, heroId in pairs(team.heros) do + pvpTC.heros[slot] = heroId + end + pvpTC.leader = team.leader + pvpTC.supports = supports + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then + pvpTC.tactics = team.tactics + end + local matchInfo, result, key, wait local now = skynet.timex() @@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) end key = tostring(math.random()) - _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC} role:checkTaskEnter("PvpBattle") @@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 + -- 失败了没再排行榜 不计入 + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_COMMON)) then + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank= role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) + end + if isWin then + -- 记录编队 + role:savePvpCTeam(_pvpStartBattleCacheC.pvpTC) + end -- 请求上传录像 local params = { @@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) curTeam.tactics = team.tactics end - table.insert(pvpTH, curTeam) end @@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) -- 战斗结束了发奖 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 - if role:isTimeResetOpen(TimeReset.PvpHight) then - myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) + + + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 + -- 失败了没再排行榜 不计入 + if role:isTimeResetOpen(TimeReset.PvpHight) then + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_HIGHT)) then + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) + end + -- 记录编队 + if isWin then + role:savePvpHTeam(_pvpStartBattleCacheH.pvpTH) + end end -- 加入战斗记录 diff --git a/src/models/RolePvp.lua b/src/models/RolePvp.lua index 1b7f60d..4bfe882 100644 --- a/src/models/RolePvp.lua +++ b/src/models/RolePvp.lua @@ -6,7 +6,7 @@ RolePvp.bind = function (Role) local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 -local PVP_RANK_ROBOT_SCORE = globalCsv.pvp_base_score -- 机器人积分 +local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 机器人积分 function Role:unpackPvpScore(score) @@ -34,7 +34,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) end) local myScore = self:unpackPvpScore(redret[1]) local oldMyRank = tonumber(redret[2] or -2) + 1 - local matchScore = PVP_RANK_ROBOT_SCORE + local matchScore = PVP_RANK_BASE_SCORE if isPlayer then matchScore = self:unpackPvpScore(redret[3]) end @@ -68,7 +68,7 @@ function Role:changePvpScoreCommon(matchId, isWin) if isWin then local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) myScore = myScore + scoreChange - matchScore = matchScore - scoreChange + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 else local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) myScore = myScore - scoreChange @@ -134,7 +134,7 @@ function Role:changePvpScoreHigh(matchId, isWin) if isWin then local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) myScore = myScore + scoreChange - matchScore = matchScore - scoreChange + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 else local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) myScore = myScore - scoreChange @@ -166,6 +166,20 @@ function Role:changePvpScoreHigh(matchId, isWin) return table.unpack(result) end +function Role:isInPvpRank(rankKey) + local Fields = { + [RANK_PVP_COMMON] = "pvpMC", + [RANK_PVP_HIGHT] = "pvpMH", + } + local dbKey = self:getPvpDBKey(rankKey) + local roleId = self:getProperty("id") + if redisproxy:zscore(dbKey, roleId) then + return true + end + return false +end + + function Role:refreshPvpMatch(score, rankKey) local Fields = { -- libgit2 0.21.2