Commit 53227d9c2f3b86eb471baaa5c73885d46c625bd9
1 parent
e8ca14c4
pvp 编队胜利推送
Showing
2 changed files
with
73 additions
and
11 deletions
Show diff stats
src/actions/PvpAction.lua
@@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 | @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 | ||
23 | local RevengeWaitTime = 60 | 23 | local RevengeWaitTime = 60 |
24 | 24 | ||
25 | function _M.formatCommonRpc(agent , data) | 25 | function _M.formatCommonRpc(agent , data) |
26 | + if true then return end | ||
26 | local role = agent.role | 27 | local role = agent.role |
27 | local roleId = role:getProperty("id") | 28 | local roleId = role:getProperty("id") |
28 | local msg = MsgPack.unpack(data) | 29 | local msg = MsgPack.unpack(data) |
@@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) | @@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) | ||
63 | local role = agent.role | 64 | local role = agent.role |
64 | local roleId = role:getProperty("id") | 65 | local roleId = role:getProperty("id") |
65 | local msg = MsgPack.unpack(data) | 66 | local msg = MsgPack.unpack(data) |
66 | - | 67 | + |
68 | + if not role:isCrossServerPvpPlayer() then return end | ||
67 | local pvpTH = {} | 69 | local pvpTH = {} |
68 | local had = {} -- 上阵的角色 | 70 | local had = {} -- 上阵的角色 |
69 | local supportHad = {} | 71 | local supportHad = {} |
@@ -258,6 +260,36 @@ function _M.startBattleRpc(agent, data) | @@ -258,6 +260,36 @@ function _M.startBattleRpc(agent, data) | ||
258 | local pvpTC = role:getProperty("pvpTC") | 260 | local pvpTC = role:getProperty("pvpTC") |
259 | if not pvpTC.heros or not next(pvpTC.heros) then return 1 end | 261 | if not pvpTC.heros or not next(pvpTC.heros) then return 1 end |
260 | 262 | ||
263 | + local team = msg.team | ||
264 | + if not team then return end | ||
265 | + | ||
266 | + for slot, heroId in pairs(team.heros or {}) do | ||
267 | + if not role.heros[heroId] then | ||
268 | + return | ||
269 | + end | ||
270 | + end | ||
271 | + if not team.heros or not next(team.heros) then | ||
272 | + return | ||
273 | + end | ||
274 | + local supports = {} | ||
275 | + for slot, support in pairs(team.supports) do | ||
276 | + if slot ~= 1 and slot ~= 2 then return end | ||
277 | + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) | ||
278 | + if level <= 0 then return end | ||
279 | + supports[slot] = support | ||
280 | + end | ||
281 | + | ||
282 | + local pvpTC = {} | ||
283 | + pvpTC.heros = {} | ||
284 | + for slot, heroId in pairs(team.heros) do | ||
285 | + pvpTC.heros[slot] = heroId | ||
286 | + end | ||
287 | + pvpTC.leader = team.leader | ||
288 | + pvpTC.supports = supports | ||
289 | + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then | ||
290 | + pvpTC.tactics = team.tactics | ||
291 | + end | ||
292 | + | ||
261 | local matchInfo, result, key, wait | 293 | local matchInfo, result, key, wait |
262 | 294 | ||
263 | local now = skynet.timex() | 295 | local now = skynet.timex() |
@@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) | @@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) | ||
299 | end | 331 | end |
300 | 332 | ||
301 | key = tostring(math.random()) | 333 | key = tostring(math.random()) |
302 | - _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} | 334 | + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC} |
303 | 335 | ||
304 | role:checkTaskEnter("PvpBattle") | 336 | role:checkTaskEnter("PvpBattle") |
305 | 337 | ||
@@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) | @@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) | ||
342 | 374 | ||
343 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) | 375 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) |
344 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) | 376 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) |
345 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) | 377 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 |
378 | + -- 失败了没再排行榜 不计入 | ||
379 | + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_COMMON)) then | ||
380 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank= role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) | ||
381 | + end | ||
382 | + if isWin then | ||
383 | + -- 记录编队 | ||
384 | + role:savePvpCTeam(_pvpStartBattleCacheC.pvpTC) | ||
385 | + end | ||
346 | 386 | ||
347 | -- 请求上传录像 | 387 | -- 请求上传录像 |
348 | local params = { | 388 | local params = { |
@@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) | @@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) | ||
472 | curTeam.tactics = team.tactics | 512 | curTeam.tactics = team.tactics |
473 | end | 513 | end |
474 | 514 | ||
475 | - | ||
476 | table.insert(pvpTH, curTeam) | 515 | table.insert(pvpTH, curTeam) |
477 | end | 516 | end |
478 | 517 | ||
@@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) | @@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) | ||
644 | -- 战斗结束了发奖 | 683 | -- 战斗结束了发奖 |
645 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) | 684 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
646 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) | 685 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) |
647 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 | ||
648 | - if role:isTimeResetOpen(TimeReset.PvpHight) then | ||
649 | - myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | 686 | + |
687 | + | ||
688 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 | ||
689 | + -- 失败了没再排行榜 不计入 | ||
690 | + if role:isTimeResetOpen(TimeReset.PvpHight) then | ||
691 | + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_HIGHT)) then | ||
692 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | ||
693 | + end | ||
694 | + -- 记录编队 | ||
695 | + if isWin then | ||
696 | + role:savePvpHTeam(_pvpStartBattleCacheH.pvpTH) | ||
697 | + end | ||
650 | end | 698 | end |
651 | 699 | ||
652 | -- 加入战斗记录 | 700 | -- 加入战斗记录 |
src/models/RolePvp.lua
@@ -6,7 +6,7 @@ RolePvp.bind = function (Role) | @@ -6,7 +6,7 @@ RolePvp.bind = function (Role) | ||
6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 | 6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 |
7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 | 7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 |
8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 | 8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 |
9 | -local PVP_RANK_ROBOT_SCORE = globalCsv.pvp_base_score -- 机器人积分 | 9 | +local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 机器人积分 |
10 | 10 | ||
11 | 11 | ||
12 | function Role:unpackPvpScore(score) | 12 | function Role:unpackPvpScore(score) |
@@ -34,7 +34,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | @@ -34,7 +34,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | ||
34 | end) | 34 | end) |
35 | local myScore = self:unpackPvpScore(redret[1]) | 35 | local myScore = self:unpackPvpScore(redret[1]) |
36 | local oldMyRank = tonumber(redret[2] or -2) + 1 | 36 | local oldMyRank = tonumber(redret[2] or -2) + 1 |
37 | - local matchScore = PVP_RANK_ROBOT_SCORE | 37 | + local matchScore = PVP_RANK_BASE_SCORE |
38 | if isPlayer then | 38 | if isPlayer then |
39 | matchScore = self:unpackPvpScore(redret[3]) | 39 | matchScore = self:unpackPvpScore(redret[3]) |
40 | end | 40 | end |
@@ -68,7 +68,7 @@ function Role:changePvpScoreCommon(matchId, isWin) | @@ -68,7 +68,7 @@ function Role:changePvpScoreCommon(matchId, isWin) | ||
68 | if isWin then | 68 | if isWin then |
69 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) | 69 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) |
70 | myScore = myScore + scoreChange | 70 | myScore = myScore + scoreChange |
71 | - matchScore = matchScore - scoreChange | 71 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 |
72 | else | 72 | else |
73 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) | 73 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) |
74 | myScore = myScore - scoreChange | 74 | myScore = myScore - scoreChange |
@@ -134,7 +134,7 @@ function Role:changePvpScoreHigh(matchId, isWin) | @@ -134,7 +134,7 @@ function Role:changePvpScoreHigh(matchId, isWin) | ||
134 | if isWin then | 134 | if isWin then |
135 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) | 135 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
136 | myScore = myScore + scoreChange | 136 | myScore = myScore + scoreChange |
137 | - matchScore = matchScore - scoreChange | 137 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 |
138 | else | 138 | else |
139 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) | 139 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) |
140 | myScore = myScore - scoreChange | 140 | myScore = myScore - scoreChange |
@@ -166,6 +166,20 @@ function Role:changePvpScoreHigh(matchId, isWin) | @@ -166,6 +166,20 @@ function Role:changePvpScoreHigh(matchId, isWin) | ||
166 | return table.unpack(result) | 166 | return table.unpack(result) |
167 | end | 167 | end |
168 | 168 | ||
169 | +function Role:isInPvpRank(rankKey) | ||
170 | + local Fields = { | ||
171 | + [RANK_PVP_COMMON] = "pvpMC", | ||
172 | + [RANK_PVP_HIGHT] = "pvpMH", | ||
173 | + } | ||
174 | + local dbKey = self:getPvpDBKey(rankKey) | ||
175 | + local roleId = self:getProperty("id") | ||
176 | + if redisproxy:zscore(dbKey, roleId) then | ||
177 | + return true | ||
178 | + end | ||
179 | + return false | ||
180 | +end | ||
181 | + | ||
182 | + | ||
169 | function Role:refreshPvpMatch(score, rankKey) | 183 | function Role:refreshPvpMatch(score, rankKey) |
170 | 184 | ||
171 | local Fields = { | 185 | local Fields = { |