Commit 4c5d72abefc010938cfdea45528d6845971c7424

Authored by zhouhaihai
1 parent 9284512a

高级pvp

@@ -26,6 +26,8 @@ RANK_DINER_INFO = "rank:diner:info" @@ -26,6 +26,8 @@ RANK_DINER_INFO = "rank:diner:info"
26 RANK_PVP_COMMON = "rank:pvpc" 26 RANK_PVP_COMMON = "rank:pvpc"
27 RECORD_PVP_COMMON = "record:pvpc:%d" 27 RECORD_PVP_COMMON = "record:pvpc:%d"
28 RANK_PVP_HIGHT = "rank:pvph" 28 RANK_PVP_HIGHT = "rank:pvph"
  29 +RECORD_PVP_HIGH = "record:pvph:%d"
  30 +
29 31
30 32
31 33
src/actions/DinerAction.lua
@@ -769,6 +769,7 @@ function _M.entrustRpc(agent , data) @@ -769,6 +769,7 @@ function _M.entrustRpc(agent , data)
769 end 769 end
770 770
771 reward = role:award(curData.reward) 771 reward = role:award(curData.reward)
  772 + table.remove(entrust, 1)
772 elseif ctype == 2 then -- 放弃 773 elseif ctype == 2 then -- 放弃
773 table.remove(entrust, 1) 774 table.remove(entrust, 1)
774 else 775 else
src/actions/PvpAction.lua
@@ -9,10 +9,16 @@ local remoteUrl = skynet.getenv("codeurl") @@ -9,10 +9,16 @@ local remoteUrl = skynet.getenv("codeurl")
9 9
10 local _M = {} 10 local _M = {}
11 local _pvpBattleInfoCacheC = {} --查询列表 缓存pvp战斗相关数据缓存 11 local _pvpBattleInfoCacheC = {} --查询列表 缓存pvp战斗相关数据缓存
12 -local _pvpStartBattleCache = nil --  
13 -  
14 -local _pvpRecordInfoCache = {} -- 记录缓存  
15 -local _pvpRecordBattleInfoCache = {} -- 记录战斗数据缓存 12 +local _pvpBattleInfoCacheH = {} --查询列表 缓存pvp战斗相关数据缓存
  13 +local _pvpHeroInfoCacheH = {} --查询列表 缓存pvp 英雄相关数据缓存
  14 +local _pvpStartBattleCacheC = nil -- 当前战斗缓存
  15 +local _pvpStartBattleCacheH = nil -- 当前战斗缓存
  16 +
  17 +local _pvpRecordInfoCacheC = {} -- 记录缓存
  18 +local _pvpRecordInfoCacheH = {} -- 记录缓存
  19 +local _pvpRecordBattleInfoCacheC = {} -- 记录战斗数据缓存
  20 +local _pvpRecordBattleInfoCacheH = {} -- 记录战斗数据缓存
  21 +local _pvpRecordHeroInfoCacheH = {} --查询列表 缓存pvp 英雄相关数据缓存
16 local _revengeRecord = {} -- 复仇对单人1分钟间隔 22 local _revengeRecord = {} -- 复仇对单人1分钟间隔
17 local RevengeWaitTime = 60 23 local RevengeWaitTime = 60
18 24
@@ -50,13 +56,57 @@ function _M.formatCommonRpc(agent , data) @@ -50,13 +56,57 @@ function _M.formatCommonRpc(agent , data)
50 return true 56 return true
51 end 57 end
52 58
  59 +function _M.formatHighRpc(agent , data)
  60 + local role = agent.role
  61 + local roleId = role:getProperty("id")
  62 + local msg = MsgPack.unpack(data)
  63 +
  64 + local pvpTH = {}
  65 + local had = {} -- 上阵的角色
  66 + local supportHad = {}
  67 + for i = 1, 3 do
  68 + local team = msg.teams[i]
  69 + if not team then return end
  70 +
  71 + if not team.heros or not next(team.heros) then
  72 + return
  73 + end
53 74
54 -local function getMatchInfo(role, pvpList, battleCache) 75 + for slot, heroId in pairs(team.heros or {}) do
  76 + if not role.heros[heroId] or had[heroId] then
  77 + return
  78 + end
  79 + had[heroId] = 1
  80 + end
  81 +
  82 + local supports = {}
  83 + for slot, support in pairs(team.supports) do
  84 + if slot ~= 1 and slot ~= 2 then return end
  85 + local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
  86 + if level <= 0 or supportHad[support] then return end
  87 + supports[slot] = support
  88 + supportHad[support] = 1
  89 + end
  90 +
  91 + local curTeam = {}
  92 + curTeam.heros = team.heros
  93 + curTeam.leader = team.leader
  94 + curTeam.supports = supports
  95 +
  96 + table.insert(pvpTH, curTeam)
  97 + end
  98 +
  99 + role:savePvpHTeam(pvpTH)
  100 + SendPacket(actionCodes.Pvp_formatHighRpc, '')
  101 + return true
  102 +end
  103 +
  104 +local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, infoCache)
55 table.clear(battleCache) 105 table.clear(battleCache)
56 local redret = redisproxy:pipelining(function(red) 106 local redret = redisproxy:pipelining(function(red)
57 for _, info in ipairs(pvpList) do 107 for _, info in ipairs(pvpList) do
58 if info.t == 1 then 108 if info.t == 1 then
59 - red:zscore(RANK_PVP_COMMON, info.id) 109 + red:zscore(dbKey, info.id)
60 end 110 end
61 end 111 end
62 end) 112 end)
@@ -70,11 +120,14 @@ local function getMatchInfo(role, pvpList, battleCache) @@ -70,11 +120,14 @@ local function getMatchInfo(role, pvpList, battleCache)
70 curInfo.score = role:unpackPvpScore(redret[curIdx] or 0) 120 curInfo.score = role:unpackPvpScore(redret[curIdx] or 0)
71 curIdx = curIdx + 1 121 curIdx = curIdx + 1
72 -- name, level, headId, battleV, heros 122 -- name, level, headId, battleV, heros
73 - local online, roleInfo = rpcRole(curInfo.roleId, "pvpCInfo") 123 + local online, roleInfo = rpcRole(curInfo.roleId, infoFuncName)
74 for k , v in pairs(roleInfo) do 124 for k , v in pairs(roleInfo) do
75 if k == "battleInfo" then 125 if k == "battleInfo" then
76 battleCache[curInfo.roleId] = v 126 battleCache[curInfo.roleId] = v
77 else 127 else
  128 + if k == "heros" and infoCache then
  129 + infoCache[curInfo.roleId] = v
  130 + end
