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,6 +259,7 @@ actionCodes = { | ||
259 | Activity_buyBattleCommandLvlRpc = 672, | 259 | Activity_buyBattleCommandLvlRpc = 672, |
260 | Activity_returnerTaskRpc = 673, | 260 | Activity_returnerTaskRpc = 673, |
261 | Activity_actNewUserTaskRpc = 674, | 261 | Activity_actNewUserTaskRpc = 674, |
262 | + Activity_buyBattleTicketRpc = 675, | ||
262 | 263 | ||
263 | Radio_startQuestRpc = 700, | 264 | Radio_startQuestRpc = 700, |
264 | Radio_finishQuestRpc = 701, | 265 | Radio_finishQuestRpc = 701, |
src/actions/ActivityAction.lua
@@ -588,24 +588,23 @@ function _M.startBattleRpc(agent, data) | @@ -588,24 +588,23 @@ function _M.startBattleRpc(agent, data) | ||
588 | role.activity:getBattleTicket(actid) | 588 | role.activity:getBattleTicket(actid) |
589 | num = battleCfg.type:toArray(true, "=")[3] | 589 | num = battleCfg.type:toArray(true, "=")[3] |
590 | if count and count > 0 then | 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 | end | 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 | end | 608 | end |
610 | if ticket < num then | 609 | if ticket < num then |
611 | return 6 | 610 | return 6 |
@@ -627,9 +626,7 @@ function _M.startBattleRpc(agent, data) | @@ -627,9 +626,7 @@ function _M.startBattleRpc(agent, data) | ||
627 | if count <= 0 then | 626 | if count <= 0 then |
628 | return | 627 | return |
629 | end | 628 | end |
630 | - if battleCfg.rank == 0 then | ||
631 | - return 7 | ||
632 | - end | 629 | + |
633 | local bi = actData[id] | 630 | local bi = actData[id] |
634 | local star = bi["star"] or 0 | 631 | local star = bi["star"] or 0 |
635 | local award = battleCfg.item_clear:toNumMap() | 632 | local award = battleCfg.item_clear:toNumMap() |
@@ -644,23 +641,26 @@ function _M.startBattleRpc(agent, data) | @@ -644,23 +641,26 @@ function _M.startBattleRpc(agent, data) | ||
644 | end | 641 | end |
645 | local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | 642 | local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) |
646 | SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) | 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 | end | 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 | end | 664 | end |
665 | if changeFlag then | 665 | if changeFlag then |
666 | role.activity:updateActData("ChallengeLevel", actData) | 666 | role.activity:updateActData("ChallengeLevel", actData) |
@@ -1466,4 +1466,30 @@ function _M.returnerTaskRpc(agent, data) | @@ -1466,4 +1466,30 @@ function _M.returnerTaskRpc(agent, data) | ||
1466 | return true | 1466 | return true |
1467 | end | 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 | return _M | 1495 | return _M |
src/models/Activity.lua
@@ -797,7 +797,12 @@ activityFunc[Activity.ActivityType.ChallengeLevel] = { | @@ -797,7 +797,12 @@ activityFunc[Activity.ActivityType.ChallengeLevel] = { | ||
797 | end, | 797 | end, |
798 | ["login"] = function(self, actType, actId) | 798 | ["login"] = function(self, actType, actId) |
799 | self:getBattleTicket(actId) | 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 | function Activity:onLoginActivity(actId) | 808 | function Activity:onLoginActivity(actId) |
src/models/RoleLog.lua
@@ -107,6 +107,7 @@ local ItemReason = { | @@ -107,6 +107,7 @@ local ItemReason = { | ||
107 | actMilecrisis = 1010, -- 物资危机 | 107 | actMilecrisis = 1010, -- 物资危机 |
108 | battleCommandTask = 1011, -- 将军令任务 | 108 | battleCommandTask = 1011, -- 将军令任务 |
109 | newUserTask = 1012, -- 新玩家任务 | 109 | newUserTask = 1012, -- 新玩家任务 |
110 | + buyActivityBattleTicket = 1013, -- 购买门票 | ||
110 | 111 | ||
111 | -- 餐厅 | 112 | -- 餐厅 |
112 | greenHourse = 1101, -- 食材获得 | 113 | greenHourse = 1101, -- 食材获得 |