Commit f76d63e1368189161505410fcd9679124dc9b99b
1 parent
fc6a75e0
联动任务活动
Showing
9 changed files
with
304 additions
and
5 deletions
Show diff stats
src/actions/ActivityAction.lua
... | ... | @@ -259,7 +259,10 @@ function _M.actCalendaTaskRpc(agent, data) |
259 | 259 | activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} |
260 | 260 | }) |
261 | 261 | |
262 | + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) | |
263 | + | |
262 | 264 | SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) |
265 | + | |
263 | 266 | return true |
264 | 267 | end |
265 | 268 | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -344,6 +344,7 @@ function _M.endHangRpc(agent, data) |
344 | 344 | adv_idle_time = adv_idle_time * 60 |
345 | 345 | |
346 | 346 | local reward, isFull, change, heroFaithMap |
347 | + local heroCnt = 0 | |
347 | 348 | if skynet.timex() >= info.time then |
348 | 349 | -- 最新需求加成取消 |
349 | 350 | --[[ |
... | ... | @@ -378,6 +379,7 @@ function _M.endHangRpc(agent, data) |
378 | 379 | for _, heroId in pairs(info.format.heros) do |
379 | 380 | local curFaith = addHeroFaith(role, heroId, exp) |
380 | 381 | heroFaithMap[heroId] = curFaith |
382 | + heroCnt = heroCnt + 1 | |
381 | 383 | end |
382 | 384 | |
383 | 385 | local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 |
... | ... | @@ -406,6 +408,7 @@ function _M.endHangRpc(agent, data) |
406 | 408 | role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) |
407 | 409 | |
408 | 410 | role:checkTaskEnter("AdvHang", {}) |
411 | + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt}) | |
409 | 412 | |
410 | 413 | SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap})) |
411 | 414 | return true | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -546,11 +546,23 @@ end |
546 | 546 | |
547 | 547 | function _M.test(role, pms) |
548 | 548 | local id = tonum(pms.pm1, 0) |
549 | + local actid = nil | |
550 | + if id > 100 then | |
551 | + actid = tonum(pms.pm2, 0) | |
552 | + end | |
549 | 553 | --local hero = require ("actions.HeroAction") |
550 | 554 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
551 | 555 | |
552 | 556 | --role:sendMail(13, nil, "1=2", {111}) |
553 | - dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) | |
557 | + local file = io.open("draw_hero_"..id..".csv", "a") | |
558 | + for i=1, 10000 do | |
559 | + local heroIds = _M.drawHero(role, id, actid) | |
560 | + for k, v in ipairs(heroIds) do | |
561 | + print((i - 1)* 10 + k, v) | |
562 | + file:write(v.."\n") | |
563 | + end | |
564 | + end | |
565 | + io.close(file) | |
554 | 566 | return "成功" |
555 | 567 | end |
556 | 568 | |
... | ... | @@ -575,5 +587,259 @@ function _M.cz(role, pms) |
575 | 587 | return "指令成功" |
576 | 588 | end |
577 | 589 | |
590 | +function _M.drawHero(role, t, act) | |
591 | + local btype = t -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 | |
592 | + local subType = 1-- 定向卡池需要传 子类型 | |
593 | + local drawType = 2 -- 1 单抽 2 十连 | |
594 | + if btype ~= 1 then | |
595 | + subType = 1 | |
596 | + end | |
597 | + | |
598 | + local actid = act | |
599 | + -- 另开活动卡池 | |
600 | + if actid then | |
601 | + --if not role.activity:isOpenById(actid, "ActHeroPool") then return end | |
602 | + local cfg = csvdb["activity_ctrlCsv"][actid] | |
603 | + if not cfg then return end | |
604 | + | |
605 | + btype = cfg.condition | |
606 | + end | |
607 | + | |
608 | + local buildTypeData = csvdb["build_typeCsv"][btype] | |
609 | + if not buildTypeData then return 2 end | |
610 | + | |
611 | + local drawCount = {1, 10} -- 抽取次数 | |
612 | + if not drawCount[drawType] then return 3 end | |
613 | + | |
614 | + local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype] | |
615 | + local floorHeroCount = role:getProperty("floorHero")[btype] or 0 | |
616 | + | |
617 | + -- 抽取的池子 | |
618 | + local poolMap = buildTypeData["pool"]:toNumMap() | |
619 | + local poolId = poolMap[subType] | |
620 | + if not poolId then return 5 end | |
621 | + | |
622 | + --TODO 活动覆盖 | |
623 | + local actPoolId = role.activity:getActivityPool(btype, subType) | |
624 | + if actPoolId ~= 0 then | |
625 | + poolId = actPoolId | |
626 | + end | |
627 | + | |
628 | + local unitPool = csvdb["build_unitCsv"][poolId] | |
629 | + if not unitPool then return 7 end | |
630 | + | |
631 | + -- 开始抽 | |
632 | + local resultPool = {} | |
633 | + local function fillDrawPool(isFloorBack) | |
634 | + local condition = {"rare"} | |
635 | + local values = {} | |
636 | + | |
637 | + | |
638 | + for idx, field in ipairs(condition) do | |
639 | + if not values[idx] then | |
640 | + local lpool = {} | |
641 | + local curIdx = 1 | |
642 | + while unitPool[field .. "_" .. curIdx] do | |
643 | + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]} | |
644 | + curIdx = curIdx + 1 | |
645 | + end | |
646 | + | |
647 | + if next(lpool) then | |
648 | + values[idx] = math.randWeight(lpool, 1) | |
649 | + end | |
650 | + end | |
651 | + end | |
652 | + | |
653 | + local weight = 0 | |
654 | + local up_pool = nil | |
655 | + local rand_v = math.randomInt(1, 100) | |
656 | + if values[1] == HeroQuality.SR then | |
657 | + weight = unitPool["up_sr_weight"] | |
658 | + up_pool = unitPool["up_sr_id"] | |
659 | + elseif values[1] == HeroQuality.SSR then | |
660 | + weight = unitPool["up_ssr_weight"] | |
661 | + up_pool = unitPool["up_ssr_id"] | |
662 | + end | |
663 | + --print(poolId, rand_v, weight, up_pool, values[1]) | |
664 | + if rand_v < weight and up_pool then | |
665 | + up_pool = up_pool:toArray(true, "=") | |
666 | + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 | |
667 | + up_pool = role:getProperty("wishPool") | |
668 | + up_pool[1] = 606 | |
669 | + up_pool[2] = 607 | |
670 | + up_pool[3] = 608 | |
671 | + end | |
672 | + for k, v in ipairs(up_pool) do | |
673 | + resultPool[v] = {1} | |
674 | + end | |
675 | + else | |
676 | + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | |
677 | + local pool_str = "pool_" .. poolId | |
678 | + if oneData[pool_str] and oneData[pool_str] ~= "" then | |
679 | + local itemData = csvdb["itemCsv"][itemId] | |
680 | + while itemData do | |
681 | + if itemData.type ~= ItemType.Hero then break end | |
682 | + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | |
683 | + if not heroData then break end | |
684 | + local ok = true | |
685 | + -- 保底是全随机,不用比较类型 | |
686 | + if not isFloorBack then | |
687 | + for idx, field in ipairs(condition) do | |
688 | + if heroData[field] ~= values[idx] then ok = false break end | |
689 | + end | |
690 | + end | |
691 | + if not ok then break end | |
692 | + if oneData[pool_str] > 0 then | |
693 | + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | |
694 | + end | |
695 | + break | |
696 | + end | |
697 | + end | |
698 | + end | |
699 | + end | |
700 | + end | |
701 | + | |
702 | + local guideHero = nil | |
703 | + if role:getProperty("newerGuide") == "8=1" then | |
704 | + guideHero = globalCsv.newdraw_hero_item_id or 503 | |
705 | + end | |
706 | + | |
707 | + local ssrCount = 0 | |
708 | + local reward = {} | |
709 | + local logReward = {} | |
710 | + local result = {} | |
711 | + for i = 1, drawCount[drawType] do | |
712 | + floorHeroCount = floorHeroCount + 1 | |
713 | + local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts | |
714 | + resultPool = {} | |
715 | + fillDrawPool(isFloorBack) | |
716 | + if not next(resultPool) then | |
717 | + skynet.error("random pool error, poolId:" .. poolId, isFloorBack) | |
718 | + return 8 | |
719 | + end | |
720 | + | |
721 | + local itemId = math.randWeight(resultPool, 1) | |
722 | + if guideHero then | |
723 | + itemId = guideHero | |
724 | + end | |
725 | + | |
726 | + local itemData = csvdb["itemCsv"][itemId] | |
727 | + if itemData.quality == HeroQuality.SSR then | |
728 | + ssrCount = ssrCount + 1 | |
729 | + if not guideHero then | |
730 | + -- 广播获得ssr英雄 | |
731 | + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} | |
732 | + --mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) | |
733 | + end | |
734 | + end | |
735 | + | |
736 | + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 | |
737 | + if itemData.quality == HeroQuality.SSR then | |
738 | + floorHeroCount = 0 | |
739 | + end | |
740 | + else | |
741 | + if itemData.quality >= HeroQuality.SR then | |
742 | + floorHeroCount = 0 | |
743 | + end | |
744 | + end | |
745 | + | |
746 | + if role:isHaveHero(itemData.id - ItemStartId.Hero) then | |
747 | + local fragId = itemData.id - ItemStartId.Hero | |
748 | + local heroData = csvdb["unitCsv"][fragId] | |
749 | + local count = globalCsv.draw_unit_tofragment[heroData.rare] | |
750 | + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) | |
751 | + logReward[fragId] = (logReward[fragId] or 0) + count | |
752 | + table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) | |
753 | + else | |
754 | + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) | |
755 | + logReward[itemId] = (logReward[itemId] or 0) + 1 | |
756 | + table.insert(reward, {id = itemId, count = 1}) | |
757 | + end | |
758 | + end | |
759 | + | |
760 | + if draw_floor_back_counts then | |
761 | + local floorHero = role:getProperty("floorHero") | |
762 | + floorHero[btype] = floorHeroCount | |
763 | + role:setProperty("floorHero", floorHero) | |
764 | + end | |
765 | + | |
766 | + if btype == 4 then | |
767 | + local newCount = role:getProperty("newerDraw") | |
768 | + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) | |
769 | + end | |
770 | + | |
771 | + --SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 | |
772 | + for k, v in pairs(reward) do | |
773 | + local hero = v | |
774 | + if hero["from"] then | |
775 | + result[#result+1] = hero["from"] | |
776 | + else | |
777 | + result[#result+1] = hero["id"] | |
778 | + end | |
779 | + end | |
780 | + | |
781 | + local feedbackId = buildTypeData["can_feedback"] or 0 | |
782 | + if feedbackId ~= 0 then | |
783 | + -- 达到一定次数,给响应奖励 | |
784 | + local oldVal = role:getProperty("repayHero") or 0 | |
785 | + if actid then | |
786 | + local actData = role.activity:getActData("ActHeroPool") | |
787 | + oldVal = actData[btype] or 0 | |
788 | + end | |
789 | + local newVal = oldVal + drawCount[drawType] | |
790 | + local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal) | |
791 | + -- 空字符穿代表直接给英雄 走以前repayHeroRpc | |
792 | + if drawCardReward == "" then | |
793 | + local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 | |
794 | + repayHeroMaxCount = repayHeroMaxCount + 1 | |
795 | + | |
796 | + role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount}) | |
797 | + local even = repayHeroMaxCount % 2 | |
798 | + local id = 0 | |
799 | + if even == 1 then | |
800 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) | |
801 | + else | |
802 | + local giftHeroSet = {} | |
803 | + for gid, cfg in pairs(csvdb["build_giftCsv"]) do | |
804 | + if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then | |
805 | + giftHeroSet[gid] = {1} | |
806 | + end | |
807 | + end | |
808 | + if next(giftHeroSet) then | |
809 | + id = math.randWeight(giftHeroSet, 1) | |
810 | + end | |
811 | + end | |
812 | + if id == 0 then | |
813 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) | |
814 | + end | |
815 | + | |
816 | + local r,change = {} | |
817 | + local itemData = csvdb["itemCsv"][id] | |
818 | + --if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then | |
819 | + -- local fragId = itemData.id - ItemStartId.Hero | |
820 | + -- local heroData = csvdb["unitCsv"][fragId] | |
821 | + -- local count = globalCsv.draw_unit_tofragment[heroData.rare] | |
822 | + -- r, change = role:award({[fragId] = count}, {log = {desc = "drawHeroExtraReward"}}) | |
823 | + -- --r = {id = fragId, count = count, from = id, fcount = 1} | |
824 | + --else | |
825 | + r, change = role:award({[id] = 1}, {log = {desc = "drawHeroExtraReward"}}) | |
826 | + --end | |
827 | + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | |
828 | + elseif drawCardReward and drawCardReward ~= "" then | |
829 | + local r,change = {} | |
830 | + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | |
831 | + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | |
832 | + end | |
833 | + if not actid then | |
834 | + role:updateProperty({field = "repayHero", value = val}) | |
835 | + else | |
836 | + local actData = role.activity:getActData("ActHeroPool") | |
837 | + actData[btype] = val | |
838 | + role.activity:updateActData("ActHeroPool", actData) | |
839 | + end | |
840 | + end | |
841 | + return result | |
842 | +end | |
843 | + | |
578 | 844 | |
579 | 845 | return _M |
580 | 846 | \ No newline at end of file | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -581,6 +581,8 @@ function _M.startBonusBattleRpc(agent, data) |
581 | 581 | |
582 | 582 | local reward, change = bonusWinReward(role, bonusData, 3, count) |
583 | 583 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) |
584 | + | |
585 | + role:checkTaskEnter("BonusQuick", {count = count}) | |
584 | 586 | else |
585 | 587 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
586 | 588 | if not next(bTeam) then return 5 end | ... | ... |
src/actions/RadioAction.lua
... | ... | @@ -101,7 +101,7 @@ function _M.startQuestRpc(agent, data) |
101 | 101 | radioTask[id] = taskData |
102 | 102 | role:updateProperty({field="radioTask", value=radioTask, notNotify=true}) |
103 | 103 | |
104 | - SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData})) | |
104 | + SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData})) | |
105 | 105 | return true |
106 | 106 | end |
107 | 107 | |
... | ... | @@ -160,6 +160,7 @@ function _M.finishQuestRpc(agent, data) |
160 | 160 | msg["heroFaith"] = heroFaithMap |
161 | 161 | SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) |
162 | 162 | |
163 | + role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros}) | |
163 | 164 | |
164 | 165 | local herolist = {} |
165 | 166 | for _, heroId in ipairs(task.heros) do | ... | ... |
src/adv/Adv.lua
... | ... | @@ -2187,6 +2187,7 @@ function Adv:enemyDead(enemy, escape) |
2187 | 2187 | self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1) |
2188 | 2188 | self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) |
2189 | 2189 | self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) |
2190 | + self.owner:checkTaskEnter("AdvKillBoss") | |
2190 | 2191 | elseif monsterData.type == 3 then |
2191 | 2192 | self:checkTask(Adv.TaskType.KillElite, 1, enemyId) |
2192 | 2193 | end | ... | ... |
src/models/Activity.lua
... | ... | @@ -457,8 +457,9 @@ activityFunc[Activity.ActivityType.CalendaTask] = { |
457 | 457 | role:checkTaskEnter("RuneQualityCollect", {}) |
458 | 458 | |
459 | 459 | end, |
460 | - -- ["close"] = function(self, actType, notify) | |
461 | - -- end, | |
460 | + ["close"] = function(self, actType, notify) | |
461 | + self.owner:updateProperty({field="CalTask", value={}}) | |
462 | + end, | |
462 | 463 | } |
463 | 464 | |
464 | 465 | -- 兑换 | ... | ... |
src/models/RoleTask.lua
... | ... | @@ -34,6 +34,7 @@ local TaskType = { |
34 | 34 | HangBattle = 304, -- 挂机战斗 - id |
35 | 35 | HangGetGold = 305, -- 挂机获得齿轮 - count |
36 | 36 | BonusPass = 306, -- 奖励副本通关 - id count |
37 | + BonusQuick = 307, -- 奖励关卡扫荡 -- id count | |
37 | 38 | |
38 | 39 | -- 冒险相关 |
39 | 40 | AdvPass = 401, -- 冒险通过关 - id level score |
... | ... | @@ -50,6 +51,8 @@ local TaskType = { |
50 | 51 | AdvHang = 412, -- 代理拾荒次数 |
51 | 52 | AdvMineKill = 413, -- 宝藏怪击杀 |
52 | 53 | AdvMineLayer = 414, -- 宝藏洞激活 |
54 | + AdvKillBoss = 415, -- 拾荒击杀boss | |
55 | + AdvHangHeroCnt = 416, -- 拾荒人数 | |
53 | 56 | |
54 | 57 | --爬塔相关 |
55 | 58 | TowerPass = 501, -- 爬塔通关 - level |
... | ... | @@ -92,6 +95,8 @@ local TaskType = { |
92 | 95 | Pay = 902, -- 充值 |
93 | 96 | ShopAll = 903, -- 在任意商店购买 |
94 | 97 | DailyTask = 904, -- 完成每日活跃任务 |
98 | + RadioTaskStart = 905, -- 电台任务开始 | |
99 | + FinishSpeTask = 906, -- 指定任务完成 | |
95 | 100 | |
96 | 101 | --功能未实现 todo |
97 | 102 | AdvShop = 1002, -- 冒险商城 |
... | ... | @@ -270,6 +275,14 @@ local CalendaTaskListener = { |
270 | 275 | [TaskType.HangGet]= {{18, 3, f("reward")}}, |
271 | 276 | [TaskType.RuneQualityCollect]= {{19, 3}}, |
272 | 277 | [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, |
278 | + [TaskType.RadioTaskStart] = {{21, 1}, {22, 3, f("heroCnt")}}, | |
279 | + [TaskType.BonusQuick] = {{23, 1, f("count")}}, | |
280 | + [TaskType.AdvHangHeroCnt] = {{24, 3, f("HeroCnt")}}, | |
281 | + [TaskType.AdvKillBoss] = {{25, 1}}, | |
282 | + [TaskType.AdvMineKill] = {{26, 1}}, | |
283 | + [TaskType.PvpBattle] = {{27, 1}}, | |
284 | + [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}}, | |
285 | + | |
273 | 286 | } |
274 | 287 | } |
275 | 288 | |
... | ... | @@ -702,6 +715,15 @@ function RoleTask.bind(Role) |
702 | 715 | calTask[id] = 1 |
703 | 716 | end |
704 | 717 | end |
718 | + elseif cfg.type == 22 then -- 电台任务出勤人数 | |
719 | + calTask[id] = (calTask[id] or 0) + (param1 or 0) | |
720 | + elseif cfg.type == 24 then -- 代理拾荒出勤人数 | |
721 | + calTask[id] = (calTask[id] or 0) + (param1 or 0) | |
722 | + elseif cfg.type == 28 then -- 完成指定任务 | |
723 | + print(actId,param2, cfg.condition2, param1) | |
724 | + if actId == param2 and cfg.condition2 == param1 then | |
725 | + calTask[id] = (calTask[id] or 0) + 1 | |
726 | + end | |
705 | 727 | end |
706 | 728 | end |
707 | 729 | end | ... | ... |