78 curInfo[k] = v 131 curInfo[k] = v
79 end 132 end
80 end 133 end
@@ -113,10 +166,25 @@ function _M.infoRpc(agent, data) @@ -113,10 +166,25 @@ function _M.infoRpc(agent, data)
113 166
114 response.rank = rank 167 response.rank = rank
115 response.score = score 168 response.score = score
116 - response.matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC)  
117 - 169 + response.matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC, RANK_PVP_COMMON, "pvpCInfo")
118 elseif ptype == 2 then -- 高级pvp 170 elseif ptype == 2 then -- 高级pvp
119 - return 171 + local redret = redisproxy:pipelining(function(red)
  172 + red:zscore(RANK_PVP_HIGHT, roleId)
  173 + red:zrevrank(RANK_PVP_HIGHT, roleId)
  174 + end)
  175 + local score = role:unpackPvpScore(redret[1])
  176 + local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp
  177 +
  178 + local pvpMH = role:getProperty("pvpMH")
  179 + if not next(pvpMH) then --没有分配过对手
  180 + role:refreshPvpMatchH(score)
  181 + pvpMH = role:getProperty("pvpMH")
  182 + end
  183 + if not next(pvpMH) then return end
  184 +
  185 + response.rank = rank
  186 + response.score = score
  187 + response.matches = getMatchInfo(role, pvpMH, _pvpBattleInfoCacheH, RANK_PVP_HIGHT, "pvpHInfo", _pvpHeroInfoCacheH)
120 else 188 else
121 return 189 return
122 end 190 end
@@ -130,12 +198,24 @@ function _M.refreshMatchCRpc(agent, data) @@ -130,12 +198,24 @@ function _M.refreshMatchCRpc(agent, data)
130 role:refreshPvpMatchC() 198 role:refreshPvpMatchC()
131 199
132 local pvpMC = role:getProperty("pvpMC") 200 local pvpMC = role:getProperty("pvpMC")
133 - local matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC) 201 + local matches = getMatchInfo(role, pvpMC, _pvpBattleInfoCacheC, RANK_PVP_COMMON, "pvpCInfo")
134 202
135 SendPacket(actionCodes.Pvp_refreshMatchCRpc, MsgPack.pack({matches = matches})) 203 SendPacket(actionCodes.Pvp_refreshMatchCRpc, MsgPack.pack({matches = matches}))
136 return true 204 return true
137 end 205 end
138 206
  207 +function _M.refreshMatchHRpc(agent, data)
  208 + local role = agent.role
  209 + local msg = MsgPack.unpack(data)
  210 + role:refreshPvpMatchH()
  211 +
  212 + local pvpMH = role:getProperty("pvpMH")
  213 + local matches = getMatchInfo(role, pvpMH, _pvpBattleInfoCacheH, RANK_PVP_HIGHT, "pvpHInfo", _pvpHeroInfoCacheH)
  214 +
  215 + SendPacket(actionCodes.Pvp_refreshMatchHRpc, MsgPack.pack({matches = matches}))
  216 + return true
  217 +end
  218 +
139 function _M.buyCountRpc(agent, data) 219 function _M.buyCountRpc(agent, data)
140 local role = agent.role 220 local role = agent.role
141 local msg = MsgPack.unpack(data) 221 local msg = MsgPack.unpack(data)
@@ -168,12 +248,12 @@ function _M.startBattleRpc(agent, data) @@ -168,12 +248,12 @@ function _M.startBattleRpc(agent, data)
168 248
169 local now = skynet.timex() 249 local now = skynet.timex()
170 if revenge then --复仇 250 if revenge then --复仇
171 - local temp = _pvpRecordInfoCache[idx] 251 + local temp = _pvpRecordInfoCacheC[idx]
172 if not temp then return 2 end 252 if not temp then return 2 end
173 253
174 if not _revengeRecord[temp.id] or now >= _revengeRecord[temp.id] then 254 if not _revengeRecord[temp.id] or now >= _revengeRecord[temp.id] then
175 if temp.t == 1 then 255 if temp.t == 1 then
176 - matchInfo = _pvpRecordBattleInfoCache[temp.id] 256 + matchInfo = _pvpRecordBattleInfoCacheC[temp.id]
177 elseif temp.t == 2 then 257 elseif temp.t == 2 then
178 matchInfo = {robot = temp.id} 258 matchInfo = {robot = temp.id}
179 end 259 end
@@ -205,7 +285,7 @@ function _M.startBattleRpc(agent, data) @@ -205,7 +285,7 @@ function _M.startBattleRpc(agent, data)
205 end 285 end
206 286
207 key = tostring(math.random()) 287 key = tostring(math.random())
208 - _pvpStartBattleCache = {idx = idx, key = key, revenge = revenge} 288 + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge}
209 289
210 role:checkTaskEnter("PvpBattle") 290 role:checkTaskEnter("PvpBattle")
211 end 291 end
@@ -219,21 +299,21 @@ function _M.endBattleRpc(agent, data) @@ -219,21 +299,21 @@ function _M.endBattleRpc(agent, data)
219 local roleId = role:getProperty("id") 299 local roleId = role:getProperty("id")
220 local msg = MsgPack.unpack(data) 300 local msg = MsgPack.unpack(data)
221 301
222 - if not msg.key or not _pvpStartBattleCache or msg.key ~= _pvpStartBattleCache.key then 302 + if not msg.key or not _pvpStartBattleCacheC or msg.key ~= _pvpStartBattleCacheC.key then
223 return 1 303 return 1
224 end 304 end
225 305
226 - if not msg.idx or msg.idx ~= _pvpStartBattleCache.idx then 306 + if not msg.idx or msg.idx ~= _pvpStartBattleCacheC.idx then
227 return 2 307 return 2
228 end 308 end
229 309
230 local isWin = msg.starNum and msg.starNum > 0 310 local isWin = msg.starNum and msg.starNum > 0
231 local now = skynet.timex() 311 local now = skynet.timex()
232 312
233 - local revenge = _pvpStartBattleCache.revenge 313 + local revenge = _pvpStartBattleCacheC.revenge
234 local match 314 local match
235 if revenge then 315 if revenge then
236 - match = _pvpRecordInfoCache[msg.idx] 316 + match = _pvpRecordInfoCacheC[msg.idx]
237 _revengeRecord[match.id] = now + RevengeWaitTime -- 1分钟内不能再打 317 _revengeRecord[match.id] = now + RevengeWaitTime -- 1分钟内不能再打
238 else 318 else
239 local pvpMC = role:getProperty("pvpMC") 319 local pvpMC = role:getProperty("pvpMC")
@@ -247,9 +327,9 @@ function _M.endBattleRpc(agent, data) @@ -247,9 +327,9 @@ function _M.endBattleRpc(agent, data)
247 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) 327 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin)
248 328
249 _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 329 _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病
250 - _pvpRecordInfoCache = {} -- 记录刷新了  
251 - _pvpRecordBattleInfoCache = {} -- 取新纪录的时候搞  
252 - _pvpStartBattleCache = nil 330 + _pvpRecordInfoCacheC = {} -- 记录刷新了
  331 + _pvpRecordBattleInfoCacheC = {} -- 取新纪录的时候搞
  332 + _pvpStartBattleCacheC = nil
