From f76d63e1368189161505410fcd9679124dc9b99b Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Tue, 5 Jan 2021 20:36:08 +0800 Subject: [PATCH] 联动任务活动 --- src/actions/ActivityAction.lua | 3 +++ src/actions/AdvAction.lua | 3 +++ src/actions/GmAction.lua | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/actions/HangAction.lua | 2 ++ src/actions/RadioAction.lua | 3 ++- src/adv/Adv.lua | 1 + src/csvdata | 2 +- src/models/Activity.lua | 5 +++-- src/models/RoleTask.lua | 22 ++++++++++++++++++++++ 9 files changed, 304 insertions(+), 5 deletions(-) diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 08c7ca6..7f9886e 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -259,7 +259,10 @@ function _M.actCalendaTaskRpc(agent, data) activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} }) + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) + return true end diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 794da80..115cff2 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -344,6 +344,7 @@ function _M.endHangRpc(agent, data) adv_idle_time = adv_idle_time * 60 local reward, isFull, change, heroFaithMap + local heroCnt = 0 if skynet.timex() >= info.time then -- 最新需求加成取消 --[[ @@ -378,6 +379,7 @@ function _M.endHangRpc(agent, data) for _, heroId in pairs(info.format.heros) do local curFaith = addHeroFaith(role, heroId, exp) heroFaithMap[heroId] = curFaith + heroCnt = heroCnt + 1 end local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 @@ -406,6 +408,7 @@ function _M.endHangRpc(agent, data) role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) role:checkTaskEnter("AdvHang", {}) + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt}) SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap})) return true diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index d94c1df..00f3915 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -546,11 +546,23 @@ end function _M.test(role, pms) local id = tonum(pms.pm1, 0) + local actid = nil + if id > 100 then + actid = tonum(pms.pm2, 0) + end --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) --role:sendMail(13, nil, "1=2", {111}) - dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) + local file = io.open("draw_hero_"..id..".csv", "a") + for i=1, 10000 do + local heroIds = _M.drawHero(role, id, actid) + for k, v in ipairs(heroIds) do + print((i - 1)* 10 + k, v) + file:write(v.."\n") + end + end + io.close(file) return "成功" end @@ -575,5 +587,259 @@ function _M.cz(role, pms) return "指令成功" end +function _M.drawHero(role, t, act) + local btype = t -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 + local subType = 1-- 定向卡池需要传 子类型 + local drawType = 2 -- 1 单抽 2 十连 + if btype ~= 1 then + subType = 1 + end + + local actid = act + -- 另开活动卡池 + if actid then + --if not role.activity:isOpenById(actid, "ActHeroPool") then return end + local cfg = csvdb["activity_ctrlCsv"][actid] + if not cfg then return end + + btype = cfg.condition + end + + local buildTypeData = csvdb["build_typeCsv"][btype] + if not buildTypeData then return 2 end + + local drawCount = {1, 10} -- 抽取次数 + if not drawCount[drawType] then return 3 end + + local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype] + local floorHeroCount = role:getProperty("floorHero")[btype] or 0 + + -- 抽取的池子 + local poolMap = buildTypeData["pool"]:toNumMap() + local poolId = poolMap[subType] + if not poolId then return 5 end + + --TODO 活动覆盖 + local actPoolId = role.activity:getActivityPool(btype, subType) + if actPoolId ~= 0 then + poolId = actPoolId + end + + local unitPool = csvdb["build_unitCsv"][poolId] + if not unitPool then return 7 end + + -- 开始抽 + local resultPool = {} + local function fillDrawPool(isFloorBack) + local condition = {"rare"} + local values = {} + + + for idx, field in ipairs(condition) do + if not values[idx] then + local lpool = {} + local curIdx = 1 + while unitPool[field .. "_" .. curIdx] do + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]} + curIdx = curIdx + 1 + end + + if next(lpool) then + values[idx] = math.randWeight(lpool, 1) + end + end + end + + local weight = 0 + local up_pool = nil + local rand_v = math.randomInt(1, 100) + if values[1] == HeroQuality.SR then + weight = unitPool["up_sr_weight"] + up_pool = unitPool["up_sr_id"] + elseif values[1] == HeroQuality.SSR then + weight = unitPool["up_ssr_weight"] + up_pool = unitPool["up_ssr_id"] + end + --print(poolId, rand_v, weight, up_pool, values[1]) + if rand_v < weight and up_pool then + up_pool = up_pool:toArray(true, "=") + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 + up_pool = role:getProperty("wishPool") + up_pool[1] = 606 + up_pool[2] = 607 + up_pool[3] = 608 + end + for k, v in ipairs(up_pool) do + resultPool[v] = {1} + end + else + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do + local pool_str = "pool_" .. poolId + if oneData[pool_str] and oneData[pool_str] ~= "" then + local itemData = csvdb["itemCsv"][itemId] + while itemData do + if itemData.type ~= ItemType.Hero then break end + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] + if not heroData then break end + local ok = true + -- 保底是全随机,不用比较类型 + if not isFloorBack then + for idx, field in ipairs(condition) do + if heroData[field] ~= values[idx] then ok = false break end + end + end + if not ok then break end + if oneData[pool_str] > 0 then + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 + end + break + end + end + end + end + end + + local guideHero = nil + if role:getProperty("newerGuide") == "8=1" then + guideHero = globalCsv.newdraw_hero_item_id or 503 + end + + local ssrCount = 0 + local reward = {} + local logReward = {} + local result = {} + for i = 1, drawCount[drawType] do + floorHeroCount = floorHeroCount + 1 + local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts + resultPool = {} + fillDrawPool(isFloorBack) + if not next(resultPool) then + skynet.error("random pool error, poolId:" .. poolId, isFloorBack) + return 8 + end + + local itemId = math.randWeight(resultPool, 1) + if guideHero then + itemId = guideHero + end + + local itemData = csvdb["itemCsv"][itemId] + if itemData.quality == HeroQuality.SSR then + ssrCount = ssrCount + 1 + if not guideHero then + -- 广播获得ssr英雄 + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} + --mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) + end + end + + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 + if itemData.quality == HeroQuality.SSR then + floorHeroCount = 0 + end + else + if itemData.quality >= HeroQuality.SR then + floorHeroCount = 0 + end + end + + if role:isHaveHero(itemData.id - ItemStartId.Hero) then + local fragId = itemData.id - ItemStartId.Hero + local heroData = csvdb["unitCsv"][fragId] + local count = globalCsv.draw_unit_tofragment[heroData.rare] + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) + logReward[fragId] = (logReward[fragId] or 0) + count + table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) + else + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) + logReward[itemId] = (logReward[itemId] or 0) + 1 + table.insert(reward, {id = itemId, count = 1}) + end + end + + if draw_floor_back_counts then + local floorHero = role:getProperty("floorHero") + floorHero[btype] = floorHeroCount + role:setProperty("floorHero", floorHero) + end + + if btype == 4 then + local newCount = role:getProperty("newerDraw") + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) + end + + --SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 + for k, v in pairs(reward) do + local hero = v + if hero["from"] then + result[#result+1] = hero["from"] + else + result[#result+1] = hero["id"] + end + end + + local feedbackId = buildTypeData["can_feedback"] or 0 + if feedbackId ~= 0 then + -- 达到一定次数,给响应奖励 + local oldVal = role:getProperty("repayHero") or 0 + if actid then + local actData = role.activity:getActData("ActHeroPool") + oldVal = actData[btype] or 0 + end + local newVal = oldVal + drawCount[drawType] + local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal) + -- 空字符穿代表直接给英雄 走以前repayHeroRpc + if drawCardReward == "" then + local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 + repayHeroMaxCount = repayHeroMaxCount + 1 + + role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount}) + local even = repayHeroMaxCount % 2 + local id = 0 + if even == 1 then + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) + else + local giftHeroSet = {} + for gid, cfg in pairs(csvdb["build_giftCsv"]) do + if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then + giftHeroSet[gid] = {1} + end + end + if next(giftHeroSet) then + id = math.randWeight(giftHeroSet, 1) + end + end + if id == 0 then + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) + end + + local r,change = {} + local itemData = csvdb["itemCsv"][id] + --if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then + -- local fragId = itemData.id - ItemStartId.Hero + -- local heroData = csvdb["unitCsv"][fragId] + -- local count = globalCsv.draw_unit_tofragment[heroData.rare] + -- r, change = role:award({[fragId] = count}, {log = {desc = "drawHeroExtraReward"}}) + -- --r = {id = fragId, count = count, from = id, fcount = 1} + --else + r, change = role:award({[id] = 1}, {log = {desc = "drawHeroExtraReward"}}) + --end + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) + elseif drawCardReward and drawCardReward ~= "" then + local r,change = {} + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) + end + if not actid then + role:updateProperty({field = "repayHero", value = val}) + else + local actData = role.activity:getActData("ActHeroPool") + actData[btype] = val + role.activity:updateActData("ActHeroPool", actData) + end + end + return result +end + return _M \ No newline at end of file diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index c712399..f1938fe 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -581,6 +581,8 @@ function _M.startBonusBattleRpc(agent, data) local reward, change = bonusWinReward(role, bonusData, 3, count) SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) + + role:checkTaskEnter("BonusQuick", {count = count}) else local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) if not next(bTeam) then return 5 end diff --git a/src/actions/RadioAction.lua b/src/actions/RadioAction.lua index df9ceee..3f22916 100644 --- a/src/actions/RadioAction.lua +++ b/src/actions/RadioAction.lua @@ -101,7 +101,7 @@ function _M.startQuestRpc(agent, data) radioTask[id] = taskData role:updateProperty({field="radioTask", value=radioTask, notNotify=true}) - SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData})) + SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData})) return true end @@ -160,6 +160,7 @@ function _M.finishQuestRpc(agent, data) msg["heroFaith"] = heroFaithMap SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) + role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros}) local herolist = {} for _, heroId in ipairs(task.heros) do diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 91009e4..2ea518a 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -2187,6 +2187,7 @@ function Adv:enemyDead(enemy, escape) self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1) self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) + self.owner:checkTaskEnter("AdvKillBoss") elseif monsterData.type == 3 then self:checkTask(Adv.TaskType.KillElite, 1, enemyId) end diff --git a/src/csvdata b/src/csvdata index fcf0c6c..48214b3 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit fcf0c6c46ae54862a6b68b77f87ce0cf8a729da5 +Subproject commit 48214b3ec01446368f92b6eb3123fe39c862c0fa diff --git a/src/models/Activity.lua b/src/models/Activity.lua index a5f54fe..6079404 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -457,8 +457,9 @@ activityFunc[Activity.ActivityType.CalendaTask] = { role:checkTaskEnter("RuneQualityCollect", {}) end, - -- ["close"] = function(self, actType, notify) - -- end, + ["close"] = function(self, actType, notify) + self.owner:updateProperty({field="CalTask", value={}}) + end, } -- 兑换 diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 31c06d3..5bd71cb 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -34,6 +34,7 @@ local TaskType = { HangBattle = 304, -- 挂机战斗 - id HangGetGold = 305, -- 挂机获得齿轮 - count BonusPass = 306, -- 奖励副本通关 - id count + BonusQuick = 307, -- 奖励关卡扫荡 -- id count -- 冒险相关 AdvPass = 401, -- 冒险通过关 - id level score @@ -50,6 +51,8 @@ local TaskType = { AdvHang = 412, -- 代理拾荒次数 AdvMineKill = 413, -- 宝藏怪击杀 AdvMineLayer = 414, -- 宝藏洞激活 + AdvKillBoss = 415, -- 拾荒击杀boss + AdvHangHeroCnt = 416, -- 拾荒人数 --爬塔相关 TowerPass = 501, -- 爬塔通关 - level @@ -92,6 +95,8 @@ local TaskType = { Pay = 902, -- 充值 ShopAll = 903, -- 在任意商店购买 DailyTask = 904, -- 完成每日活跃任务 + RadioTaskStart = 905, -- 电台任务开始 + FinishSpeTask = 906, -- 指定任务完成 --功能未实现 todo AdvShop = 1002, -- 冒险商城 @@ -270,6 +275,14 @@ local CalendaTaskListener = { [TaskType.HangGet]= {{18, 3, f("reward")}}, [TaskType.RuneQualityCollect]= {{19, 3}}, [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, + [TaskType.RadioTaskStart] = {{21, 1}, {22, 3, f("heroCnt")}}, + [TaskType.BonusQuick] = {{23, 1, f("count")}}, + [TaskType.AdvHangHeroCnt] = {{24, 3, f("HeroCnt")}}, + [TaskType.AdvKillBoss] = {{25, 1}}, + [TaskType.AdvMineKill] = {{26, 1}}, + [TaskType.PvpBattle] = {{27, 1}}, + [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}}, + } } @@ -702,6 +715,15 @@ function RoleTask.bind(Role) calTask[id] = 1 end end + elseif cfg.type == 22 then -- 电台任务出勤人数 + calTask[id] = (calTask[id] or 0) + (param1 or 0) + elseif cfg.type == 24 then -- 代理拾荒出勤人数 + calTask[id] = (calTask[id] or 0) + (param1 or 0) + elseif cfg.type == 28 then -- 完成指定任务 + print(actId,param2, cfg.condition2, param1) + if actId == param2 and cfg.condition2 == param1 then + calTask[id] = (calTask[id] or 0) + 1 + end end end end -- libgit2 0.21.2