Commit 7cba658816e05745b0613e35559070ee7a2cd54f
Merge branch 'develop' into player
Showing
15 changed files
with
540 additions
and
14 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
... | ... | @@ -223,6 +223,10 @@ actionCodes = { |
223 | 223 | Activity_exchangeRpc = 657, |
224 | 224 | Activity_gachakonRpc = 658, |
225 | 225 | Activity_hangDropRpc = 659, |
226 | + Activity_startBattleRpc = 660, | |
227 | + Activity_endBattleRpc = 661, | |
228 | + Activity_battleRankRpc = 662, | |
229 | + Activity_battleMilestoneRpc = 663, | |
226 | 230 | |
227 | 231 | Radio_startQuestRpc = 700, |
228 | 232 | Radio_finishQuestRpc = 701, | ... | ... |
src/RedisKeys.lua
... | ... | @@ -15,6 +15,11 @@ R_STORE = "role:%d:store" -- 商店 |
15 | 15 | R_ORDERS = "role:%d:orders" -- 订单 |
16 | 16 | R_ORDER = "order:%d:%d" |
17 | 17 | |
18 | +-- 通用排行榜 | |
19 | +RANK_COMMON = "rank:common:" | |
20 | +RANK_TYPE = { | |
21 | + ActBattleBoss = "act_battle_boss", | |
22 | +} | |
18 | 23 | |
19 | 24 | -- rank |
20 | 25 | RANK_TOWER = "rank:tower" | ... | ... |
src/actions/ActivityAction.lua
... | ... | @@ -319,7 +319,6 @@ function _M.gachakonRpc(agent, data) |
319 | 319 | for i = 1, count do |
320 | 320 | local tmpCfg = clone(actCfg) |
321 | 321 | remain = 0 |
322 | - print("-----------------, ", i) | |
323 | 322 | for id, cfg in pairs(tmpCfg) do |
324 | 323 | local num = gachakonInfo[id] or 0 |
325 | 324 | num = cfg.amount >= num and cfg.amount - num or 0 |
... | ... | @@ -327,7 +326,7 @@ function _M.gachakonRpc(agent, data) |
327 | 326 | if cfg.weight > 0 then |
328 | 327 | remain = remain + num |
329 | 328 | end |
330 | - print("num ".. num, id, cfg.weight, cfg.amount) | |
329 | + --print("num ".. num, id, cfg.weight, cfg.amount) | |
331 | 330 | end |
332 | 331 | if remain == 0 then |
333 | 332 | break |
... | ... | @@ -350,9 +349,9 @@ function _M.gachakonRpc(agent, data) |
350 | 349 | role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
351 | 350 | |
352 | 351 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
353 | - if remain <= count then | |
352 | + --print("-----------", remain, count) | |
353 | + if remain <= 1 then | |
354 | 354 | gachakonInfo = {} |
355 | - print("hahaha") | |
356 | 355 | end |
357 | 356 | role.activity:updateActData("Gachakon", gachakonInfo) |
358 | 357 | |
... | ... | @@ -408,11 +407,329 @@ function _M.hangDropRpc(agent, data) |
408 | 407 | |
409 | 408 | reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}}) |
410 | 409 | |
411 | - role.activity:updateActData("HangDrop", timeNow) | |
410 | + if num < 8 then | |
411 | + actData = actData + num * period | |
412 | + else | |
413 | + actData = timeNow | |
414 | + end | |
415 | + | |
416 | + role.activity:updateActData("HangDrop", actData) | |
412 | 417 | |
413 | 418 | SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change))) |
414 | 419 | |
415 | 420 | return true |
416 | 421 | end |
417 | 422 | |
423 | +local function getStarCount(cfg, data) | |
424 | + local count = 0 | |
425 | + for i = 0, #(cfg.sweep_condition:toTableArray(true)) do | |
426 | + if (1 << i & data) > 0 then | |
427 | + count = count + 1 | |
428 | + end | |
429 | + end | |
430 | + | |
431 | + return count | |
432 | +end | |
433 | + | |
434 | +function _M.startBattleRpc(agent, data) | |
435 | + local role = agent.role | |
436 | + local msg = MsgPack.unpack(data) | |
437 | + local actid = msg.actid | |
438 | + local id = msg.id | |
439 | + local count = msg.count | |
440 | + if not role.activity:isOpenById(actid) then return 1 end | |
441 | + | |
442 | + local actCfg = csvdb["activity_battleCsv"][actid] | |
443 | + if not actCfg then return 2 end | |
444 | + | |
445 | + local battleCfg = actCfg[id] | |
446 | + if not battleCfg then return 3 end | |
447 | + | |
448 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
449 | + | |
450 | + local preArr = battleCfg.prepose:toArray(true, "=") | |
451 | + for _, v in ipairs(preArr) do | |
452 | + local battleInfo = actData[v] | |
453 | + if not battleInfo then | |
454 | + return 4 | |
455 | + end | |
456 | + local star = battleInfo["star"] or 0 | |
457 | + if star <= 0 then | |
458 | + return 4 | |
459 | + end | |
460 | + end | |
461 | + -- check cost | |
462 | + local changeFlag = false | |
463 | + local ticket = actData["ticket"] | |
464 | + if battleCfg.type ~= "" then | |
465 | + role.activity:getBattleTicket(actid) | |
466 | + local num = battleCfg.type:toArray(true, "=")[3] | |
467 | + if count and count > 0 then | |
468 | + if battleCfg.rank == 0 then | |
469 | + return 7 | |
470 | + end | |
471 | + local bi = actData[id] | |
472 | + if not bi then return 8 end | |
473 | + local star = bi["star"] or 0 | |
474 | + if star < 1 then | |
475 | + return 9 | |
476 | + end | |
477 | + num = num * count | |
478 | + end | |
479 | + if ticket < num then | |
480 | + return 6 | |
481 | + end | |
482 | + actData["ticket"] = ticket - num | |
483 | + changeFlag = true | |
484 | + end | |
485 | + | |
486 | + if not count then | |
487 | + role.__actBattleCache = { | |
488 | + key = tostring(math.random()), | |
489 | + actid = actid, | |
490 | + id = id, | |
491 | + } | |
492 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack({key = role.__actBattleCache.key})) | |
493 | + else | |
494 | + if count <= 0 then | |
495 | + return | |
496 | + end | |
497 | + if battleCfg.rank == 0 then | |
498 | + return 7 | |
499 | + end | |
500 | + local bi = actData[id] | |
501 | + local star = bi["star"] | |
502 | + local award = battleCfg.item_clear:toNumMap() | |
503 | + if getStarCount(battleCfg, star) == 3 then | |
504 | + local aw = battleCfg.perfect_reward:toNumMap() | |
505 | + for k, v in pairs(aw) do | |
506 | + award[k] = (award[k] or 0) + v | |
507 | + end | |
508 | + end | |
509 | + for k, v in pairs(award) do | |
510 | + award[k] = v * count | |
511 | + end | |
512 | + local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | |
513 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) | |
514 | + | |
515 | + bi["sum"] = bi["sum"] + bi["top"] | |
516 | + actData[id] = bi | |
517 | + changeFlag = true | |
518 | + | |
519 | + local rankVal = 0 | |
520 | + if battleCfg.rank == 1 then | |
521 | + rankVal = bi["sum"] | |
522 | + elseif battleCfg.rank == 2 then | |
523 | + rankVal = bi["top"] | |
524 | + end | |
525 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | |
526 | + end | |
527 | + if changeFlag then | |
528 | + role.activity:updateActData("ChallengeLevel", actData) | |
529 | + end | |
530 | + | |
531 | + return true | |
532 | +end | |
533 | + | |
534 | +function _M.endBattleRpc(agent, data) | |
535 | + local role = agent.role | |
536 | + local msg = MsgPack.unpack(data) | |
537 | + local actid = msg.actid | |
538 | + local id = msg.id | |
539 | + local key = msg.key | |
540 | + local isWin = msg.isWin | |
541 | + local heros = msg.heros | |
542 | + local support = msg.support | |
543 | + if not role.activity:isOpenById(actid) then return 1 end | |
544 | + | |
545 | + if not role.__actBattleCache then return 2 end | |
546 | + | |
547 | + if role.__actBattleCache.id ~= id or role.__actBattleCache.key ~= key and role.__actBattleCache.actid ~= actid then | |
548 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1})) | |
549 | + end | |
550 | + | |
551 | + local actCfg = csvdb["activity_battleCsv"][actid] | |
552 | + if not actCfg then return 3 end | |
553 | + | |
554 | + local battleCfg = actCfg[id] | |
555 | + if not battleCfg then return 4 end | |
556 | + | |
557 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
558 | + | |
559 | + local reward, change = {}, nil | |
560 | + | |
561 | + local battleInfo = actData[id] or {} | |
562 | + local curStar = 0 | |
563 | + if isWin then | |
564 | + local herosInfo = msg.heros | |
565 | + | |
566 | + local check = {} | |
567 | + -- 1 通关 | |
568 | + check[1] = function(_) | |
569 | + return true | |
570 | + end | |
571 | + -- 2 阵亡人数 <= N | |
572 | + check[2] = function(_, cond) | |
573 | + return msg.info.dead and msg.info.dead <= cond | |
574 | + end | |
575 | + -- 3 全员存活 | |
576 | + check[3] = function(_) | |
577 | + return msg.info.dead and msg.info.dead == 0 | |
578 | + end | |
579 | + -- 4 指定种族 >= N | |
580 | + check[4] = function(_, cond) | |
581 | + local count = 0 | |
582 | + for _, one in pairs(herosInfo) do | |
583 | + local heroData = csvdb["unitCsv"][one.type] | |
584 | + if heroData.camp == cond then | |
585 | + count = count + 1 | |
586 | + end | |
587 | + end | |
588 | + return count >= cond | |
589 | + end | |
590 | + -- 5 指定职业 >= N | |
591 | + check[5] = function(_, cond) | |
592 | + local count = 0 | |
593 | + for _, one in pairs(herosInfo) do | |
594 | + local heroData = csvdb["unitCsv"][one.type] | |
595 | + if heroData.job == cond then | |
596 | + count = count + 1 | |
597 | + end | |
598 | + end | |
599 | + return count >= cond | |
600 | + end | |
601 | + -- 6 含有指定角色 | |
602 | + check[6] = function(_, cond) | |
603 | + for _, one in pairs(herosInfo) do | |
604 | + if one.type == cond then | |
605 | + return true | |
606 | + end | |
607 | + end | |
608 | + return false | |
609 | + end | |
610 | + -- 7 通关耗时 <= X 秒 msg.info.atime | |
611 | + check[7] = function(_, cond) | |
612 | + return msg.info.atime and msg.info.atime <= cond | |
613 | + end | |
614 | + curStar = 0 | |
615 | + local sweepConds = battleCfg.sweep_condition:toTableArray(true) | |
616 | + for i, cond in ipairs(sweepConds) do | |
617 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | |
618 | + curStar = curStar + (1 << (i - 1)) | |
619 | + end | |
620 | + end | |
621 | + else | |
622 | + curStar = 0 | |
623 | + end | |
624 | + local oldStarNum = getStarCount(battleCfg, battleInfo["star"] or 0) | |
625 | + local newStarNum = getStarCount(battleCfg, curStar) | |
626 | + if newStarNum > oldStarNum then | |
627 | + battleInfo["star"] = curStar | |
628 | + end | |
629 | + | |
630 | + if battleCfg.rank ~= 0 then | |
631 | + -- 更新排行榜 最高伤害 | |
632 | + local dmg = 0 | |
633 | + for k, v in pairs(msg.info.damage) do | |
634 | + if k % 100 == 2 then | |
635 | + dmg = dmg + v | |
636 | + end | |
637 | + end | |
638 | + battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg) | |
639 | + battleInfo["sum"] = (battleInfo["sum"] or 0) + dmg | |
640 | + local rankVal = 0 | |
641 | + if battleCfg.rank == 1 then | |
642 | + rankVal = battleInfo["sum"] | |
643 | + elseif battleCfg.rank == 2 then | |
644 | + rankVal = battleInfo["top"] | |
645 | + end | |
646 | + if rankVal > 0 then | |
647 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | |
648 | + end | |
649 | + end | |
650 | + actData[id] = battleInfo | |
651 | + role.activity:updateActData("ChallengeLevel", actData) | |
652 | + | |
653 | + if oldStarNum == 0 or battleCfg.rank ~= 0 then | |
654 | + reward = battleCfg.item_clear:toNumMap() | |
655 | + end | |
656 | + if (oldStarNum < 3 and newStarNum == 3) or battleCfg.rank ~= 0 then | |
657 | + local aw = battleCfg.perfect_reward:toNumMap() | |
658 | + for k, v in pairs(aw) do | |
659 | + reward[k] = (reward[k] or 0) + v | |
660 | + end | |
661 | + end | |
662 | + | |
663 | + role:checkBattle("act_battle", { | |
664 | + cfg = battleCfg, | |
665 | + star = newStarNum, | |
666 | + isWin = isWin, | |
667 | + info = msg.info, | |
668 | + reward = reward, | |
669 | + heros = heros, | |
670 | + supports = support, | |
671 | + }) | |
672 | + | |
673 | + reward, change = role:award(reward, {log = {desc = "actBattle", int1 = actid, int2 = newStarNum}}) | |
674 | + | |
675 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({ | |
676 | + reward = reward, | |
677 | + change = change | |
678 | + })) | |
679 | + | |
680 | + return true | |
681 | +end | |
682 | + | |
683 | +function _M.battleRankRpc(agent, data) | |
684 | + local role = agent.role | |
685 | + local msg = MsgPack.unpack(data) | |
686 | + local actid = msg.actid | |
687 | + if not role.activity:isOpenById(actid) then return 1 end | |
688 | + | |
689 | + local rankInfo = role:getRankInfoCommon(RANK_TYPE.ActBattleBoss) | |
690 | + | |
691 | + SendPacket(actionCodes.Activity_battleRankRpc, MsgPack.pack(rankInfo)) | |
692 | + return true | |
693 | +end | |
694 | + | |
695 | +function _M.battleMilestoneRpc(agent, data) | |
696 | + local role = agent.role | |
697 | + local msg = MsgPack.unpack(data) | |
698 | + local actid = msg.actid | |
699 | + local id = msg.id | |
700 | + local index = msg.index | |
701 | + | |
702 | + if not role.activity:isOpenById(actid) then return 1 end | |
703 | + | |
704 | + local actCfg = csvdb["activity_mileageCsv"][actid] | |
705 | + if not actCfg then return 3 end | |
706 | + | |
707 | + local mileCfg = actCfg[index] | |
708 | + if not mileCfg then return 4 end | |
709 | + | |
710 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
711 | + local battleInfo = actData[id] or {} | |
712 | + local val = 0 | |
713 | + if mileCfg.type == 1 then | |
714 | + val = battleInfo["sum"] or 0 | |
715 | + elseif mileCfg.type == 2 then | |
716 | + val = battleInfo["top"] or 0 | |
717 | + end | |
718 | + | |
719 | + local record = battleInfo["r"] or "" | |
720 | + local flag = string.char(string.getbit(record, index)) | |
721 | + if flag == "1" then return 5 end | |
722 | + if mileCfg.condition > val then return 6 end | |
723 | + | |
724 | + battleInfo["r"] = string.setbit(record, index) | |
725 | + actData[id] = battleInfo | |
726 | + role.activity:updateActData("ChallengeLevel", actData) | |
727 | + | |
728 | + local award = mileCfg.reward:toNumMap() | |
729 | + local reward, change = role:award(award, {log = {desc = "actMilestone", int1 = actid, int2 = index}}) | |
730 | + SendPacket(actionCodes.Activity_battleMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | |
731 | + | |
732 | + return true | |
733 | +end | |
734 | + | |
418 | 735 | return _M |
419 | 736 | \ No newline at end of file | ... | ... |
src/actions/GmAction.lua
src/actions/HangAction.lua
... | ... | @@ -632,7 +632,7 @@ function _M.endBonusBattleRpc(agent, data) |
632 | 632 | check[4] = function(_, cond) |
633 | 633 | local count = 0 |
634 | 634 | for _, one in pairs(herosInfo) do |
635 | - local heroData = csv["unitCsv"][one.type] | |
635 | + local heroData = csvdb["unitCsv"][one.type] | |
636 | 636 | if heroData.camp == cond then |
637 | 637 | count = count + 1 |
638 | 638 | end |
... | ... | @@ -643,7 +643,7 @@ function _M.endBonusBattleRpc(agent, data) |
643 | 643 | check[5] = function(_, cond) |
644 | 644 | local count = 0 |
645 | 645 | for _, one in pairs(herosInfo) do |
646 | - local heroData = csv["unitCsv"][one.type] | |
646 | + local heroData = csvdb["unitCsv"][one.type] | |
647 | 647 | if heroData.job == cond then |
648 | 648 | count = count + 1 |
649 | 649 | end | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -477,8 +477,6 @@ function _M.referEquipsRpc(agent, data) |
477 | 477 | -- 更新角色 |
478 | 478 | hero:updateProperty({field = "equip", value = curEquip}) |
479 | 479 | |
480 | - role:finishGuide(23) | |
481 | - | |
482 | 480 | local curAttr = hero:getTotalAttrs() |
483 | 481 | local attrChange = getChangeAttrJson(oldAttr, curAttr) |
484 | 482 | for typ, data in pairs(wear) do | ... | ... |
src/adv/AdvBuff.lua
... | ... | @@ -490,6 +490,7 @@ function Buff:createAfter(layer) |
490 | 490 | self:_init() |
491 | 491 | end |
492 | 492 | self:pushBackEffect(1) |
493 | + buglog("Buff", "who: %s create buffId: %s", self.owner.monsterId, self.id) | |
493 | 494 | end |
494 | 495 | |
495 | 496 | function Buff:initByDB(data) |
... | ... | @@ -632,6 +633,7 @@ function Buff:pushBackEffect(etype) |
632 | 633 | end |
633 | 634 | |
634 | 635 | function Buff:effect() |
636 | + buglog("Buff", "who: %s effect buffId: %s", self.owner.monsterId, self.id) | |
635 | 637 | self:decCount() |
636 | 638 | self:pushBackEffect(2) |
637 | 639 | if self._effectValue then |
... | ... | @@ -655,6 +657,7 @@ function Buff:endBuff() |
655 | 657 | if self._endBuff then |
656 | 658 | self:_endBuff() |
657 | 659 | end |
660 | + buglog("Buff", "who: %s endBuff buffId: %s", self.owner.monsterId, self.id) | |
658 | 661 | end |
659 | 662 | |
660 | 663 | function Buff:getType() |
... | ... | @@ -709,6 +712,7 @@ function Buff:overlay(releaser, data, layer) |
709 | 712 | end |
710 | 713 | |
711 | 714 | self:pushBackEffect(1) |
715 | + buglog("Buff", "who: %s overlay buffId: %s", self.owner.monsterId, self.id) | |
712 | 716 | end |
713 | 717 | end |
714 | 718 | ... | ... |
src/adv/AdvPassive.lua
... | ... | @@ -354,6 +354,7 @@ function Passive:effect(triggerPms) |
354 | 354 | end |
355 | 355 | if hadEffect then |
356 | 356 | self.owner.battle.adv:pushBackEvent(AdvBackEventType.PassiveEffect, {id = self.id, level = self.level, roomId = self.owner.roomId, blockId = self.owner.blockId}) |
357 | + buglog("Passive", "who: %s effect id: %s", self.owner.monsterId, self.id) | |
357 | 358 | end |
358 | 359 | if self.count > 0 then |
359 | 360 | self.count = self.count < 999 and self.count - 1 or self.count |
... | ... | @@ -404,6 +405,8 @@ function Passive:trigger(condType, params) --触发检查 |
404 | 405 | params = params or {} |
405 | 406 | if self.isDel or self.owner.isDead then return end |
406 | 407 | if self:getCondType() ~= condType then return end |
408 | + | |
409 | + buglog("Passive", "who: %s trigger id: %s", self.owner.monsterId, self.id) | |
407 | 410 | if not self:canTrigger() then return end |
408 | 411 | if self._trigger then |
409 | 412 | if not self:_trigger(params) then return end --检查 |
... | ... | @@ -600,5 +603,9 @@ function Passive:effect16(value, triggerPms, changeType) |
600 | 603 | self.owner.battle.adv:blockDropChange(changeType, blocks) |
601 | 604 | end |
602 | 605 | |
606 | +--17=玩家获得buff | |
607 | +function Passive:effect17(value, triggerPms) | |
608 | + self.owner.battle.player:addBuff(value, self.owner) | |
609 | +end | |
603 | 610 | |
604 | 611 | return Passive |
605 | 612 | \ No newline at end of file | ... | ... |
src/models/Activity.lua
... | ... | @@ -179,6 +179,7 @@ function Activity:checkActivityStatus(now, isCrossDay, notify) |
179 | 179 | |
180 | 180 | if isOpen then |
181 | 181 | if actime[actId] and actime[actId] == startTime then -- 还是之前的状态 开放中 |
182 | + self:onLoginActivity(actId) | |
182 | 183 | else -- 重置 |
183 | 184 | actime[actId] = startTime |
184 | 185 | self:closeActivity(actId, notify, true) |
... | ... | @@ -419,7 +420,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = { |
419 | 420 | local towerInfo = role:getProperty("towerInfo") |
420 | 421 | role:checkTaskEnter("TowerPass", {level = towerInfo.l}) |
421 | 422 | --"PvpWin" |
422 | - role:checkTaskEnter("HangPass", {}) | |
423 | + --role:checkTaskEnter("HangPass", {id = 0}) | |
424 | + role:checkCalendaTask(true, 15, 3) | |
423 | 425 | role:checkTaskEnter("HeroStarCollect", {}) |
424 | 426 | role:checkTaskEnter("RuneQualityCollect", {}) |
425 | 427 | |
... | ... | @@ -475,7 +477,8 @@ activityFunc[Activity.ActivityType.Gachakon] = { |
475 | 477 | activityFunc[Activity.ActivityType.HangDrop] = { |
476 | 478 | ["init"] = function(self, actType, isCrossDay, notify, actId) |
477 | 479 | local actime = self:getProperty("actime") |
478 | - local startTime = actime[actId] | |
480 | + local ctime = self.owner:getProperty("ctime") | |
481 | + local startTime = math.max(actime[actId], ctime) | |
479 | 482 | local actData = self:getActData(actType) or 0 |
480 | 483 | local cfg = csvdb["activity_putCsv"][actId] |
481 | 484 | if not cfg then return end |
... | ... | @@ -484,11 +487,30 @@ activityFunc[Activity.ActivityType.HangDrop] = { |
484 | 487 | end |
485 | 488 | } |
486 | 489 | |
490 | +--ChallengeLevel | |
491 | +activityFunc[Activity.ActivityType.ChallengeLevel] = { | |
492 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
493 | + self:getBattleTicket(actId) | |
494 | + end, | |
495 | + ["login"] = function(self, actType, actId) | |
496 | + self:getBattleTicket(actId) | |
497 | + end | |
498 | +} | |
499 | + | |
500 | +function Activity:onLoginActivity(actId) | |
501 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
502 | + if not actData then return end | |
503 | + local actType = actData.showType | |
504 | + if activityFunc[actType] and activityFunc[actType]['login'] then | |
505 | + activityFunc[actType]["login"](self, actType, actId) | |
506 | + end | |
507 | +end | |
508 | + | |
487 | 509 | function Activity:initActivity(actId, isCrossDay, notify) |
488 | 510 | local actData = csvdb["activity_ctrlCsv"][actId] |
489 | 511 | if not actData then return end |
490 | 512 | local actType = actData.showType |
491 | - if activityFunc[actType] and activityFunc[actType]['close'] then | |
513 | + if activityFunc[actType] and activityFunc[actType]['init'] then | |
492 | 514 | activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) |
493 | 515 | end |
494 | 516 | end |
... | ... | @@ -633,5 +655,39 @@ function Activity:recycleActItem(actId) |
633 | 655 | end |
634 | 656 | end |
635 | 657 | |
658 | +-- 活动挑战关卡计算门票 | |
659 | +function Activity:getBattleTicket(actId) | |
660 | + local role = self.owner | |
661 | + local createTs = role:getProperty("ctime") | |
662 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | |
663 | + if not actCfg then return 0 end | |
664 | + | |
665 | + local actStartTime = 0 | |
666 | + local openTimes = actCfg.time:toArray(false, "=") | |
667 | + actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME)) | |
668 | + local actData = self:getActData("ChallengeLevel") or {} | |
669 | + local startTs = actData["ts"] or math.max(actStartTime, createTs) | |
670 | + local timeNow = skynet.timex() | |
671 | + local modify = false | |
672 | + local arr = actCfg.condition2:toArray(true, "=") | |
673 | + | |
674 | + local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000 | |
675 | + | |
676 | + local count = actData["ticket"] or init | |
677 | + local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0) | |
678 | + | |
679 | + local newCount= math.min(count + add, limit) | |
680 | + if newCount ~= count or newCount >= limit then | |
681 | + modify = true | |
682 | + end | |
683 | + add = newCount - count | |
684 | + | |
685 | + if modify or not next(actData) then | |
686 | + actData["ticket"] = newCount | |
687 | + actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60) | |
688 | + self:updateActData("ChallengeLevel", actData) | |
689 | + end | |
690 | +end | |
691 | + | |
636 | 692 | |
637 | 693 | return Activity | ... | ... |
src/models/RoleBattle.lua
... | ... | @@ -16,6 +16,7 @@ local BattleType = { |
16 | 16 | bonus = 300, |
17 | 17 | pvpc = 500, |
18 | 18 | pvph = 501, |
19 | + act_battle = 502, | |
19 | 20 | } |
20 | 21 | |
21 | 22 | RoleBattle.bind = function (Role) |
... | ... | @@ -86,6 +87,20 @@ function Role:checkBattle(battleType, params) |
86 | 87 | enemylist[#enemylist + 1] = one["unitType"] |
87 | 88 | end |
88 | 89 | end, |
90 | + act_battle = function() | |
91 | + for slot, hero in pairs(self:getTeamHerosInfo(params.heros)) do | |
92 | + selflist[slot] = hero.type | |
93 | + end | |
94 | + heroscore = self:getTeamBattleValue(params.heros) | |
95 | + for slot , one in pairs(params.supports) do | |
96 | + teamskill[one[1]] = one[2] | |
97 | + end | |
98 | + local carbonData = params.cfg | |
99 | + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] | |
100 | + for slot, one in pairs(monsterData[1]) do | |
101 | + enemylist[#enemylist + 1] = one["unitType"] | |
102 | + end | |
103 | + end, | |
89 | 104 | pvpc = function() |
90 | 105 | for slot, hero in pairs(self:getProperty("pvpTSC")) do |
91 | 106 | selflist[slot] = hero.type |
... | ... | @@ -163,7 +178,7 @@ function Role:checkBattle(battleType, params) |
163 | 178 | mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级 |
164 | 179 | mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒) |
165 | 180 | mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败) |
166 | - mission_star = 0, -- 战斗完成星数,无星级的话填写0 | |
181 | + mission_star = params.star or 0, -- 战斗完成星数,无星级的话填写0 | |
167 | 182 | mission_restriction = 0, -- 周期内参与限制(0表示没有上限) |
168 | 183 | mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0 |
169 | 184 | mission_strength = 1, -- 消耗的体力或次数 | ... | ... |
src/models/RoleLog.lua
src/models/RolePlugin.lua
... | ... | @@ -1929,6 +1929,53 @@ function RolePlugin.bind(Role) |
1929 | 1929 | end |
1930 | 1930 | deleteNotify({pattern = pattern}) |
1931 | 1931 | end |
1932 | + | |
1933 | + local CommonRankTime = toUnixtime("2019010100") | |
1934 | + local CommonCoef1 = 10000 | |
1935 | + local CommonCoef2 = 10000 | |
1936 | + function Role:updateRankCommon(rankType, rankVal, reserve) | |
1937 | + if not rankType then return end | |
1938 | + reserve = reserve or 0 | |
1939 | + local now = skynet.timex() | |
1940 | + local ct = math.ceil((now - CommonRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | |
1941 | + ct = 10000 - ct -- 越早的排名越靠前 | |
1942 | + local score = (rankVal * CommonCoef1 + ct) * CommonCoef2 + reserve | |
1943 | + | |
1944 | + local roleId = self:getProperty("id") | |
1945 | + redisproxy:pipelining(function (red) | |
1946 | + red:zadd(RANK_COMMON..rankType, score, roleId) --更新分数 | |
1947 | + end) | |
1948 | + end | |
1949 | + | |
1950 | + function Role:getRankInfoCommon(rankType) | |
1951 | + if not rankType then return end | |
1952 | + local list = {} | |
1953 | + local rankKey = RANK_COMMON .. rankType | |
1954 | + local ids = redisproxy:zrevrange(rankKey, 0 , 99, "WITHSCORES") | |
1955 | + for i = 1, #ids, 2 do | |
1956 | + local roleId = tonumber(ids[i]) | |
1957 | + local rankVal = tonumber(ids[i + 1]) | |
1958 | + rankVal = math.floor(math.floor(rankVal / CommonCoef2) / CommonCoef1) | |
1959 | + table.insert(list, {roleId = roleId, player = rankVal}) | |
1960 | + end | |
1961 | + | |
1962 | + for _, v in ipairs(list) do | |
1963 | + local _, curInfo = rpcRole(v.roleId, "friendSInfo") | |
1964 | + curInfo.ltime = nil | |
1965 | + curInfo.rankVal = v.player | |
1966 | + v.player = curInfo | |
1967 | + end | |
1968 | + | |
1969 | + local rank = redisproxy:ZREVRANK(rankKey, self:getProperty("id")) | |
1970 | + if not rank then | |
1971 | + rank = -1 | |
1972 | + else | |
1973 | + rank = rank + 1 | |
1974 | + end | |
1975 | + return {list = list, rank = rank} | |
1976 | + end | |
1977 | + | |
1978 | + | |
1932 | 1979 | end |
1933 | 1980 | |
1934 | 1981 | return RolePlugin |
1935 | 1982 | \ No newline at end of file | ... | ... |
src/services/globald.lua
... | ... | @@ -7,6 +7,7 @@ require "shared.init" |
7 | 7 | require "utils.init" |
8 | 8 | require "RedisKeys" |
9 | 9 | require "skynet.manager" |
10 | +require "GlobalVar" | |
10 | 11 | |
11 | 12 | |
12 | 13 | local ipairs = ipairs |
... | ... | @@ -16,6 +17,7 @@ local string_format = string.format |
16 | 17 | |
17 | 18 | |
18 | 19 | local CHECK_MAIL_STATUS_INTERVAL = 100 * 60 |
20 | +local CHECK_BATTLE_ACT_CLOSE_INTERVAL = 100 * 1 | |
19 | 21 | local function mailQuene() |
20 | 22 | local delayEmail = tonum(redisproxy:hget("autoincrement_set", "delay_email")) |
21 | 23 | if delayEmail == 0 then |
... | ... | @@ -91,6 +93,64 @@ local function check_mail_queue() |
91 | 93 | skynet.timeout(CHECK_MAIL_STATUS_INTERVAL, check_mail_queue) |
92 | 94 | end |
93 | 95 | |
96 | +-- @desc: 检测关卡活动结束 排行榜奖励发放 | |
97 | +local lastCheckBattleActTs = 0 | |
98 | +local function check_battle_act_close() | |
99 | + local csvdb = require "shared.csvdata" | |
100 | + local act = require "models.Activity" | |
101 | + local st = 0 | |
102 | + local et = 0 | |
103 | + local actId = 0 | |
104 | + local timeNow = skynet.timex() | |
105 | + for k, v in pairs(csvdb["activity_ctrlCsv"]) do | |
106 | + if v.showType == act.ActivityType.ChallengeLevel then | |
107 | + local openTimes = v.time:toArray(false, "=") | |
108 | + if openTimes[1] ~= "0" then | |
109 | + st = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME)) | |
110 | + end | |
111 | + if openTimes[2] ~= "0" then | |
112 | + et = toUnixtime(openTimes[2]..string_format("%02x", RESET_TIME)) | |
113 | + end | |
114 | + actId = k | |
115 | + break | |
116 | + end | |
117 | + end | |
118 | + if st ~= 0 and et ~= 0 and actId ~= 0 then | |
119 | + -- close | |
120 | + if lastCheckBattleActTs < et and timeNow >= et then | |
121 | + -- check rank key exist | |
122 | + local rankKey = RANK_COMMON..RANK_TYPE.ActBattleBoss | |
123 | + local flag = redisproxy:exists(rankKey) | |
124 | + if flag then | |
125 | + local actData = csvdb["activity_groupCsv"][actId] | |
126 | + local lastRank = actData[#actData].rank | |
127 | + | |
128 | + local ids = redisproxy:zrevrange(rankKey, 0 , lastRank - 1) | |
129 | + local rankIndex = 0 | |
130 | + for roleId in pairs(ids) do | |
131 | + rankIndex = rankIndex + 1 | |
132 | + for _, cfg in pairs(actData) do | |
133 | + if rankIndex <= cfg.rank then | |
134 | + redisproxy:insertEmail({ | |
135 | + roleId = roleId, | |
136 | + emailId = cfg.email_1, | |
137 | + attachments = cfg.reward_1, | |
138 | + contentPms = {rankIndex}, | |
139 | + }) | |
140 | + break | |
141 | + end | |
142 | + end | |
143 | + end | |
144 | + | |
145 | + redisproxy:del(rankKey..":bak") | |
146 | + redisproxy:rename(rankKey, rankKey..":bak") | |
147 | + end | |
148 | + end | |
149 | + end | |
150 | + lastCheckBattleActTs = skynet.timex() | |
151 | + skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close) | |
152 | +end | |
153 | + | |
94 | 154 | |
95 | 155 | |
96 | 156 | local CMD = {} |
... | ... | @@ -115,6 +175,7 @@ end |
115 | 175 | |
116 | 176 | function CMD.start() |
117 | 177 | check_mail_queue() |
178 | + check_battle_act_close() | |
118 | 179 | end |
119 | 180 | |
120 | 181 | local function __init__() | ... | ... |