253 333
254 -- 请求上传录像 334 -- 请求上传录像
255 local params = { 335 local params = {
@@ -310,6 +390,289 @@ function _M.endBattleRpc(agent, data) @@ -310,6 +390,289 @@ function _M.endBattleRpc(agent, data)
310 return true 390 return true
311 end 391 end
312 392
  393 +
  394 +function _M.startBattleHRpc(agent, data)
  395 + local role = agent.role
  396 + local msg = MsgPack.unpack(data)
  397 +
  398 + local idx = msg.idx
  399 + local revenge = msg.revenge
  400 +
  401 + local pvpTH = role:getProperty("pvpTH")
  402 + if not pvpTH.heros or not next(pvpTH.heros) then return 1 end
  403 +
  404 + -- 检查并记录玩家队伍
  405 + local pvpTH = {}
  406 + local had = {} -- 上阵的角色
  407 + local supportHad = {}
  408 + for i = 1, 3 do
  409 + local team = msg.teams[i]
  410 + if not team then return end
  411 +
  412 + if not team.heros or not next(team.heros) then
  413 + return
  414 + end
  415 +
  416 + for slot, heroId in pairs(team.heros or {}) do
  417 + if not role.heros[heroId] or had[heroId] then
  418 + return
  419 + end
  420 + had[heroId] = 1
  421 + end
  422 +
  423 + local supports = {}
  424 + for slot, support in pairs(team.supports) do
  425 + if slot ~= 1 and slot ~= 2 then return end
  426 + local level = role.dinerData:getProperty("dishTree"):getv(support, 0)
  427 + if level <= 0 or supportHad[support] then return end
  428 + supports[slot] = support
  429 + supportHad[support] = 1
  430 + end
  431 +
  432 + local curTeam = {}
  433 + curTeam.heros = team.heros
  434 + curTeam.leader = team.leader
  435 + curTeam.supports = supports
  436 +
  437 + table.insert(pvpTH, curTeam)
  438 + end
  439 +
  440 + local enemyTeamRecord, result, key, wait, enemyT, matchInfo
  441 +
  442 + local now = skynet.timex()
  443 + if revenge then --复仇
  444 + local temp = _pvpRecordInfoCacheH[idx]
  445 + if not temp then return 2 end
  446 +
  447 + if not _revengeRecord[temp.id] or now >= _revengeRecord[temp.id] then
  448 + if temp.t == 1 then
  449 + enemyTeamRecord = _pvpRecordBattleInfoCacheH[temp.id]
  450 + enemyT = _pvpRecordHeroInfoCacheH[temp.id]
  451 + elseif temp.t == 2 then
  452 + enemyTeamRecord = {robot = temp.id}
  453 + end
  454 + else
  455 + result = 1
  456 + wait = _revengeRecord[temp.id] - now
  457 + end
  458 + else --打正常
  459 + local pvpMH = role:getProperty("pvpMH")
  460 + if not pvpMH[idx] then return 3 end
  461 + if pvpMH[idx].t == 1 then
  462 + enemyTeamRecord = _pvpBattleInfoCacheH[pvpMH[idx].id]
  463 + enemyT = _pvpHeroInfoCacheH[temp.id]
  464 + elseif pvpMH[idx].t == 2 then
  465 + enemyTeamRecord = {robot = pvpMH[idx].id}
  466 + end
  467 + end
  468 +
  469 + if not result and not enemyTeamRecord then return 4 end
  470 +
  471 + if not result then
  472 + -- 次数扣一波
  473 + local pvpFreeH = role.dailyData:getProperty("pvpFreeH")
  474 + if pvpFreeH >= globalCsv.pvp_battle_free_count_high then
  475 + local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost}
  476 + if not role:checkItemEnough(cost) then return 5 end
  477 + role:costItems(cost)
  478 + else
  479 + role.dailyData:updateProperty({field = "pvpFreeH", delta = 1})
  480 + end
  481 +
  482 +
  483 + -- 只发送指定的那个敌人
  484 + if enemyTeamRecord.robot then
  485 + matchInfo = enemyTeamRecord
  486 + else
  487 + matchInfo = enemyTeamRecord[1]
  488 + end
  489 +
  490 + key = tostring(math.random())
  491 + _pvpStartBattleCacheH = {
  492 + idx = idx, -- 数据索引
  493 + key = key, -- 战斗校验 key
  494 + revenge = revenge, -- 是否是复仇
  495 + result = {}, -- 战斗记录
  496 + pvpTH = pvpTH, -- 我方队伍缓存
  497 + enemyTB = enemyTeamRecord, --敌方战斗队伍缓存
  498 + enemyT = enemyT,
  499 + }
  500 +
  501 + role:checkTaskEnter("PvpBattle")
  502 + end
  503 +
  504 + SendPacket(actionCodes.Pvp_startBattleHRpc, MsgPack.pack({
  505 + matchInfo = matchInfo, --敌方队伍 信息
  506 + key = key, --战斗校验 key
  507 + round = 1, -- 战斗场数索引
  508 + result = result, -- 返回状态
  509 + wait = wait -- 等待复仇时间
  510 + }))
  511 + return true
  512 +end
  513 +
  514 +function _M.endBattleHRpc(agent, data)
  515 + local role = agent.role
  516 + local roleId = role:getProperty("id")
  517 + local msg = MsgPack.unpack(data)
  518 +
  519 + if not msg.key or not _pvpStartBattleCacheH or msg.key ~= _pvpStartBattleCacheH.key then
  520 + return 1
  521 + end
  522 +
  523 + if not msg.idx or msg.idx ~= _pvpStartBattleCacheH.idx then
  524 + return 2
  525 + end
  526 +
  527 + local isWin = msg.starNum and msg.starNum > 0
  528 + local now = skynet.timex()
  529 +
  530 + local revenge = _pvpStartBattleCacheH.revenge
  531 + local match
  532 + if revenge then
  533 + match = _pvpRecordInfoCacheH[msg.idx]
  534 + _revengeRecord[match.id] = now + RevengeWaitTime -- 1分钟内不能再打
  535 + else
  536 + local pvpMH = role:getProperty("pvpMH")
  537 + match = pvpMH[msg.idx]
  538 + end
  539 +
  540 + if not match then return end
  541 +
  542 + -- 请求上传录像
  543 + local params = {
  544 + ["roleid"] = roleId,
  545 + ["key"] = "zhaolugame20191016",
  546 + ["time"] = now,
  547 + }
  548 + local status, body = httpc.get(remoteUrl, "/applyvideo?" .. httpGetFormatData(params), {}, {})
  549 + local video = nil
  550 + if tonumber(status) == 200 then
  551 + local result = json.decode(body)
  552 + video = result.name
  553 + else
  554 + skynet.error("applyvideo", "error", status, body, content)
  555 + end
  556 +
  557 + table.insert(_pvpStartBattleCacheH.result, {
  558 + isWin = isWin,
  559 + video = video,
  560 + })
  561 +
  562 + -- 检查是否结束战斗
  563 + local winCount, loseCount = 0, 0
  564 + for _, status in pairs(_pvpStartBattleCacheH.result) do
  565 + if status.isWin then
  566 + winCount = winCount + 1
  567 + else
  568 + loseCount = loseCount + 1
  569 + end
  570 + end
  571 +
  572 + if winCount >= 2 then
  573 + isWin = true
  574 + elseif loseCount >= 2 then
  575 + isWin = false
  576 + else -- 没结束
  577 + -- 返回继续战斗
  578 +
  579 + local key = tostring(math.random())
  580 + _pvpStartBattleCacheH.key = key
  581 + local round = #_pvpStartBattleCacheH.result + 1
  582 + local matchInfo = nil
  583 + if _pvpStartBattleCacheH.enemyTB.robot then
  584 + matchInfo = _pvpStartBattleCacheH.enemyTB.robot
  585 + else
  586 + matchInfo = _pvpStartBattleCacheH.enemyTB[round]
  587 + end
  588 +
  589 + -- 继续战斗
  590 + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({
  591 + matchInfo = matchInfo, --敌方队伍 信息
  592 + key = key, --战斗校验 key
  593 + round = round, -- 战斗场数索引
  594 + video = video, -- 返回让客户端上传录像
  595 + }))
  596 + return true
  597 + end
  598 +
  599 + -- 战斗结束了发奖
  600 + local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true)
  601 + 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 +
  604 +
  605 + -- 加入战斗记录
  606 + local selfTeam = {}
  607 + local enemyTeam = {}
  608 + for _idx, info in ipairs(_pvpStartBattleCacheH.result) do
  609 + info.winId = info.isWin and roleId or match.id
  610 + info.isWin = nil
  611 + selfTeam[_idx] = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx].heros)
  612 + if match.t == 1 and _pvpStartBattleCacheH.enemyT then
  613 + enemyTeam[_idx] = _pvpStartBattleCacheH.enemyT[_idx]
  614 + end
  615 + end
  616 + local recordBattle = {
  617 + result = _pvpStartBattleCacheH.result,
  618 + [roleId] = selfTeam,
  619 + [match.id] = enemyTeam
  620 + }
  621 +
  622 + redisproxy:pipelining(function(red)
  623 + local dbKey = string.format(RECORD_PVP_HIGH, roleId)
  624 + red:lpush(dbKey, MsgPack.pack({
  625 + id = match.id,
  626 + t = match.t,
  627 + win = isWin,
  628 + time = now,
  629 + sdelta = myScore - oldmyScore,
  630 + -- 队伍信息
  631 + record = recordBattle,
  632 + }))
  633 + red:ltrim(dbKey, 0, 9)
  634 + -- 对方加入战斗记录
  635 + if match.t == 1 then
  636 + dbKey = string.format(RECORD_PVP_HIGH, match.id)
  637 + red:lpush(dbKey, MsgPack.pack({
  638 + id = roleId,
  639 + t = 1,
  640 + win = not isWin,
  641 + time = now,
  642 + sdelta = matchScore - oldMatchScore,
  643 + -- 队伍信息
  644 + record = recordBattle,
  645 + }))
  646 + red:ltrim(dbKey, 0, 9)
  647 + end
  648 + end)
  649 +
  650 + _pvpBattleInfoCacheH = {} --重新发阵容了 没毛病
  651 + _pvpRecordInfoCacheH = {} -- 记录刷新了
  652 + _pvpRecordBattleInfoCacheH = {} -- 取新纪录的时候搞
  653 + _pvpStartBattleCacheH = nil
  654 + _pvpHeroInfoCacheH = {}
  655 + _pvpRecordHeroInfoCacheH = {}
  656 +
  657 + if isWin then
  658 + role:checkTaskEnter("PvpWin", {score = myScore})
  659 + end
  660 +
  661 + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({
  662 + reward = reward,
  663 + myScore = myScore,
  664 + matchScore = matchScore,
  665 + oldmyScore = oldmyScore,
  666 + oldMatchScore = oldMatchScore,
  667 + myRank = myRank,
  668 + oldMyRank = oldMyRank,
  669 + video = video,
  670 + isWin = isWin,
  671 + }))
  672 + return true
  673 +end
  674 +
  675 +
