Commit 50da0e3763617072f2c3d2e740b1b9659455d85f
1 parent
dac9fbcc
挑战关卡活动 普通关卡扫荡,购买挑战次数
Showing
4 changed files
with
68 additions
and
35 deletions
Show diff stats
src/ProtocolCode.lua
... | ... | @@ -259,6 +259,7 @@ actionCodes = { |
259 | 259 | Activity_buyBattleCommandLvlRpc = 672, |
260 | 260 | Activity_returnerTaskRpc = 673, |
261 | 261 | Activity_actNewUserTaskRpc = 674, |
262 | + Activity_buyBattleTicketRpc = 675, | |
262 | 263 | |
263 | 264 | Radio_startQuestRpc = 700, |
264 | 265 | Radio_finishQuestRpc = 701, | ... | ... |
src/actions/ActivityAction.lua
... | ... | @@ -588,24 +588,23 @@ function _M.startBattleRpc(agent, data) |
588 | 588 | role.activity:getBattleTicket(actid) |
589 | 589 | num = battleCfg.type:toArray(true, "=")[3] |
590 | 590 | if count and count > 0 then |
591 | - if battleCfg.rank == 0 then | |
592 | - return 7 | |
591 | + if battleCfg.rank ~= 0 then | |
592 | + local bi = actData[id] | |
593 | + if not bi then return 8 end | |
594 | + local star = bi["star"] or 0 | |
595 | + local maxP = bi["maxP"] or 0 | |
596 | + -- 世界boss | |
597 | + if battleCfg.worldBoss_award ~= 0 then | |
598 | + if maxP < 1 then | |
599 | + return 9 | |
600 | + end | |
601 | + else | |
602 | + if star < 1 then | |
603 | + return 9 | |
604 | + end | |
605 | + end | |
593 | 606 | end |
594 | - local bi = actData[id] | |
595 | - if not bi then return 8 end | |
596 | - local star = bi["star"] or 0 | |
597 | - local maxP = bi["maxP"] or 0 | |
598 | - -- 世界boss | |
599 | - if battleCfg.worldBoss_award ~= 0 then | |
600 | - if maxP < 1 then | |
601 | - return 9 | |
602 | - end | |
603 | - else | |
604 | - if star < 1 then | |
605 | - return 9 | |
606 | - end | |
607 | - end | |
608 | - num = num * count | |
607 | + num = num * count | |
609 | 608 | end |
610 | 609 | if ticket < num then |
611 | 610 | return 6 |
... | ... | @@ -627,9 +626,7 @@ function _M.startBattleRpc(agent, data) |
627 | 626 | if count <= 0 then |
628 | 627 | return |
629 | 628 | end |
630 | - if battleCfg.rank == 0 then | |
631 | - return 7 | |
632 | - end | |
629 | + | |
633 | 630 | local bi = actData[id] |
634 | 631 | local star = bi["star"] or 0 |
635 | 632 | local award = battleCfg.item_clear:toNumMap() |
... | ... | @@ -644,23 +641,26 @@ function _M.startBattleRpc(agent, data) |
644 | 641 | end |
645 | 642 | local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) |
646 | 643 | SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) |
644 | + changeFlag = true | |
645 | + actData["ticket"] = ticket - num | |
647 | 646 | |
648 | - if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | |
649 | - bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count | |
647 | + if battleCfg.rank ~= 0 then | |
648 | + if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | |
649 | + bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count | |
650 | + end | |
651 | + | |
652 | + bi["sum"] = bi["sum"] + bi["top"] * count | |
653 | + actData[id] = bi | |
654 | + | |
655 | + local rankVal = 0 | |
656 | + if battleCfg.rank == 1 then | |
657 | + rankVal = bi["sum"] | |
658 | + elseif battleCfg.rank == 2 then | |
659 | + rankVal = bi["top"] | |
660 | + end | |
661 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | |
650 | 662 | end |
651 | 663 | |
652 | - bi["sum"] = bi["sum"] + bi["top"] * count | |
653 | - actData["ticket"] = ticket - num | |
654 | - actData[id] = bi | |
655 | - changeFlag = true | |
656 | - | |
657 | - local rankVal = 0 | |
658 | - if battleCfg.rank == 1 then | |
659 | - rankVal = bi["sum"] | |
660 | - elseif battleCfg.rank == 2 then | |
661 | - rankVal = bi["top"] | |
662 | - end | |
663 | - role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | |
664 | 664 | end |
665 | 665 | if changeFlag then |
666 | 666 | role.activity:updateActData("ChallengeLevel", actData) |
... | ... | @@ -1466,4 +1466,30 @@ function _M.returnerTaskRpc(agent, data) |
1466 | 1466 | return true |
1467 | 1467 | end |
1468 | 1468 | |
1469 | +function _M.buyBattleTicketRpc(agent, data) | |
1470 | + local role = agent.role | |
1471 | + local msg = MsgPack.unpack(data) | |
1472 | + local actid = msg.actid | |
1473 | + local count = msg.count | |
1474 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
1475 | + role.activity:getBattleTicket(actid) | |
1476 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
1477 | + local battleInfo = actData[id] or {} | |
1478 | + --["activity_scrofa_tickets"] = { 10, 20, 30, 40, 50, 100, 150, 200, 200, 200 } | |
1479 | + local limit = #(globalCsv.activity_scrofa_tickets) | |
1480 | + local curCount = actData["buyC"] or 0 | |
1481 | + if count <= 0 or curCount + count > limit then | |
1482 | + return 2 | |
1483 | + end | |
1484 | + local cost = globalCsv.activity_scrofa_tickets[curCount + 1] | |
1485 | + if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 3 end | |
1486 | + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyActivityBattleTicket", int1 = actid, int2 = count, cint1 = curCount}}) | |
1487 | + actData["ticket"] = (actData["ticket"] or 0) + 1 | |
1488 | + actData["buyC"] = curCount + count | |
1489 | + | |
1490 | + role.activity:updateActData("ChallengeLevel", actData) | |
1491 | + SendPacket(actionCodes.Activity_buyBattleTicketRpc, "") | |
1492 | + return true | |
1493 | +end | |
1494 | + | |
1469 | 1495 | return _M | ... | ... |
src/models/Activity.lua
... | ... | @@ -797,7 +797,12 @@ activityFunc[Activity.ActivityType.ChallengeLevel] = { |
797 | 797 | end, |
798 | 798 | ["login"] = function(self, actType, actId) |
799 | 799 | self:getBattleTicket(actId) |
800 | - end | |
800 | + end, | |
801 | + ["crossDay"] = function(self, actType, notify) | |
802 | + local actData = self:getActData(actType) | |
803 | + actData["buyC"] = 0 | |
804 | + self:updateActData(actType, actData, not notify) | |
805 | + end, | |
801 | 806 | } |
802 | 807 | |
803 | 808 | function Activity:onLoginActivity(actId) | ... | ... |
src/models/RoleLog.lua