Commit 686d4fd674e8d9ecc4a51d13f19ea194f0d7e4e5
1 parent
6a2b449c
兑换活动支持兑换多个, 新增卡池
Showing
5 changed files
with
64 additions
and
13 deletions
Show diff stats
src/actions/ActivityAction.lua
... | ... | @@ -268,7 +268,8 @@ 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:isOpenById(actid) then return 1 end | |
271 | + local count = msg.count | |
272 | + if not role.activity:isOpenById(actid, "Exchange") then return 1 end | |
272 | 273 | |
273 | 274 | local exchangeCfg = csvdb["activity_exchangeCsv"][actid] |
274 | 275 | if not exchangeCfg then return 2 end |
... | ... | @@ -278,13 +279,16 @@ function _M.exchangeRpc(agent, data) |
278 | 279 | local curCount = exchangeData[id] or 0 |
279 | 280 | local actCfg = exchangeCfg[id] |
280 | 281 | local limitArr = actCfg.limit:toArray(true, "=") |
281 | - if curCount >= limitArr[2] then return 4 end | |
282 | + if curCount + count > limitArr[2] then return 4 end | |
282 | 283 | |
283 | 284 | local costs = actCfg.goods:toNumMap() |
285 | + for k,v in pairs(costs) do | |
286 | + costs[k] = v * count | |
287 | + end | |
284 | 288 | if not role:checkItemEnough(costs) then return 5 end |
285 | 289 | role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) |
286 | 290 | |
287 | - curCount = curCount + 1 | |
291 | + curCount = curCount + count | |
288 | 292 | exchangeData[id] = curCount |
289 | 293 | curData[actid] = exchangeData |
290 | 294 | role.activity:updateActData("Exchange", curData) |
... | ... | @@ -304,7 +308,7 @@ function _M.gachakonRpc(agent, data) |
304 | 308 | |
305 | 309 | if count > 10 then return end |
306 | 310 | |
307 | - if not role.activity:isOpenById(actid) then return 1 end | |
311 | + if not role.activity:isOpenById(actid, "Gachakon") then return 1 end | |
308 | 312 | |
309 | 313 | local actCtrlData = csvdb["activity_ctrlCsv"][actid] |
310 | 314 | if not actCtrlData then return 2 end |
... | ... | @@ -365,7 +369,7 @@ function _M.hangDropRpc(agent, data) |
365 | 369 | local role = agent.role |
366 | 370 | local msg = MsgPack.unpack(data) |
367 | 371 | local actid = msg.actid |
368 | - if not role.activity:isOpenById(actid) then return 1 end | |
372 | + if not role.activity:isOpenById(actid, "HangDrop") then return 1 end | |
369 | 373 | |
370 | 374 | local actCfg = csvdb["activity_putCsv"][actid] |
371 | 375 | if not actCfg then return 2 end |
... | ... | @@ -382,7 +386,7 @@ function _M.hangDropRpc(agent, data) |
382 | 386 | if type == 1 then |
383 | 387 | local actId = arr[2] |
384 | 388 | local carbonId = arr[3] |
385 | - if not role.activity:isOpenById(actid) then return 3 end | |
389 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 3 end | |
386 | 390 | local clInfo = role.activity:getActData("ChallengeLevel") or {} |
387 | 391 | if not clInfo[carbonId] then |
388 | 392 | break |
... | ... | @@ -439,7 +443,7 @@ function _M.startBattleRpc(agent, data) |
439 | 443 | local actid = msg.actid |
440 | 444 | local id = msg.id |
441 | 445 | local count = msg.count |
442 | - if not role.activity:isOpenById(actid) then return 1 end | |
446 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
443 | 447 | |
444 | 448 | local actCfg = csvdb["activity_battleCsv"][actid] |
445 | 449 | if not actCfg then return 2 end |
... | ... | @@ -542,7 +546,7 @@ function _M.endBattleRpc(agent, data) |
542 | 546 | local isWin = msg.isWin |
543 | 547 | local heros = msg.heros |
544 | 548 | local support = msg.support |
545 | - if not role.activity:isOpenById(actid) then return 1 end | |
549 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
546 | 550 | |
547 | 551 | if not role.__actBattleCache then return 2 end |
548 | 552 | |
... | ... | @@ -686,7 +690,7 @@ function _M.battleRankRpc(agent, data) |
686 | 690 | local role = agent.role |
687 | 691 | local msg = MsgPack.unpack(data) |
688 | 692 | local actid = msg.actid |
689 | - if not role.activity:isOpenById(actid) then return 1 end | |
693 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
690 | 694 | |
691 | 695 | local rankInfo = role:getRankInfoCommon(RANK_TYPE.ActBattleBoss) |
692 | 696 | |
... | ... | @@ -701,7 +705,7 @@ function _M.battleMilestoneRpc(agent, data) |
701 | 705 | local id = msg.id |
702 | 706 | local index = msg.index |
703 | 707 | |
704 | - if not role.activity:isOpenById(actid) then return 1 end | |
708 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
705 | 709 | |
706 | 710 | local actCfg = csvdb["activity_mileageCsv"][actid] |
707 | 711 | if not actCfg then return 3 end | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -529,6 +529,16 @@ function _M.guide(role, pms) |
529 | 529 | return "成功" |
530 | 530 | end |
531 | 531 | |
532 | +table.insert(helpDes, {"挑战关卡次数", "actbattle"}) | |
533 | +function _M.actbattle(role, pms) | |
534 | + if not role.activity:isOpen("ChallengeLevel") then return end | |
535 | + local actData = role.activity:getActData("ChallengeLevel") | |
536 | + actData["ticket"] = 100 | |
537 | + role.activity:updateActData("ChallengeLevel", actData) | |
538 | + | |
539 | + return "成功" | |
540 | +end | |
541 | + | |
532 | 542 | function _M.helpRpc(agent, data) |
533 | 543 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) |
534 | 544 | return true | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -714,6 +714,7 @@ end |
714 | 714 | function _M.drawHeroRpc(agent, data) |
715 | 715 | local role = agent.role |
716 | 716 | local msg = MsgPack.unpack(data) |
717 | + local actid = msg.actid | |
717 | 718 | |
718 | 719 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end |
719 | 720 | local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 |
... | ... | @@ -726,11 +727,32 @@ function _M.drawHeroRpc(agent, data) |
726 | 727 | end |
727 | 728 | end |
728 | 729 | |
730 | + -- 活动卡池 | |
731 | + if actid then | |
732 | + if not role.activity:isOpenById(actid, "ActHeroPool") then return end | |
733 | + local cfg = csvdb["activity_ctrlCsv"][actid] | |
734 | + if not cfg then return end | |
735 | + | |
736 | + btype = cfg.condition | |
737 | + end | |
738 | + | |
729 | 739 | if btype == 1 then |
730 | 740 | -- 判断定向卡池活动开启 |
731 | 741 | if not role.activity:isOpen("RaceDraw") then |
732 | 742 | return |
733 | 743 | end |
744 | + elseif btype == 2 then | |
745 | + if role:getProperty("newerGuide") ~= "8=1" then | |
746 | + -- 判断普通卡池 | |
747 | + if role.activity:isOpen("WishHeroPool") then | |
748 | + return | |
749 | + end | |
750 | + end | |
751 | + elseif btype == 5 then | |
752 | + -- 判断心愿单卡池 | |
753 | + if not role.activity:isOpen("WishHeroPool") then | |
754 | + return | |
755 | + end | |
734 | 756 | end |
735 | 757 | |
736 | 758 | local buildTypeData = csvdb["build_typeCsv"][btype] |
... | ... | @@ -952,7 +974,7 @@ function _M.drawHeroRpc(agent, data) |
952 | 974 | }) |
953 | 975 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
954 | 976 | |
955 | - if btype == 1 or btype == 2 then | |
977 | + if (buildTypeData["can_feedback"] or 0) == 1 then | |
956 | 978 | -- 达到一定次数,给响应奖励 |
957 | 979 | local oldVal = role:getProperty("repayHero") or 0 |
958 | 980 | local newVal = oldVal + drawCount[drawType] | ... | ... |
src/models/Activity.lua
... | ... | @@ -24,6 +24,9 @@ Activity.ActivityType = { |
24 | 24 | Exchange = 18, -- 兑换活动 |
25 | 25 | HangDrop = 19, -- 挂机掉落活动 |
26 | 26 | Gachakon = 20, -- 扭蛋活动 |
27 | + | |
28 | + WishHeroPool = 23, -- 心愿卡池 | |
29 | + ActHeroPool = 24, -- 活动卡池 | |
27 | 30 | } |
28 | 31 | |
29 | 32 | |
... | ... | @@ -41,6 +44,13 @@ function Activity:ctor(properties) |
41 | 44 | self._isOpen = {} |
42 | 45 | end |
43 | 46 | |
47 | +function Activity:getType(actType) | |
48 | + if type(actType) == "string" then | |
49 | + actType = Activity.ActivityType[actType] | |
50 | + end | |
51 | + return actType or 0 | |
52 | +end | |
53 | + | |
44 | 54 | |
45 | 55 | Activity.schema = { |
46 | 56 | actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} |
... | ... | @@ -153,7 +163,12 @@ function Activity:isOpen(activityType) |
153 | 163 | return false |
154 | 164 | end |
155 | 165 | |
156 | -function Activity:isOpenById(id) | |
166 | +function Activity:isOpenById(id, activityType) | |
167 | + activityType = checkActivityType(activityType) | |
168 | + local cfg = csvdb["activity_ctrlCsv"][id] | |
169 | + if not cfg then return false end | |
170 | + if cfg.showType ~= activityType then return false end | |
171 | + | |
157 | 172 | return self._isOpen[id] |
158 | 173 | end |
159 | 174 | ... | ... |