313 function _M.rankListRpc(agent, data) 676 function _M.rankListRpc(agent, data)
314 local role = agent.role 677 local role = agent.role
315 local roleId = role:getProperty("id") 678 local roleId = role:getProperty("id")
@@ -340,7 +703,26 @@ function _M.rankListRpc(agent, data) @@ -340,7 +703,26 @@ function _M.rankListRpc(agent, data)
340 response.rankList = rankList 703 response.rankList = rankList
341 704
342 elseif ptype == 2 then -- 高级pvp 705 elseif ptype == 2 then -- 高级pvp
343 - return 706 + 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")
  710 + end)
  711 + local score = role:unpackPvpScore(redret[1])
  712 + local rank = tonumber(redret[2] or -2) + 1 --排名 1 - ... -1 未上榜 没打过pvp
  713 + local rankList = {}
  714 + for i = 1, #redret[3], 2 do
  715 + local roleId = tonumber(redret[3][i])
  716 + local score = role:unpackPvpScore(redret[3][i + 1])
  717 + local online, curInfo = rpcRole(roleId, "friendSInfo")
  718 + curInfo.score = score
  719 + curInfo.roleId = roleId
  720 + table.insert(rankList, curInfo)
  721 + end
  722 +
  723 + response.score = score
  724 + response.rank = rank
  725 + response.rankList = rankList
