Commit 4ae70ca271b5d0b5fa721ab523e6a8d14b1c83ec
Merge branch 'develop' into tr/publish
Showing
20 changed files
with
726 additions
and
297 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
... | ... | @@ -221,6 +221,8 @@ actionCodes = { |
221 | 221 | Activity_actCalendaTaskRpc = 655, |
222 | 222 | Activity_actPaySignRpc = 656, |
223 | 223 | Activity_exchangeRpc = 657, |
224 | + Activity_gachakonRpc = 658, | |
225 | + Activity_hangDropRpc = 659, | |
224 | 226 | |
225 | 227 | Radio_startQuestRpc = 700, |
226 | 228 | Radio_finishQuestRpc = 701, | ... | ... |
src/actions/ActivityAction.lua
... | ... | @@ -268,7 +268,7 @@ function _M.exchangeRpc(agent, data) |
268 | 268 | local msg = MsgPack.unpack(data) |
269 | 269 | local actid = msg.actid |
270 | 270 | local id = msg.id |
271 | - if not role.activity:isOpen("Exchange") then return 1 end | |
271 | + if not role.activity:isOpenById(actid) then return 1 end | |
272 | 272 | |
273 | 273 | local exchangeCfg = csvdb["activity_exchangeCsv"][actid] |
274 | 274 | if not exchangeCfg then return 2 end |
... | ... | @@ -277,7 +277,8 @@ function _M.exchangeRpc(agent, data) |
277 | 277 | local exchangeData = curData[actid] or {} |
278 | 278 | local curCount = exchangeData[id] or 0 |
279 | 279 | local actCfg = exchangeCfg[id] |
280 | - if curCount >= actCfg then return 4 end | |
280 | + local limitArr = actCfg.limit:toArray(true, "=") | |
281 | + if curCount >= limitArr[2] then return 4 end | |
281 | 282 | |
282 | 283 | local costs = actCfg.goods:toNumMap() |
283 | 284 | if not role:checkItemEnough(costs) then return 5 end |
... | ... | @@ -295,4 +296,123 @@ function _M.exchangeRpc(agent, data) |
295 | 296 | return true |
296 | 297 | end |
297 | 298 | |
299 | +function _M.gachakonRpc(agent, data) | |
300 | + local role = agent.role | |
301 | + local msg = MsgPack.unpack(data) | |
302 | + local actid = msg.actid | |
303 | + local count = msg.count | |
304 | + | |
305 | + if count > 10 then return end | |
306 | + | |
307 | + if not role.activity:isOpenById(actid) then return 1 end | |
308 | + | |
309 | + local actCtrlData = csvdb["activity_ctrlCsv"][actid] | |
310 | + if not actCtrlData then return 2 end | |
311 | + local cost = actCtrlData.condition2:toNumMap() | |
312 | + | |
313 | + local actCfg = csvdb["activity_capsuleToysCsv"][actid] | |
314 | + if not actCfg then return 3 end | |
315 | + | |
316 | + local gachakonInfo = role.activity:getActData("Gachakon") or {} | |
317 | + local award = {} | |
318 | + local remain = 0 | |
319 | + for i = 1, count do | |
320 | + local tmpCfg = clone(actCfg) | |
321 | + remain = 0 | |
322 | + print("-----------------, ", i) | |
323 | + for id, cfg in pairs(tmpCfg) do | |
324 | + local num = gachakonInfo[id] or 0 | |
325 | + num = cfg.amount >= num and cfg.amount - num or 0 | |
326 | + cfg.weight = cfg.weight * num | |
327 | + if cfg.weight > 0 then | |
328 | + remain = remain + num | |
329 | + end | |
330 | + print("num ".. num, id, cfg.weight, cfg.amount) | |
331 | + end | |
332 | + if remain == 0 then | |
333 | + break | |
334 | + end | |
335 | + local id = math.randWeight(tmpCfg, "weight") | |
336 | + if not id then return 4 end | |
337 | + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 | |
338 | + local curAward = tmpCfg[id].award:toNumMap() | |
339 | + for k, v in pairs(curAward) do | |
340 | + award[k] = (award[k] or 0) + v | |
341 | + end | |
342 | + end | |
343 | + | |
344 | + for k, v in pairs(cost) do | |
345 | + cost[k] = v * count | |
346 | + end | |
347 | + | |
348 | + if not role:checkItemEnough(cost) then return 5 end | |
349 | + | |
350 | + role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | |
351 | + | |
352 | + local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | |
353 | + if remain <= count then | |
354 | + gachakonInfo = {} | |
355 | + print("hahaha") | |
356 | + end | |
357 | + role.activity:updateActData("Gachakon", gachakonInfo) | |
358 | + | |
359 | + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change))) | |
360 | + return true | |
361 | +end | |
362 | + | |
363 | +function _M.hangDropRpc(agent, data) | |
364 | + local role = agent.role | |
365 | + local msg = MsgPack.unpack(data) | |
366 | + local actid = msg.actid | |
367 | + if not role.activity:isOpenById(actid) then return 1 end | |
368 | + | |
369 | + local actCfg = csvdb["activity_putCsv"][actid] | |
370 | + if not actCfg then return 2 end | |
371 | + | |
372 | + local award, period = "", 0 | |
373 | + for i = 1, #actCfg do | |
374 | + local cfg = actCfg[i] | |
375 | + if not cfg then | |
376 | + break | |
377 | + end | |
378 | + if cfg.condition ~= "" then | |
379 | + local arr = cfg.condition:toArray(true, "=") | |
380 | + local type = arr[1] | |
381 | + if type == 1 then | |
382 | + local actId = arr[2] | |
383 | + local carbonId = arr[3] | |
384 | + if not role.activity:isOpenById(actid) then return 3 end | |
385 | + local clInfo = role.activity:getActData("ChallengeLevel") or {} | |
386 | + if not clInfo[carbonId] then | |
387 | + break | |
388 | + end | |
389 | + end | |
390 | + end | |
391 | + award = cfg.reward | |
392 | + period = cfg.period * 60 | |
393 | + end | |
394 | + local actData = role.activity:getActData("HangDrop") or 0 | |
395 | + local timeNow = skynet.timex() | |
396 | + if period == 0 or award == "" then | |
397 | + return 4 | |
398 | + end | |
399 | + local num = math.floor((timeNow - actData)/ period) | |
400 | + num = num > 8 and 8 or num | |
401 | + if num == 0 then | |
402 | + return 5 | |
403 | + end | |
404 | + local reward, change = {}, nil | |
405 | + for id, value in pairs(award:toNumMap()) do | |
406 | + reward[id] = value * num | |
407 | + end | |
408 | + | |
409 | + reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}}) | |
410 | + | |
411 | + role.activity:updateActData("HangDrop", timeNow) | |
412 | + | |
413 | + SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change))) | |
414 | + | |
415 | + return true | |
416 | +end | |
417 | + | |
298 | 418 | return _M |
299 | 419 | \ No newline at end of file | ... | ... |
src/actions/EmailAction.lua
... | ... | @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) |
121 | 121 | local attachments = getEmailAttachments(email) |
122 | 122 | if attachments == "" then return end |
123 | 123 | |
124 | - local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId}}) | |
124 | + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) | |
125 | 125 | email:setProperty("status", 2) |
126 | 126 | email:log(role, 2) |
127 | 127 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -534,7 +534,7 @@ function _M.test(role, pms) |
534 | 534 | --local hero = require ("actions.HeroAction") |
535 | 535 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
536 | 536 | |
537 | - role:sendMail(13, nil, "1=2", {111}) | |
537 | + --role:sendMail(13, nil, "1=2", {111}) | |
538 | 538 | return "成功" |
539 | 539 | end |
540 | 540 | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) |
585 | 585 | local itemData = csvdb["itemCsv"][itemId] |
586 | 586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end |
587 | 587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] |
588 | - if not cost or role:getItemCount(itemId) < cost then return end | |
588 | + if not cost or role:getItemCount(itemId) < cost then return 1 end | |
589 | 589 | |
590 | 590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] |
591 | - if not randomData then return end | |
591 | + if not randomData then return 2 end | |
592 | 592 | |
593 | 593 | local temp = randomData.gift1:randWeight(true) |
594 | - if not temp or not next(temp) then return end | |
594 | + if not temp or not next(temp) then return 3 end | |
595 | 595 | |
596 | 596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) |
597 | - local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}}) | |
597 | + local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) | |
598 | 598 | |
599 | 599 | |
600 | 600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) | ... | ... |
src/actions/PvpAction.lua
... | ... | @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 |
23 | 23 | local RevengeWaitTime = 60 |
24 | 24 | |
25 | 25 | function _M.formatCommonRpc(agent , data) |
26 | + if true then return end | |
26 | 27 | local role = agent.role |
27 | 28 | local roleId = role:getProperty("id") |
28 | 29 | local msg = MsgPack.unpack(data) |
... | ... | @@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) |
63 | 64 | local role = agent.role |
64 | 65 | local roleId = role:getProperty("id") |
65 | 66 | local msg = MsgPack.unpack(data) |
66 | - | |
67 | + | |
68 | + if not role:isCrossServerPvpPlayer() then return end | |
67 | 69 | local pvpTH = {} |
68 | 70 | local had = {} -- 上阵的角色 |
69 | 71 | local supportHad = {} |
... | ... | @@ -169,7 +171,7 @@ function _M.infoRpc(agent, data) |
169 | 171 | |
170 | 172 | local pvpMC = role:getProperty("pvpMC") |
171 | 173 | if not next(pvpMC) then --没有分配过对手 |
172 | - role:refreshPvpMatchC(score) | |
174 | + role:refreshPvpMatchC(score, -1) | |
173 | 175 | pvpMC = role:getProperty("pvpMC") |
174 | 176 | end |
175 | 177 | if not next(pvpMC) then return end |
... | ... | @@ -189,7 +191,7 @@ function _M.infoRpc(agent, data) |
189 | 191 | |
190 | 192 | local pvpMH = role:getProperty("pvpMH") |
191 | 193 | if not next(pvpMH) then --没有分配过对手 |
192 | - role:refreshPvpMatchH(score) | |
194 | + role:refreshPvpMatchH(score, -1) | |
193 | 195 | pvpMH = role:getProperty("pvpMH") |
194 | 196 | end |
195 | 197 | if not next(pvpMH) then return end |
... | ... | @@ -255,8 +257,38 @@ function _M.startBattleRpc(agent, data) |
255 | 257 | local idx = msg.idx |
256 | 258 | local revenge = msg.revenge |
257 | 259 | |
258 | - local pvpTC = role:getProperty("pvpTC") | |
259 | - if not pvpTC.heros or not next(pvpTC.heros) then return 1 end | |
260 | + -- local pvpTC = role:getProperty("pvpTC") | |
261 | + -- if not pvpTC.heros or not next(pvpTC.heros) then return 1 end | |
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 | |
260 | 292 | |
261 | 293 | local matchInfo, result, key, wait |
262 | 294 | |
... | ... | @@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) |
299 | 331 | end |
300 | 332 | |
301 | 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 | 336 | role:checkTaskEnter("PvpBattle") |
305 | 337 | |
... | ... | @@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) |
342 | 374 | |
343 | 375 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) |
344 | 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 | 388 | local params = { |
... | ... | @@ -433,8 +473,8 @@ function _M.startBattleHRpc(agent, data) |
433 | 473 | local revenge = msg.revenge |
434 | 474 | if not role:isTimeResetOpen(TimeReset.PvpHight) then return end |
435 | 475 | |
436 | - local pvpTH = role:getProperty("pvpTH") | |
437 | - if not next(pvpTH) then return 1 end | |
476 | + -- local pvpTH = role:getProperty("pvpTH") | |
477 | + -- if not next(pvpTH) then return 1 end | |
438 | 478 | |
439 | 479 | -- 检查并记录玩家队伍 |
440 | 480 | local pvpTH = {} |
... | ... | @@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) |
472 | 512 | curTeam.tactics = team.tactics |
473 | 513 | end |
474 | 514 | |
475 | - | |
476 | 515 | table.insert(pvpTH, curTeam) |
477 | 516 | end |
478 | 517 | |
... | ... | @@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) |
644 | 683 | -- 战斗结束了发奖 |
645 | 684 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
646 | 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 | 698 | end |
651 | 699 | |
652 | 700 | -- 加入战斗记录 | ... | ... |
src/actions/StoreAction.lua
... | ... | @@ -402,18 +402,24 @@ function _M.getTotalRechargeAwardRpc(agent, data) |
402 | 402 | local role = agent.role |
403 | 403 | local msg = MsgPack.unpack(data) |
404 | 404 | local index = msg.index -- 领取的索引id |
405 | + local totalTwd = role:getProperty("twdC") | |
405 | 406 | local totalRechargeRecord = role.storeData:getProperty("totalRR") |
406 | 407 | local flag = string.char(string.getbit(totalRechargeRecord, index)) |
407 | - if flag == "1" then | |
408 | - return 1 | |
409 | - end | |
408 | + if flag == "1" then return 1 end | |
409 | + local cfg = csvdb["activity_payRebateCsv"][index] | |
410 | + if not cfg then return 2 end | |
411 | + if cfg.twd > totalTwd then return 3 end | |
412 | + | |
410 | 413 | totalRechargeRecord = string.setbit(totalRechargeRecord, index) |
411 | 414 | role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) |
412 | - local cfg = csvdb["Csv"][index] | |
413 | - if not cfg then return 2 end | |
415 | + local main = cfg.main_reward:toNumMap() | |
416 | + local sub = cfg.sub_reward:toNumMap() | |
417 | + for k, v in pairs(sub) do | |
418 | + main[k] = (main[k] or 0) + v | |
419 | + end | |
414 | 420 | |
415 | - local reward, _ = role:award(cfg.reward, {log = {desc = "totalRecharge", int1 = index}}) | |
416 | - SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack({reward = reward})) | |
421 | + local reward, change = role:award(main, {log = {desc = "totalRecharge", int1 = index}}) | |
422 | + SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack(role:packReward(reward, change))) | |
417 | 423 | return true |
418 | 424 | end |
419 | 425 | ... | ... |
src/adv/Adv.lua
... | ... | @@ -1388,19 +1388,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) |
1388 | 1388 | [14] = function() -- 指定地块召唤 指定类型的id |
1389 | 1389 | local change = self:getCurMap():layEventToStage(effect[2], effect[3], effect[4], effect[5]) |
1390 | 1390 | for _, one in ipairs(change) do |
1391 | - self:backBlockChange(one[1].roomId, one[2].blockId) | |
1391 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then | |
1392 | + clearBlock = false | |
1393 | + else | |
1394 | + self:backBlockChange(one[1].roomId, one[2].blockId) | |
1395 | + end | |
1392 | 1396 | end |
1393 | 1397 | end, |
1394 | 1398 | [15] = function() -- 移除指定事件 |
1395 | 1399 | local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4]) |
1396 | 1400 | for _, one in ipairs(change) do |
1397 | - self:backBlockChange(one[1].roomId, one[2].blockId) | |
1401 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then | |
1402 | + clearBlock = false | |
1403 | + else | |
1404 | + self:backBlockChange(one[1].roomId, one[2].blockId) | |
1405 | + end | |
1398 | 1406 | end |
1399 | 1407 | end, |
1400 | 1408 | [16] = function() -- 指定事件转移 |
1401 | 1409 | local change = self:getCurMap():eventChangeToOther(effect[2], effect[3], effect[4], effect[5], effect[6]) |
1402 | 1410 | for _, one in ipairs(change) do |
1403 | - self:backBlockChange(one[1].roomId, one[2].blockId) | |
1411 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then | |
1412 | + clearBlock = false | |
1413 | + else | |
1414 | + self:backBlockChange(one[1].roomId, one[2].blockId) | |
1415 | + end | |
1404 | 1416 | end |
1405 | 1417 | end, |
1406 | 1418 | } |
... | ... | @@ -1526,6 +1538,24 @@ local function clickBuild(self, room, block, params) |
1526 | 1538 | local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") |
1527 | 1539 | if not status then return end |
1528 | 1540 | |
1541 | + local isMine = false -- 是不是宝藏怪 | |
1542 | + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do | |
1543 | + if mid == oldId then | |
1544 | + isMine = true | |
1545 | + break | |
1546 | + end | |
1547 | + end | |
1548 | + if isMine then | |
1549 | + local advMine = self.owner:getProperty("advMine") | |
1550 | + advMine[2] = advMine[2] or {} | |
1551 | + local mineCo2 = advMine[2].co or {} | |
1552 | + if chooseData.limit ~= 0 then | |
1553 | + mineCo2[oldId] = (mineCo2[oldId] or 0) + 1 | |
1554 | + end | |
1555 | + advMine[2].co = mineCo2 | |
1556 | + self.owner:setProperty("advMine", advMine) | |
1557 | + end | |
1558 | + | |
1529 | 1559 | self:checkTask(Adv.TaskType.Build, 1, oldId) |
1530 | 1560 | self:checkAchievement(Adv.AchievType.Build, 1, oldId) |
1531 | 1561 | self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) |
... | ... | @@ -1960,6 +1990,7 @@ function Adv:enemyDead(enemy, escape) |
1960 | 1990 | break |
1961 | 1991 | end |
1962 | 1992 | end |
1993 | + | |
1963 | 1994 | if isMine then |
1964 | 1995 | local advMine = self.owner:getProperty("advMine") |
1965 | 1996 | advMine[1] = advMine[1] or {} |
... | ... | @@ -1986,16 +2017,14 @@ function Adv:enemyDead(enemy, escape) |
1986 | 2017 | etype = AdvEventType.Build, |
1987 | 2018 | id = cId |
1988 | 2019 | }) |
1989 | - if csvdb["event_buildingCsv"][cId].limit ~= 0 then | |
1990 | - mineCo2[cId] = (mineCo2[cId] or 0) + 1 | |
1991 | - end | |
1992 | 2020 | had = true |
1993 | 2021 | end |
1994 | 2022 | end |
1995 | 2023 | if had then |
1996 | - mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100) | |
1997 | - else | |
1998 | 2024 | mineCh = nil |
2025 | + else | |
2026 | + block:clear() | |
2027 | + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100) | |
1999 | 2028 | end |
2000 | 2029 | |
2001 | 2030 | local drops = {} | ... | ... |
src/adv/AdvBattle.lua
... | ... | @@ -463,7 +463,7 @@ function Battle:iLayerChange(oldMapIdx) |
463 | 463 | local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras) |
464 | 464 | local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) |
465 | 465 | self.player:checkAuraBuff(playerBuffs) |
466 | - for _, enemy in pairs(self.player:getTeam(2)) do | |
466 | + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do | |
467 | 467 | enemy:checkAuraBuff(enemyBuffs) |
468 | 468 | end |
469 | 469 | self:setMapAuras(auras) |
... | ... | @@ -483,7 +483,7 @@ function Battle:newBattle() |
483 | 483 | local auras = self:getActiveAuras() |
484 | 484 | local buffs = self:checkDiffAuraBuff({}, auras) |
485 | 485 | self.player:checkAuraBuff(buffs) |
486 | - for _, enemy in pairs(self.player:getTeam(2)) do | |
486 | + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do | |
487 | 487 | enemy:checkAuraBuff(buffs) |
488 | 488 | end |
489 | 489 | self:setMapAuras(auras) | ... | ... |
src/adv/AdvBuff.lua
... | ... | @@ -489,6 +489,7 @@ function Buff:createAfter(layer) |
489 | 489 | if self._init then |
490 | 490 | self:_init() |
491 | 491 | end |
492 | + self:pushBackEffect(1) | |
492 | 493 | end |
493 | 494 | |
494 | 495 | function Buff:initByDB(data) |
... | ... | @@ -620,11 +621,19 @@ function Buff:canEffect(...) |
620 | 621 | return self:_canEffect(...) |
621 | 622 | end |
622 | 623 | |
624 | +function Buff:pushBackEffect(etype) | |
625 | + local shows = self.buffData.show:toTableArray(true) | |
626 | + for _, one in ipairs(shows) do | |
627 | + if one[1] == etype then | |
628 | + self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = etype, id = self.id, blockId = self.owner.blockId, roomId = self.owner.roomId}) | |
629 | + break | |
630 | + end | |
631 | + end | |
632 | +end | |
633 | + | |
623 | 634 | function Buff:effect() |
624 | 635 | self:decCount() |
625 | - if self.buffData.show:sismember(2, " ") then | |
626 | - self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 2}) | |
627 | - end | |
636 | + self:pushBackEffect(2) | |
628 | 637 | if self._effectValue then |
629 | 638 | return self:_effectValue() |
630 | 639 | end |
... | ... | @@ -698,6 +707,8 @@ function Buff:overlay(releaser, data, layer) |
698 | 707 | if self._overlay then |
699 | 708 | self:_overlay() |
700 | 709 | end |
710 | + | |
711 | + self:pushBackEffect(1) | |
701 | 712 | end |
702 | 713 | end |
703 | 714 | ... | ... |
src/adv/AdvMap.lua
... | ... | @@ -13,12 +13,12 @@ local createMap, getEventLib |
13 | 13 | function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay) |
14 | 14 | self.adv = adv |
15 | 15 | local isNew = type(mapInfo) == "number" |
16 | + self.mapIdx = mapIdx | |
16 | 17 | if isNew then -- mapInfo 传入 id |
17 | 18 | mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图 |
18 | 19 | end |
19 | 20 | if not mapInfo then return end |
20 | 21 | |
21 | - self.mapIdx = mapIdx | |
22 | 22 | self.mapId = mapInfo.mapId |
23 | 23 | self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用 |
24 | 24 | self.rooms = {} |
... | ... | @@ -258,7 +258,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) |
258 | 258 | if isPlayer then |
259 | 259 | self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId}) |
260 | 260 | self.adv.owner:checkTaskEnter("AdvOpenBlock") |
261 | - | |
261 | + self.adv.battle.player:changeSp(1) -- 翻开格子 sp 加1 | |
262 | 262 | -- 潜行检查 |
263 | 263 | local sneakBuff = self.adv.battle.player:hadBuff(Buff.SNEAK) |
264 | 264 | if sneakBuff then |
... | ... | @@ -349,8 +349,8 @@ function Map:getDistance(froomId, fblockId, troomId, tblockId) |
349 | 349 | local room1 = self.rooms[froomId] |
350 | 350 | local room2 = self.rooms[troomId] |
351 | 351 | if room1 and room2 then |
352 | - local block1 = room1[fblockId] | |
353 | - local block2 = room2[tblockId] | |
352 | + local block1 = room1.blocks[fblockId] | |
353 | + local block2 = room2.blocks[tblockId] | |
354 | 354 | if block1 and block2 then |
355 | 355 | local c1, r1 = room1:tranLtoG(block1.col, block1.row) |
356 | 356 | local c2, r2 = room2:tranLtoG(block2.col, block2.row) |
... | ... | @@ -811,46 +811,47 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
811 | 811 | end |
812 | 812 | end |
813 | 813 | end |
814 | - | |
815 | 814 | -- 宝藏怪刷新 |
816 | - for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do | |
817 | - local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId} | |
818 | - if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在 | |
819 | - table.remove(stagePool["global"][AdvCodeRandomStage], idx) | |
820 | - end | |
821 | - end | |
822 | - local ln = #(stagePool["global"][AdvCodeRandomStage] or {}) | |
823 | - local advMine = self.adv.owner:getProperty("advMine") | |
824 | - advMine[1] = advMine[1] or {} | |
825 | - local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup | |
826 | - local mineCo = advMine[1].co or {} | |
827 | - local had = false | |
828 | - if ln > 0 then | |
829 | - if math.randomInt(1, 100) <= mineCh then -- 刷出来了 | |
830 | - local mpool = {} | |
831 | - for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do | |
832 | - local monster = csvdb["event_monsterCsv"][mid] | |
833 | - if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then | |
834 | - mpool[mid] = {monster.showup} | |
835 | - end | |
836 | - end | |
837 | - if next(mpool) then | |
838 | - local idx = math.randomInt(1, ln) | |
839 | - local cur = stagePool["global"][AdvCodeRandomStage][idx] | |
840 | - giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1)) | |
815 | + if self.mapIdx == 1 and not self.adv.isRelay then | |
816 | + for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do | |
817 | + local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId} | |
818 | + if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在 | |
841 | 819 | table.remove(stagePool["global"][AdvCodeRandomStage], idx) |
842 | - ln = ln - 1 | |
843 | - had = true | |
844 | 820 | end |
845 | 821 | end |
822 | + local ln = #(stagePool["global"][AdvCodeRandomStage] or {}) | |
823 | + local advMine = self.adv.owner:getProperty("advMine") | |
824 | + advMine[1] = advMine[1] or {} | |
825 | + local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup | |
826 | + local mineCo = advMine[1].co or {} | |
827 | + local had = false | |
828 | + if ln > 0 then | |
829 | + if math.randomInt(1, 100) <= mineCh then -- 刷出来了 | |
830 | + local mpool = {} | |
831 | + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do | |
832 | + local monster = csvdb["event_monsterCsv"][mid] | |
833 | + if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then | |
834 | + mpool[mid] = {monster.showup} | |
835 | + end | |
836 | + end | |
837 | + if next(mpool) then | |
838 | + local idx = math.randomInt(1, ln) | |
839 | + local cur = stagePool["global"][AdvCodeRandomStage][idx] | |
840 | + giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1)) | |
841 | + table.remove(stagePool["global"][AdvCodeRandomStage], idx) | |
842 | + ln = ln - 1 | |
843 | + had = true | |
844 | + end | |
845 | + end | |
846 | + end | |
847 | + if had then | |
848 | + mineCh = nil | |
849 | + else | |
850 | + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100) | |
851 | + end | |
852 | + advMine[1].ch = mineCh | |
853 | + self.adv.owner:setProperty("advMine", advMine) | |
846 | 854 | end |
847 | - if not had then | |
848 | - mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100) | |
849 | - else | |
850 | - mineCh = nil | |
851 | - end | |
852 | - advMine[1].ch = mineCh | |
853 | - self.adv.owner:setProperty("advMine", advMine) | |
854 | 855 | |
855 | 856 | |
856 | 857 | if mapCsvData.clearType == 1 and not haveBoss then | ... | ... |
src/adv/AdvPassive.lua
... | ... | @@ -50,7 +50,7 @@ end |
50 | 50 | |
51 | 51 | FilterFactory[Filter.RANGE] = function (_Filter) |
52 | 52 | _Filter._execute = function (self, target, params) |
53 | - if self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then | |
53 | + if params and self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then | |
54 | 54 | local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId) |
55 | 55 | return distance ~= -1 and distance <= self.value |
56 | 56 | end |
... | ... | @@ -95,9 +95,8 @@ function Filter:execute(params) |
95 | 95 | if not target then |
96 | 96 | return |
97 | 97 | end |
98 | - if self:_execute(target) then | |
99 | - return self:_execute(target, params) | |
100 | - end | |
98 | + | |
99 | + return self:_execute(target, params) | |
101 | 100 | end |
102 | 101 | |
103 | 102 | -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
... | ... | @@ -203,7 +202,7 @@ PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] |
203 | 202 | |
204 | 203 | PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) |
205 | 204 | _Passive._trigger = function(self, params) |
206 | - if params.classify:sismember(self.passiveData.value) then | |
205 | + if params.classify:sismember(self.passiveData.value, " ") then | |
207 | 206 | return true |
208 | 207 | end |
209 | 208 | end |
... | ... | @@ -340,6 +339,7 @@ function Passive:canEffect(effType, effValue) |
340 | 339 | end |
341 | 340 | |
342 | 341 | function Passive:effect(triggerPms) |
342 | + local hadEffect = false | |
343 | 343 | for _, effect in ipairs(self.effects) do |
344 | 344 | local effType = effect[1] |
345 | 345 | local effValue = effect[2] |
... | ... | @@ -348,10 +348,13 @@ function Passive:effect(triggerPms) |
348 | 348 | table.insert(otherPms, effect[i]) |
349 | 349 | end |
350 | 350 | if self:canEffect(effType, effValue) then |
351 | + hadEffect = true | |
351 | 352 | self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms)) |
352 | 353 | end |
353 | 354 | end |
354 | - | |
355 | + if hadEffect then | |
356 | + self.owner.battle.adv:pushBackEvent(AdvBackEventType.PassiveEffect, {id = self.id, level = self.level, roomId = self.owner.roomId, blockId = self.owner.blockId}) | |
357 | + end | |
355 | 358 | if self.count > 0 then |
356 | 359 | self.count = self.count < 999 and self.count - 1 or self.count |
357 | 360 | self.round = self.passiveData.round | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -847,10 +847,6 @@ function Player:addBuff(buffId, releaser) |
847 | 847 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) |
848 | 848 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) |
849 | 849 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) |
850 | - local buffData = csvdb["adv_map_buffCsv"][buffId] | |
851 | - if buffData and buffData.show:sismember(1, " ") then | |
852 | - self.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 1}) | |
853 | - end | |
854 | 850 | end |
855 | 851 | return status |
856 | 852 | end | ... | ... |
src/models/Activity.lua
... | ... | @@ -54,10 +54,10 @@ Activity.schema = { |
54 | 54 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 |
55 | 55 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 |
56 | 56 | |
57 | - act20 = {"table", {}, true}, -- {id=兑换数量} | |
58 | - act21 = {"table", {}}, -- {id=抽取的数量} | |
59 | - act22 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} | |
60 | - act23 = {"table", {}}, -- {挂机信息} | |
57 | + act17 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} | |
58 | + act18 = {"table", {}, true}, -- {id=兑换数量} | |
59 | + act19 = {"number", 0}, -- {挂机信息} | |
60 | + act20 = {"table", {}}, -- {id=扭蛋抽出数量} | |
61 | 61 | } |
62 | 62 | |
63 | 63 | function Activity:data() |
... | ... | @@ -71,6 +71,11 @@ function Activity:data() |
71 | 71 | act12 = self:getProperty("act12"), |
72 | 72 | act13 = self:getProperty("act13"), |
73 | 73 | act14 = self:getProperty("act14"), |
74 | + | |
75 | + act17 = self:getProperty("act17"), | |
76 | + act18 = self:getProperty("act18"), | |
77 | + act19 = self:getProperty("act19"), | |
78 | + act20 = self:getProperty("act20"), | |
74 | 79 | } |
75 | 80 | end |
76 | 81 | |
... | ... | @@ -148,6 +153,10 @@ function Activity:isOpen(activityType) |
148 | 153 | return false |
149 | 154 | end |
150 | 155 | |
156 | +function Activity:isOpenById(id) | |
157 | + return self._isOpen[id] | |
158 | +end | |
159 | + | |
151 | 160 | function Activity:getActData(actType) |
152 | 161 | actType = checkActivityType(actType) |
153 | 162 | return self:getProperty("act" .. actType) |
... | ... | @@ -422,13 +431,34 @@ activityFunc[Activity.ActivityType.CalendaTask] = { |
422 | 431 | -- 兑换 |
423 | 432 | activityFunc[Activity.ActivityType.Exchange] = { |
424 | 433 | ["init"] = function(self, actType, isCrossDay, notify, actId) |
425 | - local role = self.owner | |
426 | 434 | local actData = self:getActData(actType) or {} |
427 | 435 | actData[actId] = {} |
428 | 436 | self:updateActData(actType, actData, not notify) |
429 | 437 | end, |
430 | - --["close"] = function(self, actType, notify, actId) | |
431 | - --end, | |
438 | + ["crossDay"] = function(self, actType, notify, actId) | |
439 | + local actData = self:getActData(actType) or {} | |
440 | + local lastTs = actData["ts"] or 0 | |
441 | + local timeNow = skynet.timex() | |
442 | + local cfg = csvdb["activity_ctrlCsv"][actId] | |
443 | + if not cfg then return end | |
444 | + local refreshTimes = cfg.condition2:toArray(false, "=") | |
445 | + for i = 1, #refreshTimes do | |
446 | + local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME)) | |
447 | + if timeNow >= rt and rt > lastTs then | |
448 | + lastTs = rt | |
449 | + actData = {} | |
450 | + end | |
451 | + end | |
452 | + if next(actData) then | |
453 | + actData["ts"] = lastTs | |
454 | + self:updateActData(actType, actData, not notify) | |
455 | + end | |
456 | + end, | |
457 | + ["close"] = function(self, actType, notify, actId) | |
458 | + local actData = self:getActData(actType) or {} | |
459 | + actData[actId] = nil | |
460 | + self:updateActData(actType, actData, not notify) | |
461 | + end, | |
432 | 462 | } |
433 | 463 | |
434 | 464 | -- 扭蛋机 |
... | ... | @@ -441,6 +471,19 @@ activityFunc[Activity.ActivityType.Gachakon] = { |
441 | 471 | end, |
442 | 472 | } |
443 | 473 | |
474 | +-- 挂机掉落 | |
475 | +activityFunc[Activity.ActivityType.HangDrop] = { | |
476 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
477 | + local actime = self:getProperty("actime") | |
478 | + local startTime = actime[actId] | |
479 | + local actData = self:getActData(actType) or 0 | |
480 | + local cfg = csvdb["activity_putCsv"][actId] | |
481 | + if not cfg then return end | |
482 | + actData = startTime | |
483 | + self:updateActData(actType, actData, not notify) | |
484 | + end | |
485 | +} | |
486 | + | |
444 | 487 | function Activity:initActivity(actId, isCrossDay, notify) |
445 | 488 | local actData = csvdb["activity_ctrlCsv"][actId] |
446 | 489 | if not actData then return end |
... | ... | @@ -469,7 +512,7 @@ function Activity:refreshDailyData(notify) |
469 | 512 | if status and actData then |
470 | 513 | local actType = actData.showType |
471 | 514 | if activityFunc[actType] and activityFunc[actType]['crossDay'] then |
472 | - activityFunc[actType]["crossDay"](self, actType, notify) | |
515 | + activityFunc[actType]["crossDay"](self, actType, notify, actId) | |
473 | 516 | end |
474 | 517 | end |
475 | 518 | end |
... | ... | @@ -486,8 +529,8 @@ end |
486 | 529 | -- 获取此次挂机掉落翻倍时长 |
487 | 530 | function Activity:getActHangDoubleTime(lastTs, nowTs) |
488 | 531 | local type = "DoubleDrop" |
489 | - local actId = checkActivityType(type) | |
490 | - local isOpen = self:isOpen(type) | |
532 | + --local actId = checkActivityType(type) | |
533 | + local isOpen, actId = self:isOpen(type) | |
491 | 534 | local openTs = self:getProperty("actime")[actId] or 0 |
492 | 535 | local timeNow = skynet.timex() |
493 | 536 | lastTs = math.max(lastTs, openTs) |
... | ... | @@ -569,7 +612,7 @@ function Activity:recycleActItem(actId) |
569 | 612 | if not actCfg then return end |
570 | 613 | local gift = {} |
571 | 614 | local costs = {} |
572 | - for _, arr in ipairs(role:getItemCount(actCfg.recycle):toTableArray(true)) do | |
615 | + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do | |
573 | 616 | local fromId, toId, toNum = arr[1], arr[2], arr[3] |
574 | 617 | local itemCount = role:getItemCount(fromId) |
575 | 618 | if itemCount > 0 then | ... | ... |
src/models/HeroPlugin.lua
... | ... | @@ -126,11 +126,11 @@ function HeroPlugin.bind(Hero) |
126 | 126 | end |
127 | 127 | |
128 | 128 | -- 羁绊加成 |
129 | - if params.activeRelation then | |
130 | - for k, attName in pairs(AttsEnumEx) do | |
131 | - attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName) | |
132 | - end | |
133 | - end | |
129 | + -- if params.activeRelation then | |
130 | + -- for k, attName in pairs(AttsEnumEx) do | |
131 | + -- attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName) | |
132 | + -- end | |
133 | + -- end | |
134 | 134 | return attrs |
135 | 135 | end |
136 | 136 | |
... | ... | @@ -224,8 +224,10 @@ function HeroPlugin.bind(Hero) |
224 | 224 | |
225 | 225 | |
226 | 226 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] |
227 | - function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | |
228 | - local attrs = self:getTotalAttrs({activeRelation = activeRelation}) | |
227 | + -- function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | |
228 | + function Hero:getBattleValue() -- isReal包括队伍加成 | |
229 | + -- local attrs = self:getTotalAttrs({activeRelation = activeRelation}) | |
230 | + local attrs = self:getTotalAttrs() | |
229 | 231 | local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] * 4 + attrs["hit"] * 2) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 600000) ^ 0.8 |
230 | 232 | return math.floor(battleValue) |
231 | 233 | end | ... | ... |
src/models/RoleLog.lua
src/models/RolePlugin.lua
... | ... | @@ -102,6 +102,35 @@ function RolePlugin.bind(Role) |
102 | 102 | [ItemType.FuncOpen] = function() |
103 | 103 | self:funcOpen(itemId, count, pms) |
104 | 104 | end, |
105 | + [ItemType.HeroFCommon] = function() | |
106 | + if itemData.use_type == 2 then | |
107 | + local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | |
108 | + for _i = 1, count do | |
109 | + for i = 1, 10 do | |
110 | + local num = randomData["num" .. i] | |
111 | + local gift = randomData["gift" .. i] | |
112 | + if num and gift and num > 0 and gift ~= "" then | |
113 | + local pool = {} | |
114 | + for _, temp in ipairs(gift:toArray()) do | |
115 | + table.insert(pool, temp:toArray(true, "=")) | |
116 | + end | |
117 | + local needCount = math.min(#pool, num) | |
118 | + for j = 1, needCount do | |
119 | + local idx = math.randWeight(pool, 3) | |
120 | + change[pool[idx][1]] = (change[pool[idx][1]] or 0) + pool[idx][2] | |
121 | + table.remove(pool, idx) | |
122 | + end | |
123 | + end | |
124 | + end | |
125 | + end | |
126 | + change[0] = nil | |
127 | + count = 0 | |
128 | + else | |
129 | + pms.itemId = itemId | |
130 | + pms.count = count | |
131 | + self:addItem(pms) | |
132 | + end | |
133 | + end, | |
105 | 134 | } |
106 | 135 | -- 对数量筛查 |
107 | 136 | count = checkItemCount(self, itemId, count) |
... | ... | @@ -806,50 +835,50 @@ function RolePlugin.bind(Role) |
806 | 835 | SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) |
807 | 836 | end |
808 | 837 | |
809 | - function Role:getHeroActiveRelationData(heros) | |
810 | - local relations = {} | |
811 | - for _, id in pairs(heros or {}) do | |
812 | - local hero = self.heros[id] | |
813 | - if hero then | |
814 | - local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | |
815 | - relations[camp] = (relations[camp] or 0) + 1 | |
816 | - end | |
817 | - end | |
818 | - local curData = csvdb["unit_relationCsv"][0] | |
819 | - if not next(relations) then return curData end | |
838 | + -- function Role:getHeroActiveRelationData(heros) | |
839 | + -- local relations = {} | |
840 | + -- for _, id in pairs(heros or {}) do | |
841 | + -- local hero = self.heros[id] | |
842 | + -- if hero then | |
843 | + -- local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | |
844 | + -- relations[camp] = (relations[camp] or 0) + 1 | |
845 | + -- end | |
846 | + -- end | |
847 | + -- local curData = csvdb["unit_relationCsv"][0] | |
848 | + -- if not next(relations) then return curData end | |
820 | 849 | |
821 | - for _, data in ipairs(csvdb["unit_relationCsv"]) do | |
822 | - local had = {} | |
823 | - local isDone = true | |
824 | - for _, count in pairs(data.relation:toArray(true, "=")) do | |
825 | - local find = false | |
826 | - for camp, _count in pairs(relations) do | |
827 | - if count == _count and not had[camp] then | |
828 | - had[camp] = true | |
829 | - find = true | |
830 | - break | |
831 | - end | |
832 | - end | |
833 | - if not find then | |
834 | - isDone = false | |
835 | - break | |
836 | - end | |
837 | - end | |
838 | - if isDone then | |
839 | - curData = data | |
840 | - end | |
841 | - end | |
842 | - return curData | |
843 | - end | |
844 | - | |
845 | - function Role:getHeroActiveRelation(heros) | |
846 | - local data = self:getHeroActiveRelationData(heros) | |
847 | - local result = {} | |
848 | - for attr, value in pairs(data.effect:toNumMap()) do | |
849 | - result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | |
850 | - end | |
851 | - return result | |
852 | - end | |
850 | + -- for _, data in ipairs(csvdb["unit_relationCsv"]) do | |
851 | + -- local had = {} | |
852 | + -- local isDone = true | |
853 | + -- for _, count in pairs(data.relation:toArray(true, "=")) do | |
854 | + -- local find = false | |
855 | + -- for camp, _count in pairs(relations) do | |
856 | + -- if count == _count and not had[camp] then | |
857 | + -- had[camp] = true | |
858 | + -- find = true | |
859 | + -- break | |
860 | + -- end | |
861 | + -- end | |
862 | + -- if not find then | |
863 | + -- isDone = false | |
864 | + -- break | |
865 | + -- end | |
866 | + -- end | |
867 | + -- if isDone then | |
868 | + -- curData = data | |
869 | + -- end | |
870 | + -- end | |
871 | + -- return curData | |
872 | + -- end | |
873 | + | |
874 | + -- function Role:getHeroActiveRelation(heros) | |
875 | + -- local data = self:getHeroActiveRelationData(heros) | |
876 | + -- local result = {} | |
877 | + -- for attr, value in pairs(data.effect:toNumMap()) do | |
878 | + -- result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | |
879 | + -- end | |
880 | + -- return result | |
881 | + -- end | |
853 | 882 | |
854 | 883 | function Role:getHerosCamp(heros) |
855 | 884 | local had = {} |
... | ... | @@ -870,14 +899,16 @@ function RolePlugin.bind(Role) |
870 | 899 | return curCamp |
871 | 900 | end |
872 | 901 | |
873 | - function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 | |
902 | + -- function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 | |
903 | + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成 | |
874 | 904 | heros = heros or {} |
875 | - local activeRelation = activeRelation or self:getHeroActiveRelation(heros) | |
905 | + -- local activeRelation = activeRelation or self:getHeroActiveRelation(heros) | |
876 | 906 | local battleValue = 0 |
877 | 907 | for _, id in pairs(heros) do |
878 | 908 | local hero = self.heros[id] |
879 | 909 | if hero then |
880 | - battleValue = battleValue + hero:getBattleValue(activeRelation) | |
910 | + -- battleValue = battleValue + hero:getBattleValue(activeRelation) | |
911 | + battleValue = battleValue + hero:getBattleValue() | |
881 | 912 | end |
882 | 913 | end |
883 | 914 | return battleValue |
... | ... | @@ -1263,7 +1294,7 @@ function RolePlugin.bind(Role) |
1263 | 1294 | |
1264 | 1295 | function Role:getTeamBattleInfo(team) |
1265 | 1296 | local teamInfo = {heros = {}, supports = {}} |
1266 | - local activeRelation = self:getHeroActiveRelation(team.heros) | |
1297 | + -- local activeRelation = self:getHeroActiveRelation(team.heros) | |
1267 | 1298 | |
1268 | 1299 | for slot, id in pairs(team.heros or {}) do |
1269 | 1300 | local info = {} |
... | ... | @@ -1271,7 +1302,8 @@ function RolePlugin.bind(Role) |
1271 | 1302 | if not hero then |
1272 | 1303 | print("error heroid " .. id) |
1273 | 1304 | end |
1274 | - local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) | |
1305 | + -- local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) | |
1306 | + local attrs = hero:getTotalAttrs() | |
1275 | 1307 | for k, v in pairs(AttsEnumEx) do |
1276 | 1308 | info[v] = (attrs[v] or 0) |
1277 | 1309 | end | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -6,7 +6,12 @@ RolePvp.bind = function (Role) |
6 | 6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 |
7 | 7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 |
8 | 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 | + | |
11 | +-- 匹配规则改为以排名来匹配 | |
12 | +local PVP_GET_ROBOT_SCORE = 2400 -- 2400分以下低档位匹配机器人 | |
13 | +local PRE_RANGE_COUNT = 20 -- 每个档位人数 | |
14 | +local NEED_MATCH = 3 --匹配到多少人 | |
10 | 15 | |
11 | 16 | |
12 | 17 | function Role:unpackPvpScore(score) |
... | ... | @@ -34,7 +39,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) |
34 | 39 | end) |
35 | 40 | local myScore = self:unpackPvpScore(redret[1]) |
36 | 41 | local oldMyRank = tonumber(redret[2] or -2) + 1 |
37 | - local matchScore = PVP_RANK_ROBOT_SCORE | |
42 | + local matchScore = PVP_RANK_BASE_SCORE | |
38 | 43 | if isPlayer then |
39 | 44 | matchScore = self:unpackPvpScore(redret[3]) |
40 | 45 | end |
... | ... | @@ -68,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin) |
68 | 73 | if isWin then |
69 | 74 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) |
70 | 75 | myScore = myScore + scoreChange |
71 | - matchScore = matchScore - scoreChange | |
76 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
72 | 77 | else |
73 | 78 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) |
74 | 79 | myScore = myScore - scoreChange |
... | ... | @@ -78,7 +83,7 @@ function Role:changePvpScoreCommon(matchId, isWin) |
78 | 83 | end |
79 | 84 | |
80 | 85 | local result = self:changePvpScore(RANK_PVP_COMMON, changeScoreCallback, matchId) |
81 | - self:refreshPvpMatchC(result[1]) | |
86 | + self:refreshPvpMatchC(result[1], result[5]) | |
82 | 87 | return table.unpack(result) |
83 | 88 | end |
84 | 89 | |
... | ... | @@ -134,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin) |
134 | 139 | if isWin then |
135 | 140 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
136 | 141 | myScore = myScore + scoreChange |
137 | - matchScore = matchScore - scoreChange | |
142 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
138 | 143 | else |
139 | 144 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) |
140 | 145 | myScore = myScore - scoreChange |
... | ... | @@ -162,85 +167,50 @@ function Role:changePvpScoreHigh(matchId, isWin) |
162 | 167 | }) |
163 | 168 | end |
164 | 169 | |
165 | - self:refreshPvpMatchH(result[1]) | |
170 | + self:refreshPvpMatchH(result[1], result[5]) | |
166 | 171 | return table.unpack(result) |
167 | 172 | end |
168 | 173 | |
169 | -function Role:refreshPvpMatch(score, rankKey) | |
174 | +function Role:isInPvpRank(rankKey) | |
175 | + local Fields = { | |
176 | + [RANK_PVP_COMMON] = "pvpMC", | |
177 | + [RANK_PVP_HIGHT] = "pvpMH", | |
178 | + } | |
179 | + local dbKey = self:getPvpDBKey(rankKey) | |
180 | + local roleId = self:getProperty("id") | |
181 | + if redisproxy:zscore(dbKey, roleId) then | |
182 | + return true | |
183 | + end | |
184 | + return false | |
185 | +end | |
170 | 186 | |
187 | +-- 新的匹配规则 | |
188 | +function Role:refreshPvpMatch(score, rank, rankKey) | |
171 | 189 | local Fields = { |
172 | 190 | [RANK_PVP_COMMON] = "pvpMC", |
173 | 191 | [RANK_PVP_HIGHT] = "pvpMH", |
174 | 192 | } |
175 | 193 | local RobotCsvs = { |
176 | 194 | [RANK_PVP_COMMON] = "pvp_robotCsv", |
177 | - [RANK_PVP_HIGHT] = "pvp_robotCsv", | |
195 | + [RANK_PVP_HIGHT] = "pvp_robot_groupCsv", | |
178 | 196 | } |
197 | + | |
179 | 198 | local mField = Fields[rankKey] |
180 | 199 | local robotCsv = RobotCsvs[rankKey] |
181 | - local dbKey = self:getPvpDBKey(rankKey) | |
182 | 200 | |
201 | + local dbKey = self:getPvpDBKey(rankKey) | |
183 | 202 | local roleId = self:getProperty("id") |
184 | - score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) | |
185 | - | |
186 | - local function getPlayers(levels) | |
203 | + if not score and not rank then | |
187 | 204 | local redret = redisproxy:pipelining(function(red) |
188 | - for _, level in ipairs(levels) do | |
189 | - local low, high = table.unpack(level) | |
190 | - red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") | |
191 | - red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | |
192 | - red:ZREVRANK(dbKey, "std_temp1") | |
193 | - red:ZREVRANK(dbKey, "std_temp2") | |
194 | - end | |
195 | - red:zrem(dbKey, "std_temp1", "std_temp2") | |
205 | + red:zscore(dbKey, roleId) | |
206 | + red:zrevrank(dbKey, roleId) | |
196 | 207 | end) |
197 | - | |
198 | - local PreGetCount = 7 | |
199 | - local redret = redisproxy:pipelining(function(red) | |
200 | - for idx, level in ipairs(levels) do | |
201 | - local rank1 = tonumber(redret[(idx - 1) * 4 + 3]) | |
202 | - local rank2 = tonumber(redret[(idx - 1) * 4 + 4]) | |
203 | - if rank1 - rank2 > PreGetCount then | |
204 | - rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) | |
205 | - rank1 = rank2 + PreGetCount - 1 | |
206 | - end | |
207 | - red:ZREVRANGE(dbKey, rank2, rank1) | |
208 | - end | |
209 | - end) | |
210 | - return redret | |
211 | - end | |
212 | - | |
213 | - local findIdx = #globalCsv.pvp_division | |
214 | - for idx, limit in ipairs(globalCsv.pvp_division) do | |
215 | - if score < limit then | |
216 | - findIdx = idx - 1 | |
217 | - break | |
218 | - end | |
208 | + score = self:unpackPvpScore(redret[1]) | |
209 | + rank = tonumber(redret[2] or -2) + 1 | |
219 | 210 | end |
220 | - local levels = { | |
221 | - {}, {}, {} | |
222 | - } | |
223 | - if globalCsv.pvp_division[findIdx + 1] then | |
224 | - levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1} | |
225 | - end | |
226 | - levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1} | |
227 | - if globalCsv.pvp_division[findIdx - 1] then | |
228 | - levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1} | |
229 | - end | |
230 | - local redirect = {} | |
231 | - for i = #levels , 1, -1 do | |
232 | - if not next(levels[i]) then | |
233 | - table.remove(levels, i) | |
234 | - redirect[i] = -1 | |
235 | - for _, v in pairs(redirect) do | |
236 | - redirect[_] = v - 1 | |
237 | - end | |
238 | - else | |
239 | - redirect[i] = i | |
240 | - end | |
241 | - end | |
242 | - | |
243 | - local result = getPlayers(levels) | |
211 | + score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) | |
212 | + rank = rank or tonumber(redisproxy:zrevrank(dbKey, roleId) or -2) + 1 | |
213 | + | |
244 | 214 | local match = self:getProperty(mField) |
245 | 215 | local hadPlayer = {[roleId] = 1} |
246 | 216 | local hadRobot = {} |
... | ... | @@ -252,97 +222,261 @@ function Role:refreshPvpMatch(score, rankKey) |
252 | 222 | end |
253 | 223 | end |
254 | 224 | |
255 | - for _, temp in pairs(result) do | |
256 | - for i = #temp, 1, -1 do | |
257 | - local id = tonumber(temp[i]) | |
258 | - if hadPlayer[id] then | |
259 | - table.remove(temp, i) | |
260 | - else | |
261 | - temp[i] = id | |
262 | - hadPlayer[id] = 1 | |
263 | - end | |
225 | + local tempMatch = {} | |
226 | + local needRobot = 0 | |
227 | + -- -1 没有上榜 | |
228 | + if rank == -1 then | |
229 | + needRobot = NEED_MATCH | |
230 | + else | |
231 | + local need = PRE_RANGE_COUNT * NEED_MATCH | |
232 | + local low, heigh = math.floor(rank - need / 2 - 1), math.floor(rank + need / 2 - 1) | |
233 | + if low < 0 then | |
234 | + low = 0 | |
264 | 235 | end |
265 | - end | |
266 | - -- 增加第几个 | |
267 | - local function getPlayer(idx) | |
268 | - for i = idx, 3 do | |
269 | - if redirect[i] ~= -1 then | |
270 | - local curR = result[redirect[i]] or {} | |
271 | - if next(curR) then | |
272 | - local curIdx = math.randomInt(1, #curR) | |
273 | - local objId = curR[curIdx] | |
274 | - table.remove(curR, curIdx) | |
275 | - return objId | |
276 | - end | |
236 | + print(low, heigh) | |
237 | + local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh) | |
238 | + local lastRangeIds = {} | |
239 | + for idx, one in ipairs(rangeIds) do | |
240 | + local cid = tonumber(one) | |
241 | + if not hadPlayer[cid] then | |
242 | + lastRangeIds[#lastRangeIds + 1] = cid | |
277 | 243 | end |
278 | 244 | end |
279 | - end | |
280 | - | |
281 | - local tempMatch = {} | |
282 | - local curCount = 0 | |
283 | - for i = 1, 3 do | |
284 | - local objId = getPlayer(i) | |
285 | - if objId then | |
286 | - tempMatch[i] = {t = 1, id = objId} | |
287 | - curCount = curCount + 1 | |
245 | + if score < PVP_GET_ROBOT_SCORE then | |
246 | + needRobot = 1 | |
288 | 247 | end |
289 | - end | |
290 | - | |
291 | - -- 正常的玩家不够了 低一档继续 | |
292 | - if curCount < 3 then | |
293 | - local level = nil | |
294 | - if globalCsv.pvp_division[findIdx - 2] then | |
295 | - level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1} | |
248 | + local len = #lastRangeIds | |
249 | + if len < NEED_MATCH then | |
250 | + needRobot = NEED_MATCH - len | |
296 | 251 | end |
297 | - if level then | |
298 | - local result = getPlayers({level})[1] or {} | |
299 | - for i = #result, 1, -1 do | |
300 | - local id = tonumber(result[i]) | |
301 | - if hadPlayer[id] then | |
302 | - table.remove(result, i) | |
303 | - else | |
304 | - result[i] = id | |
305 | - hadPlayer[id] = 1 | |
306 | - end | |
252 | + local needPlayer = NEED_MATCH - needRobot | |
253 | + if needPlayer > 0 then | |
254 | + local pre = math.floor(len / needPlayer) | |
255 | + for i = 1, needPlayer do | |
256 | + local idx = math.randomInt((i - 1) * pre + 1, i * pre) | |
257 | + tempMatch[#tempMatch + 1] = {t = 1, id = lastRangeIds[idx]} | |
307 | 258 | end |
259 | + end | |
308 | 260 | |
309 | - if next(result) then | |
310 | - for i = curCount + 1, 3 do | |
311 | - local curIdx = math.randomInt(1, #result) | |
312 | - local objId = result[curIdx] | |
313 | - table.remove(result, curIdx) | |
314 | - tempMatch[i] = {t = 1, id = objId} | |
315 | - curCount = curCount + 1 | |
316 | - if not next(result) then | |
317 | - break | |
318 | - end | |
319 | - end | |
261 | + end | |
262 | + if needRobot > 0 then | |
263 | + local RobotPoolCount = 20 | |
264 | + local max = #csvdb[robotCsv] | |
265 | + local min = 1 | |
266 | + local mid | |
267 | + while min <= max do | |
268 | + mid = math.floor((min + max) / 2) | |
269 | + local tempPt = csvdb[robotCsv][mid].pt | |
270 | + if score == tempPt then | |
271 | + break | |
272 | + elseif score > tempPt then | |
273 | + min = mid + 1 | |
274 | + elseif score < tempPt then | |
275 | + max = mid - 1 | |
320 | 276 | end |
321 | 277 | end |
322 | - end | |
323 | - | |
324 | - -- 增加机器人 | |
325 | - if curCount < 3 then | |
326 | - for i = curCount + 1, 3 do | |
327 | - while true do | |
328 | - local id = math.randomInt(1, #csvdb[robotCsv]) | |
329 | - if not hadRobot[id] then | |
330 | - hadRobot[id] = 1 | |
331 | - tempMatch[i] = {t = 2, id = id} | |
332 | - break | |
333 | - end | |
278 | + assert(mid, "pvp no robot " .. robotCsv) | |
279 | + local low = mid - RobotPoolCount / 2 | |
280 | + local heigh = mid + RobotPoolCount / 2 | |
281 | + if low < 1 then | |
282 | + heigh = heigh + (1 - low) | |
283 | + low = 1 | |
284 | + end | |
285 | + if heigh > #csvdb[robotCsv] then | |
286 | + heigh = #csvdb[robotCsv] | |
287 | + end | |
288 | + local pools = {} | |
289 | + for i = low, heigh do | |
290 | + if not hadRobot[i] then | |
291 | + pools[#pools + 1] = i | |
334 | 292 | end |
335 | 293 | end |
294 | + local pre = math.floor(#pools / needRobot) | |
295 | + for i = 1, needRobot do | |
296 | + local idx = math.randomInt((i - 1) * pre + 1, i * pre) | |
297 | + tempMatch[#tempMatch + 1] = {t = 2, id = pools[idx]} | |
298 | + end | |
336 | 299 | end |
337 | 300 | self:setProperty(mField, tempMatch) |
338 | 301 | end |
339 | 302 | |
340 | -function Role:refreshPvpMatchC(score) | |
341 | - self:refreshPvpMatch(score, RANK_PVP_COMMON) | |
303 | +-- function Role:refreshPvpMatch(score, rank, rankKey) | |
304 | + | |
305 | +-- local Fields = { | |
306 | +-- [RANK_PVP_COMMON] = "pvpMC", | |
307 | +-- [RANK_PVP_HIGHT] = "pvpMH", | |
308 | +-- } | |
309 | +-- local RobotCsvs = { | |
310 | +-- [RANK_PVP_COMMON] = "pvp_robotCsv", | |
311 | +-- [RANK_PVP_HIGHT] = "pvp_robotCsv", | |
312 | +-- } | |
313 | +-- local mField = Fields[rankKey] | |
314 | +-- local robotCsv = RobotCsvs[rankKey] | |
315 | +-- local dbKey = self:getPvpDBKey(rankKey) | |
316 | + | |
317 | +-- local roleId = self:getProperty("id") | |
318 | +-- score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) | |
319 | + | |
320 | +-- local function getPlayers(levels) | |
321 | +-- local redret = redisproxy:pipelining(function(red) | |
322 | +-- for _, level in ipairs(levels) do | |
323 | +-- local low, high = table.unpack(level) | |
324 | +-- red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") | |
325 | +-- red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | |
326 | +-- red:ZREVRANK(dbKey, "std_temp1") | |
327 | +-- red:ZREVRANK(dbKey, "std_temp2") | |
328 | +-- end | |
329 | +-- red:zrem(dbKey, "std_temp1", "std_temp2") | |
330 | +-- end) | |
331 | + | |
332 | +-- local PreGetCount = 7 | |
333 | +-- local redret = redisproxy:pipelining(function(red) | |
334 | +-- for idx, level in ipairs(levels) do | |
335 | +-- local rank1 = tonumber(redret[(idx - 1) * 4 + 3]) | |
336 | +-- local rank2 = tonumber(redret[(idx - 1) * 4 + 4]) | |
337 | +-- if rank1 - rank2 > PreGetCount then | |
338 | +-- rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) | |
339 | +-- rank1 = rank2 + PreGetCount - 1 | |
340 | +-- end | |
341 | +-- red:ZREVRANGE(dbKey, rank2, rank1) | |
342 | +-- end | |
343 | +-- end) | |
344 | +-- return redret | |
345 | +-- end | |
346 | + | |
347 | +-- local findIdx = #globalCsv.pvp_division | |
348 | +-- for idx, limit in ipairs(globalCsv.pvp_division) do | |
349 | +-- if score < limit then | |
350 | +-- findIdx = idx - 1 | |
351 | +-- break | |
352 | +-- end | |
353 | +-- end | |
354 | +-- local levels = { | |
355 | +-- {}, {}, {} | |
356 | +-- } | |
357 | +-- if globalCsv.pvp_division[findIdx + 1] then | |
358 | +-- levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1} | |
359 | +-- end | |
360 | +-- levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1} | |
361 | +-- if globalCsv.pvp_division[findIdx - 1] then | |
362 | +-- levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1} | |
363 | +-- end | |
364 | +-- local redirect = {} | |
365 | +-- for i = #levels , 1, -1 do | |
366 | +-- if not next(levels[i]) then | |
367 | +-- table.remove(levels, i) | |
368 | +-- redirect[i] = -1 | |
369 | +-- for _, v in pairs(redirect) do | |
370 | +-- redirect[_] = v - 1 | |
371 | +-- end | |
372 | +-- else | |
373 | +-- redirect[i] = i | |
374 | +-- end | |
375 | +-- end | |
376 | + | |
377 | +-- local result = getPlayers(levels) | |
378 | +-- local match = self:getProperty(mField) | |
379 | +-- local hadPlayer = {[roleId] = 1} | |
380 | +-- local hadRobot = {} | |
381 | +-- for _, one in pairs(match) do | |
382 | +-- if one.t == 1 then | |
383 | +-- hadPlayer[one.id] = 1 | |
384 | +-- elseif one.t == 2 then | |
385 | +-- hadRobot[one.id] = 1 | |
386 | +-- end | |
387 | +-- end | |
388 | + | |
389 | +-- for _, temp in pairs(result) do | |
390 | +-- for i = #temp, 1, -1 do | |
391 | +-- local id = tonumber(temp[i]) | |
392 | +-- if hadPlayer[id] then | |
393 | +-- table.remove(temp, i) | |
394 | +-- else | |
395 | +-- temp[i] = id | |
396 | +-- hadPlayer[id] = 1 | |
397 | +-- end | |
398 | +-- end | |
399 | +-- end | |
400 | +-- -- 增加第几个 | |
401 | +-- local function getPlayer(idx) | |
402 | +-- for i = idx, 3 do | |
403 | +-- if redirect[i] ~= -1 then | |
404 | +-- local curR = result[redirect[i]] or {} | |
405 | +-- if next(curR) then | |
406 | +-- local curIdx = math.randomInt(1, #curR) | |
407 | +-- local objId = curR[curIdx] | |
408 | +-- table.remove(curR, curIdx) | |
409 | +-- return objId | |
410 | +-- end | |
411 | +-- end | |
412 | +-- end | |
413 | +-- end | |
414 | + | |
415 | +-- local tempMatch = {} | |
416 | +-- local curCount = 0 | |
417 | +-- for i = 1, 3 do | |
418 | +-- local objId = getPlayer(i) | |
419 | +-- if objId then | |
420 | +-- tempMatch[i] = {t = 1, id = objId} | |
421 | +-- curCount = curCount + 1 | |
422 | +-- end | |
423 | +-- end | |
424 | + | |
425 | +-- -- 正常的玩家不够了 低一档继续 | |
426 | +-- if curCount < 3 then | |
427 | +-- local level = nil | |
428 | +-- if globalCsv.pvp_division[findIdx - 2] then | |
429 | +-- level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1} | |
430 | +-- end | |
431 | +-- if level then | |
432 | +-- local result = getPlayers({level})[1] or {} | |
433 | +-- for i = #result, 1, -1 do | |
434 | +-- local id = tonumber(result[i]) | |
435 | +-- if hadPlayer[id] then | |
436 | +-- table.remove(result, i) | |
437 | +-- else | |
438 | +-- result[i] = id | |
439 | +-- hadPlayer[id] = 1 | |
440 | +-- end | |
441 | +-- end | |
442 | + | |
443 | +-- if next(result) then | |
444 | +-- for i = curCount + 1, 3 do | |
445 | +-- local curIdx = math.randomInt(1, #result) | |
446 | +-- local objId = result[curIdx] | |
447 | +-- table.remove(result, curIdx) | |
448 | +-- tempMatch[i] = {t = 1, id = objId} | |
449 | +-- curCount = curCount + 1 | |
450 | +-- if not next(result) then | |
451 | +-- break | |
452 | +-- end | |
453 | +-- end | |
454 | +-- end | |
455 | +-- end | |
456 | +-- end | |
457 | + | |
458 | +-- -- 增加机器人 | |
459 | +-- if curCount < 3 then | |
460 | +-- for i = curCount + 1, 3 do | |
461 | +-- while true do | |
462 | +-- local id = math.randomInt(1, #csvdb[robotCsv]) | |
463 | +-- if not hadRobot[id] then | |
464 | +-- hadRobot[id] = 1 | |
465 | +-- tempMatch[i] = {t = 2, id = id} | |
466 | +-- break | |
467 | +-- end | |
468 | +-- end | |
469 | +-- end | |
470 | +-- end | |
471 | +-- self:setProperty(mField, tempMatch) | |
472 | +-- end | |
473 | + | |
474 | +function Role:refreshPvpMatchC(score, rank) | |
475 | + self:refreshPvpMatch(score, rank, RANK_PVP_COMMON) | |
342 | 476 | end |
343 | 477 | |
344 | -function Role:refreshPvpMatchH(score) | |
345 | - self:refreshPvpMatch(score, RANK_PVP_HIGHT) | |
478 | +function Role:refreshPvpMatchH(score, rank) | |
479 | + self:refreshPvpMatch(score, rank, RANK_PVP_HIGHT) | |
346 | 480 | end |
347 | 481 | |
348 | 482 | function Role:getPvpDBKey(ptype) | ... | ... |