344 else 726 else
345 return 727 return
346 end 728 end
@@ -365,9 +747,9 @@ function _M.recordListRpc(agent, data) @@ -365,9 +747,9 @@ function _M.recordListRpc(agent, data)
365 table.insert(tempList, one) 747 table.insert(tempList, one)
366 end 748 end
367 end 749 end
368 - _pvpRecordInfoCache = tempList 750 + _pvpRecordInfoCacheC = tempList
369 751
370 - recordList = getMatchInfo(role, tempList, _pvpRecordBattleInfoCache) 752 + recordList = getMatchInfo(role, tempList, _pvpRecordBattleInfoCacheC, RANK_PVP_COMMON, "pvpCInfo")
371 for idx, info in ipairs(recordList) do 753 for idx, info in ipairs(recordList) do
372 local temp = tempList[idx] 754 local temp = tempList[idx]
373 info.win = temp.win 755 info.win = temp.win
@@ -377,7 +759,24 @@ function _M.recordListRpc(agent, data) @@ -377,7 +759,24 @@ function _M.recordListRpc(agent, data)
377 end 759 end
378 760
379 elseif ptype == 2 then -- 高级pvp 761 elseif ptype == 2 then -- 高级pvp
380 - return 762 + local rlist = redisproxy:lrange(string.format(RECORD_PVP_HIGH, roleId), 0 , 9)
  763 + local tempList = {}
  764 + for _, temp in ipairs(rlist) do
  765 + local one = MsgPack.unpack(temp)
  766 + if now - one.time <= globalCsv.pvp_record_keep_time then -- 大于一天的弃之
  767 + table.insert(tempList, one)
  768 + end
  769 + end
  770 + _pvpRecordInfoCacheH = tempList
  771 +
  772 + recordList = getMatchInfo(role, tempList, _pvpRecordBattleInfoCacheH, RANK_PVP_HIGHT, "pvpHInfo", _pvpRecordHeroInfoCacheH)
  773 + for idx, info in ipairs(recordList) do
  774 + local temp = tempList[idx]
  775 + info.win = temp.win
  776 + info.time = temp.time
  777 + info.sdelta = temp.sdelta
  778 + info.record = temp.record
  779 + end
381 else 780 else
382 return 781 return
383 end 782 end
src/actions/RoleAction.lua
@@ -245,8 +245,9 @@ function _M.loginRpc( agent, data ) @@ -245,8 +245,9 @@ function _M.loginRpc( agent, data )
245 -- 玩家登陆做的一些操作 245 -- 玩家登陆做的一些操作
246 role:saveHangTeam() 246 role:saveHangTeam()
247 role:savePvpCTeam() 247 role:savePvpCTeam()
248 - -- role:log("login", { ip = agent.ip, diamond = role:getProperty("diamond"), reDiamond = role:getProperty("reDiamond")})  
249 248
  249 + role:log("login", {ip = agent.ip})
  250 +
250 return true 251 return true
251 end 252 end
252 253
@@ -675,18 +676,18 @@ function _M.achiveRpc(agent, data) @@ -675,18 +676,18 @@ function _M.achiveRpc(agent, data)
675 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end 676 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end
676 677
677 local achiveTask = csvdb["achievementCsv"][taskId] 678 local achiveTask = csvdb["achievementCsv"][taskId]
678 - if not achiveTask then return end 679 + if not achiveTask then return 1 end
679 680
680 local achiveT = role:getProperty("achiveT") 681 local achiveT = role:getProperty("achiveT")
681 local achiveV = role:getProperty("achiveV") 682 local achiveV = role:getProperty("achiveV")
682 683
683 - if achiveV[taskId] then return end 684 + if achiveV[taskId] then return 2 end
684 685
685 local curStatus = achiveT[achiveTask.type] or 0 686 local curStatus = achiveT[achiveTask.type] or 0
686 local maxc = achiveTask.condition1 687 local maxc = achiveTask.condition1
687 688
688 if maxc > curStatus then 689 if maxc > curStatus then
689 - return 690 + return 3
690 end 691 end
691 692
692 local reward = role:award(achiveTask.reward) 693 local reward = role:award(achiveTask.reward)
@@ -716,7 +717,7 @@ function _M.achiveRpc(agent, data) @@ -716,7 +717,7 @@ function _M.achiveRpc(agent, data)
716 attachments = pData.reward, 717 attachments = pData.reward,
717 contentPms = {pData.level}, 718 contentPms = {pData.level},
718 }) 719 })
719 - elseif pData.request > newP then 720 + elseif pData.request > overCount then
720 break 721 break
721 end 722 end
722 end 723 end
src/models/Daily.lua
@@ -19,6 +19,7 @@ Daily.schema = { @@ -19,6 +19,7 @@ Daily.schema = {
19 giveFP = {"table", {}}, -- 给谁送过心心 19 giveFP = {"table", {}}, -- 给谁送过心心
20 getFP = {"table", {}}, -- 领过谁的心心 20 getFP = {"table", {}}, -- 领过谁的心心
21 pvpFree = {"number", 0}, -- pvp使用免费次数 21 pvpFree = {"number", 0}, -- pvp使用免费次数
  22 + pvpFreeH = {"number", 0}, -- 高级pvp使用免费次数
22 23
23 dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计 24 dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计
24 dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计 25 dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计
@@ -92,6 +93,7 @@ function Daily:data() @@ -92,6 +93,7 @@ function Daily:data()
92 giveFP = self:getProperty("giveFP"), 93 giveFP = self:getProperty("giveFP"),
93 getFP = self:getProperty("getFP"), 94 getFP = self:getProperty("getFP"),
94 pvpFree = self:getProperty("pvpFree"), 95 pvpFree = self:getProperty("pvpFree"),
  96 + pvpFreeH = self:getProperty("pvpFreeH"),
95 dailySDC = self:getProperty("dailySDC"), 97 dailySDC = self:getProperty("dailySDC"),
96 dailySDD = self:getProperty("dailySDD"), 98 dailySDD = self:getProperty("dailySDD"),
97 advSupRe = self:getProperty("advSupRe"), 99 advSupRe = self:getProperty("advSupRe"),
src/models/Role.lua
1 local Role = class("Role", require("shared.ModelBase")) 1 local Role = class("Role", require("shared.ModelBase"))
2 2
  3 +local RoleLog = import(".RoleLog")
3 local RolePlugin = import(".RolePlugin") 4 local RolePlugin = import(".RolePlugin")
4 local RoleTask = import(".RoleTask") 5 local RoleTask = import(".RoleTask")
5 local RoleActivity = import(".RoleActivity") 6 local RoleActivity = import(".RoleActivity")
@@ -7,6 +8,7 @@ local RoleChangeStruct = import(&quot;.RoleChangeStruct&quot;) @@ -7,6 +8,7 @@ local RoleChangeStruct = import(&quot;.RoleChangeStruct&quot;)
7 local RolePvp = import(".RolePvp") 8 local RolePvp = import(".RolePvp")
8 local RoleCross = import(".RoleCross") 9 local RoleCross = import(".RoleCross")
9 10
  11 +RoleLog.bind(Role)
10 RolePlugin.bind(Role) 12 RolePlugin.bind(Role)
11 RoleTask.bind(Role) 13 RoleTask.bind(Role)
12 RoleActivity.bind(Role) 14 RoleActivity.bind(Role)
src/models/RoleCross.lua
@@ -42,6 +42,19 @@ RoleCross.bind = function (Role) @@ -42,6 +42,19 @@ RoleCross.bind = function (Role)
42 return info 42 return info
43 end 43 end
44 44
  45 + -- pvp 数据
  46 + function Role:pvpHInfo()
  47 + local info = {
  48 + name = self:getProperty("name"),
  49 + level = self:getProperty("level"),
  50 + headId = self:getProperty("headId"),
  51 + battleV = self:getProperty("pvpTBVH"),
  52 + heros = self:getProperty("pvpTSH"),
  53 + battleInfo = self:getProperty("pvpTBH")
  54 + }
  55 + return info
  56 + end
  57 +
45 function Role:accountInit(initData) 58 function Role:accountInit(initData)
46 -- 道具 59 -- 道具
47 local reward = {} 60 local reward = {}
@@ -270,6 +283,18 @@ function CMD.pvpCInfo(roleId) @@ -270,6 +283,18 @@ function CMD.pvpCInfo(roleId)
270 } 283 }
271 end 284 end
272 285
  286 +function CMD.pvpHInfo(roleId)
  287 + local info = CMD.getProperties(roleId, {"name", "level", "headId", "pvpTBVH", "pvpTSH", "pvpTBH"})
  288 + return {
  289 + name = info.name,
  290 + level = info.level,
  291 + headId = info.headId,
  292 + battleV = info.pvpTBVH,
  293 + heros = info.pvpTSH,
  294 + battleInfo = info.pvpTBH
  295 + }
  296 +end
  297 +
273 RoleCross.handle = function(cmd, roleId, ...) 298 RoleCross.handle = function(cmd, roleId, ...)
274 SRole = SRole or require("models.Role") 299 SRole = SRole or require("models.Role")
275 if CMD[cmd] then 300 if CMD[cmd] then
src/models/RoleLog.lua 0 → 100644
@@ -0,0 +1,65 @@ @@ -0,0 +1,65 @@
  1 +
  2 +
  3 +-- logType 日志 mapping 信息(确定后不能更改类型) 修改需要设置 es 日志mapping
  4 +
  5 +
  6 +
  7 +local LogType = {
  8 + create = {
  9 + ip = "string"
  10 + },
  11 + login = {
  12 + ip = "string"
  13 + },
  14 + logout = {
  15 + online = "number"
  16 + },
  17 +
  18 +}
  19 +
  20 +
  21 +-- 所有的日志都包括的部分 role 里面的信息
  22 +local commonField = {
  23 + name = "string",
  24 + id = "number",
  25 + uid = "string",
  26 + sId = "number",
  27 + device = "string",
  28 + ctime = "number",
  29 + ltime = "number",
  30 + level = "number",
  31 + rmbC = "number",
  32 +}
  33 +
  34 +local RoleLog = {}
  35 +
  36 +function RoleLog.bind(Role)
  37 +
  38 + function Role:log(logType, contents)
  39 +
  40 + local _logType = LogType[logType]
  41 + if not _logType then return end
  42 +
  43 +
  44 + if not logd then return end
  45 +
  46 + contents = contents or {}
  47 + local doc = {}
  48 + for field, _typ in pairs(commonField) do
  49 + doc[field] = self:getProperty(field)
  50 + end
  51 + for field, value in pairs(contents) do
  52 + if _logType[field] then
  53 + doc[field] = value
  54 + else
  55 + print(string.format("LOG ERROR: %s had new field %s no type.", logType, field))
  56 + end
  57 + end
  58 +
  59 + doc.mid = doc.uid:sub(-2, -1)
  60 + pcall(skynet.send, logd, "lua", "log", logType, doc)
  61 + end
  62 +
  63 +end
  64 +
  65 +return RoleLog
0 \ No newline at end of file 66 \ No newline at end of file
src/models/RolePlugin.lua
@@ -4,10 +4,6 @@ local RolePlugin = {} @@ -4,10 +4,6 @@ local RolePlugin = {}
4 4
5 function RolePlugin.bind(Role) 5 function RolePlugin.bind(Role)
6 6
7 - function Role:log()  
8 -  
9 - end  
10 -  
11 function Role:loadAll() 7 function Role:loadAll()
12 self:loadDaily() 8 self:loadDaily()
13 self:loadEquips() 9 self:loadEquips()
src/models/RolePvp.lua
@@ -20,14 +20,15 @@ function Role:packPvpScore(score, now) @@ -20,14 +20,15 @@ function Role:packPvpScore(score, now)
20 return math.floor(score * PVP_RANK_TIME_SORT_PLACE + (PVP_RANK_TIME_SORT_STD - now) / PVP_RANK_TIME_SORT_PRECISION) 20 return math.floor(score * PVP_RANK_TIME_SORT_PLACE + (PVP_RANK_TIME_SORT_STD - now) / PVP_RANK_TIME_SORT_PRECISION)
21 end 21 end
22 22
23 -function Role:changePvpScoreCommon(matchId, isWin) 23 +
  24 +function Role:changePvpScore(rankKey, changeScoreCallback, matchId)
24 local roleId = self:getProperty("id") 25 local roleId = self:getProperty("id")
25 local isPlayer = matchId ~= -1 26 local isPlayer = matchId ~= -1
26 local redret = redisproxy:pipelining(function(red) 27 local redret = redisproxy:pipelining(function(red)
27 - red:zscore(RANK_PVP_COMMON, roleId)  
28 - red:zrevrank(RANK_PVP_COMMON, roleId) 28 + red:zscore(rankKey, roleId)
  29 + red:zrevrank(rankKey, roleId)
29 if isPlayer then 30 if isPlayer then
30 - red:zscore(RANK_PVP_COMMON, matchId) 31 + red:zscore(rankKey, matchId)
31 end 32 end
32 end) 33 end)
33 local myScore = self:unpackPvpScore(redret[1]) 34 local myScore = self:unpackPvpScore(redret[1])
@@ -38,51 +39,103 @@ function Role:changePvpScoreCommon(matchId, isWin) @@ -38,51 +39,103 @@ function Role:changePvpScoreCommon(matchId, isWin)
38 end 39 end
39 local oldmyScore, oldMatchScore = myScore, matchScore 40 local oldmyScore, oldMatchScore = myScore, matchScore
40 41
41 - if isWin then  
42 - local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400)))  
43 - myScore = myScore + scoreChange  
44 - matchScore = matchScore - scoreChange  
45 - else  
46 - local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400)))  
47 - myScore = myScore - scoreChange  
48 - matchScore = matchScore + scoreChange  
49 - end  
50 - 42 + myScore, matchScore = changeScoreCallback(myScore, matchScore)
51 myScore = math.max(myScore, 0) 43 myScore = math.max(myScore, 0)
52 matchScore = math.max(matchScore, 0) 44 matchScore = math.max(matchScore, 0)
53 45
54 local now = skynet.timex() 46 local now = skynet.timex()
55 redret = redisproxy:pipelining(function(red) 47 redret = redisproxy:pipelining(function(red)
56 - red:zadd(RANK_PVP_COMMON, self:packPvpScore(myScore, now), roleId) 48 + red:zadd(rankKey, self:packPvpScore(myScore, now), roleId)
57 if isPlayer then 49 if isPlayer then
58 - red:zadd(RANK_PVP_COMMON, self:packPvpScore(matchScore, now), matchId) 50 + red:zadd(rankKey, self:packPvpScore(matchScore, now), matchId)
59 end 51 end
60 - red:zrevrank(RANK_PVP_COMMON, roleId) 52 + red:zrevrank(rankKey, roleId)
61 end) 53 end)
  54 +
62 local myRank 55 local myRank
63 if isPlayer then 56 if isPlayer then
64 myRank = tonumber(redret[3] or -2) + 1 57 myRank = tonumber(redret[3] or -2) + 1
65 else 58 else
66 myRank = tonumber(redret[2] or -2) + 1 59 myRank = tonumber(redret[2] or -2) + 1
67 end 60 end
68 - self:refreshPvpMatchC(myScore)  
69 - return myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank 61 +
  62 + return {myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank}
70 end 63 end
71 64
72 -function Role:refreshPvpMatchC(score) 65 +function Role:changePvpScoreCommon(matchId, isWin)
  66 + local function changeScoreCallback(myScore, matchScore)
  67 + if isWin then
  68 + local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400)))
  69 + myScore = myScore + scoreChange
  70 + matchScore = matchScore - scoreChange
  71 + else
  72 + local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400)))
  73 + myScore = myScore - scoreChange
  74 + matchScore = matchScore + scoreChange
  75 + end
  76 + return myScore, matchScore
  77 + end
  78 +
  79 + local result = self:changePvpScore(RANK_PVP_COMMON, changeScoreCallback, matchId)
  80 + self:refreshPvpMatchC(result[1])
  81 + return table.unpack(result)
  82 +end
  83 +
  84 +function Role:changePvpScoreHigh(matchId, isWin)
  85 + local function changeScoreCallback(myScore, matchScore)
  86 + local myMinScore = 0
  87 + local matchMinScore = 0
  88 + for _, division in ipairs(csvdb["pvp_group_divisionCsv"]) do
  89 + if myScore >= division.division then
  90 + myMinScore = division.division
  91 + end
  92 + if matchScore >= division.division then
  93 + matchMinScore = division.division
  94 + end
  95 + end
  96 + if isWin then
  97 + local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000)))
  98 + myScore = myScore + scoreChange
  99 + matchScore = matchScore - scoreChange
  100 + else
  101 + local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000)))
  102 + myScore = myScore - scoreChange
  103 + matchScore = matchScore + scoreChange
  104 + end
  105 + return math.max(myScore, myMinScore), math.max(matchScore, matchMinScore)
  106 + end
  107 +
  108 + local result = self:changePvpScore(RANK_PVP_HIGHT, changeScoreCallback, matchId)
  109 + self:refreshPvpMatchH(result[1])
  110 + return table.unpack(result)
  111 +end
  112 +
  113 +function Role:refreshPvpMatch(score, rankKey)
  114 +
  115 + local Fields = {
  116 + [RANK_PVP_COMMON] = "pvpMC",
  117 + [RANK_PVP_HIGHT] = "pvpMH",
  118 + }
  119 + local RobotCsvs = {
  120 + [RANK_PVP_COMMON] = "pvp_robotCsv",
  121 + [RANK_PVP_HIGHT] = "pvp_robotCsv",
  122 + }
  123 + local mField = Fields[rankKey]
  124 + local robotCsv = RobotCsvs[rankKey]
  125 +
73 local roleId = self:getProperty("id") 126 local roleId = self:getProperty("id")
74 - score = score or self:unpackPvpScore(redisproxy:zscore(RANK_PVP_COMMON, roleId))  
75 - 127 + score = score or self:unpackPvpScore(redisproxy:zscore(rankKey, roleId))
  128 +
76 local function getPlayers(levels) 129 local function getPlayers(levels)
77 local redret = redisproxy:pipelining(function(red) 130 local redret = redisproxy:pipelining(function(red)
78 for _, level in ipairs(levels) do 131 for _, level in ipairs(levels) do
79 local low, high = table.unpack(level) 132 local low, high = table.unpack(level)
80 - red:zadd(RANK_PVP_COMMON, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1")  
81 - red:zadd(RANK_PVP_COMMON, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2")  
82 - red:ZREVRANK(RANK_PVP_COMMON, "std_temp1")  
83 - red:ZREVRANK(RANK_PVP_COMMON, "std_temp2") 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")
84 end 137 end
85 - red:zrem(RANK_PVP_COMMON, "std_temp1", "std_temp2") 138 + red:zrem(rankKey, "std_temp1", "std_temp2")
86 end) 139 end)
87 140
88 local PreGetCount = 7 141 local PreGetCount = 7
@@ -94,7 +147,7 @@ function Role:refreshPvpMatchC(score) @@ -94,7 +147,7 @@ function Role:refreshPvpMatchC(score)
94 rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) 147 rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1)
95 rank1 = rank2 + PreGetCount - 1 148 rank1 = rank2 + PreGetCount - 1
96 end 149 end
97 - red:ZREVRANGE(RANK_PVP_COMMON, rank2, rank1) 150 + red:ZREVRANGE(rankKey, rank2, rank1)
98 end 151 end
99 end) 152 end)
100 return redret 153 return redret
@@ -131,10 +184,10 @@ function Role:refreshPvpMatchC(score) @@ -131,10 +184,10 @@ function Role:refreshPvpMatchC(score)
131 end 184 end
132 185
133 local result = getPlayers(levels) 186 local result = getPlayers(levels)
134 - local matchC = self:getProperty("pvpMC") 187 + local match = self:getProperty(mField)
135 local hadPlayer = {[roleId] = 1} 188 local hadPlayer = {[roleId] = 1}
136 local hadRobot = {} 189 local hadRobot = {}
137 - for _, one in pairs(matchC) do 190 + for _, one in pairs(match) do
138 if one.t == 1 then 191 if one.t == 1 then
139 hadPlayer[one.id] = 1 192 hadPlayer[one.id] = 1
140 elseif one.t == 2 then 193 elseif one.t == 2 then
@@ -168,12 +221,12 @@ function Role:refreshPvpMatchC(score) @@ -168,12 +221,12 @@ function Role:refreshPvpMatchC(score)
168 end 221 end
169 end 222 end
170 223
171 - local tempMatchC = {} 224 + local tempMatch = {}
172 local curCount = 0 225 local curCount = 0
173 for i = 1, 3 do 226 for i = 1, 3 do
174 local objId = getPlayer(i) 227 local objId = getPlayer(i)
175 if objId then 228 if objId then
176 - tempMatchC[i] = {t = 1, id = objId} 229 + tempMatch[i] = {t = 1, id = objId}
177 curCount = curCount + 1 230 curCount = curCount + 1
178 end 231 end
179 end 232 end
@@ -201,7 +254,7 @@ function Role:refreshPvpMatchC(score) @@ -201,7 +254,7 @@ function Role:refreshPvpMatchC(score)
201 local curIdx = math.randomInt(1, #result) 254 local curIdx = math.randomInt(1, #result)
202 local objId = result[curIdx] 255 local objId = result[curIdx]
203 table.remove(result, curIdx) 256 table.remove(result, curIdx)
204 - tempMatchC[i] = {t = 1, id = objId} 257 + tempMatch[i] = {t = 1, id = objId}
205 curCount = curCount + 1 258 curCount = curCount + 1
206 if not next(result) then 259 if not next(result) then
207 break 260 break
@@ -215,19 +268,25 @@ function Role:refreshPvpMatchC(score) @@ -215,19 +268,25 @@ function Role:refreshPvpMatchC(score)
215 if curCount < 3 then 268 if curCount < 3 then
216 for i = curCount + 1, 3 do 269 for i = curCount + 1, 3 do
217 while true do 270 while true do
218 - local id = math.randomInt(1, #csvdb["pvp_robotCsv"]) 271 + local id = math.randomInt(1, #csvdb[robotCsv])
219 if not hadRobot[id] then 272 if not hadRobot[id] then
220 hadRobot[id] = 1 273 hadRobot[id] = 1
221 - tempMatchC[i] = {t = 2, id = id} 274 + tempMatch[i] = {t = 2, id = id}
222 break 275 break
223 end 276 end
224 end 277 end
225 end 278 end
226 end 279 end
  280 + self:setProperty(mField, tempMatch)
  281 +end
227 282
228 - self:setProperty("pvpMC", tempMatchC) 283 +function Role:refreshPvpMatchC(score)
  284 + self:refreshPvpMatch(score, RANK_PVP_COMMON)
229 end 285 end
230 286
  287 +function Role:refreshPvpMatchH(score)
  288 + self:refreshPvpMatch(score, RANK_PVP_HIGHT)
  289 +end
231 290
232 end 291 end
233 292