From 7b570ef2f680be5560bdb3bee5199da027ed95d3 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Sat, 6 Feb 2021 20:54:35 +0800 Subject: [PATCH] 新春活动任务 --- src/GlobalVar.lua | 1 + src/actions/ActivityAction.lua | 4 +++- src/actions/AdvAction.lua | 2 +- src/actions/HeroAction.lua | 6 ++++++ src/adv/Adv.lua | 4 ++++ src/csvdata | 2 +- src/models/Daily.lua | 1 + src/models/RoleTask.lua | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------- src/preload.lua | 2 +- 9 files changed, 84 insertions(+), 126 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 86604bd..e63fcd6 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -355,6 +355,7 @@ TriggerEventType = { AddNewHero = 5, SSRCount = 6, AfterTs = 7, -- 某时间以后 + DrawHeroCnt = 8, -- 每日抽卡次数 } DrawCardType = { diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 71f8c0e..28b795f 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -723,7 +723,9 @@ function _M.endBattleRpc(agent, data) if check[cond[1]] and check[cond[1]](table.unpack(cond)) then curStar = curStar + (1 << (i - 1)) end - end + end + + role:checkTaskEnter("ActBattlePass", {chapterId = id}) else curStar = 0 if battleCfg.rank ~= 0 then diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index cf65bd1..9a05601 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -334,7 +334,7 @@ function _M.startHangRpc(agent, data) role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) role:changeAdvCount(adv_idle_energy) - role:checkTaskEnter("AdvStart", {id = chapterId}) + role:checkTaskEnter("AdvStart", {id = chapterId, actid = actid}) role:mylog("adv_action", {desc = "startHang", int1 = chapterId}) SendPacket(actionCodes.Adv_startHangRpc, '') diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 9e94ceb..8e015e4 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -976,6 +976,12 @@ function _M.drawHeroRpc(agent, data) role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) end + -- 限时礼包 + local dailyDrawCnt = role.dailyData:getProperty("drawHeroCnt") or 0 + dailyDrawCnt = dailyDrawCnt + drawCount[drawType] + role.dailyData:setProperty("drawHeroCnt", dailyDrawCnt) + role:checkTaskEnter("DrawHeroLimitPack", {count = dailyDrawCnt}) + role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) if btype ~= 3 then role:checkTaskEnter("DrawHeroNotFriend", {pool = btype, count = drawCount[drawType]}) diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 7d849bd..22abb9b 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -1133,6 +1133,7 @@ function Adv:useItem(itemId, count, target) end self:checkAchievement(self.AchievType.UseItem, count, itemId) + self.owner:checkTaskEnter("AdvUseItem", {itemId = itemId, count = count}) self:mylog({desc = "useItem", int1 = itemId, int2 = count}) self.owner:log("mission_pick_use", { @@ -1760,6 +1761,7 @@ local function clickBuild(self, room, block, params) self:checkTask(Adv.TaskType.Build, 1, oldId) self:checkAchievement(Adv.AchievType.Build, 1, oldId) self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) + self.owner:checkTaskEnter("AdvBuild", {buildId = oldId}) if clearBlock then block:clear() @@ -2338,6 +2340,8 @@ function Adv:enemyDead(enemy, escape) self:checkAchievement(Adv.AchievType.Kill, 1, enemyId) self:checkAchievement(Adv.AchievType.KillHadBuff, 1, enemy) + self.onwer:checkTaskEnter("AdvKill", {chapterId = self.chapterId}) + self:checkAchievement(Adv.AchievType.KillWithBuff, 1) self:checkAchievement(Adv.AchievType.KillNoBuff, 1) self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1) diff --git a/src/csvdata b/src/csvdata index b86293f..4210e5c 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit b86293f02222b1fbd499e57de9ead6cbd6e0d736 +Subproject commit 4210e5c61075be7be7df1737200944d9bcb6810d diff --git a/src/models/Daily.lua b/src/models/Daily.lua index 038ede4..9a1a71e 100644 --- a/src/models/Daily.lua +++ b/src/models/Daily.lua @@ -28,6 +28,7 @@ Daily.schema = { unlockPool = {"table", {}}, -- 解锁的属性卡池 curPool = {"number", 0}, -- 属性卡池当前索引 + drawCardCnt = {"number", 0}, -- 每日抽卡次数 } function Daily:updateProperty(params) diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 6c1bc73..122a153 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -16,6 +16,7 @@ local TaskType = { HeroQualityCollect = 11, -- 英雄品质收集进度 HeroStarCollect = 12, -- 英雄星级收集进度 DrawHeroNotFriend = 13, -- 非友情招募 -- count + DrawHeroLimitPack = 14, -- 抽卡限时礼貌 -- count --装备相关 AddEquip = 101, -- 获得装备 - equipId rarity @@ -56,6 +57,9 @@ local TaskType = { AdvHangHeroCnt = 416, -- 拾荒人数 AdvCostPower = 417, -- 消耗体力 AdvPassFirst = 418, -- 冒险首次通关 - id + AdvUseItem = 419, -- 使用道具 - itemId count + AdvBuild = 420, -- 建筑交互 - buildId + AdvKill = 421, -- 拾荒击败敌人 --爬塔相关 TowerPass = 501, -- 爬塔通关 - level @@ -104,6 +108,7 @@ local TaskType = { Login = 908, -- 登入 CostDiamond = 909, -- 消耗钻石 WeekTask = 910, -- 完成每周活跃任务 + ActBattlePass = 911, -- 活动关卡通关 -- chapterId --功能未实现 todo AdvShop = 1002, -- 冒险商城 @@ -257,6 +262,7 @@ local StoreListener = { [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, [TaskType.AdvPassFirst] = {{TriggerEventType.AdvPass, f("id")}}, [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, + [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroLimitPack, f("count")}}, } } @@ -268,7 +274,7 @@ local CalendaTaskListener = { [TaskType.AdvStart]= {{3, 1}}, [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 - [TaskType.AdvHang]= {{6, 1}}, ---- + [TaskType.AdvHang]= {{6, 3, f("actid")}}, ---- [TaskType.HeroQualityCollect]= {{7, 3}}, [TaskType.OverOderTask]= {{8, 1}}, [TaskType.VillageApply]= {{9, 1}}, @@ -294,10 +300,16 @@ local CalendaTaskListener = { [TaskType.DailyTask] = {{30, 2, f("cur")}}, [TaskType.WeekTask] = {{31, 2, f("cur")}}, [TaskType.MakeFood] = {{32, 1, f("count")}}, - [TaskType.AddItem] = {{33, 3, f("type"), f("count")}}, + [TaskType.AddItem] = {{33, 3, f("type"), f("count")}, {42, 3, f("id"), f("count")}}, [TaskType.CostDiamond] = {{34, 1, f("count")}}, [TaskType.DrawHeroNotFriend] = {{35, 1, f("count")}}, [TaskType.AdvCostPower] = {{36, 1, f("count")}}, + + [TaskType.AdvUseItem] = {{37, 3, f("itemId"), f("count")}}, + [TaskType.AdvBuild] = {{38, 3, f("buildId")}}, + [TaskType.AdvKill] = {{39, 1, f("chapterId")}}, + [TaskType.ActBattlePass] = {{40, 3, f("chapterId")}}, + [TaskType.AdvPass] = {{41, 3, f("id")}}, } } @@ -642,17 +654,7 @@ function RoleTask.bind(Role) self.storeData:OnTriggerLimitTimePack(triggerType, param) end - function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) - --print("check calenda task", mainType, subType, param1, param2) - local actEnum = "CalendaTask" - local keyName = "calTask" - if not self.activity then return end - local open, actId = self.activity:isOpen(actEnum) - local actData = csvdb["activity_ctrlCsv"][actId] - if not actData then return end - if not open then return end - - local change = false + function Role:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) local calTask = self:getProperty(keyName) or {} param1 = param1 or 1 @@ -744,13 +746,49 @@ function RoleTask.bind(Role) 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 + if actData.id == param2 and cfg.condition2 == param1 then calTask[id] = (calTask[id] or 0) + 1 end elseif cfg.type == 33 then -- 获得指定类型道具多少个 if cfg.condition2 == param1 then calTask[id] = (calTask[id] or 0) + (param2 or 0) end + elseif cfg.type == 42 then -- 获得指定id道具多少个 + if cfg.condition2 == param1 then + calTask[id] = (calTask[id] or 0) + (param2 or 0) + end + elseif cfg.type == 6 then -- 代理拾荒次数 + if cfg.condition2 == 0 or (cfg.condition2 == 1 and param1) then + calTask[id] = (calTask[id] or 0) + 1 + end + elseif cfg.type == 37 then -- 拾荒使用道具 + if cfg.condition2 == param1 then + calTask[id] = (calTask[id] or 0) + (param2 or 0) + end + elseif cfg.type == 38 then -- 和指定建筑交互 + local condArr = cfg.condition3:toArray(true, "=") + for i = 0, #condArr do + if condArr[i] == param1 then + calTask[id] = (calTask[id] or 0) + 1 + break + end + end + elseif cfg.type == 39 then -- 拾荒特定章节消灭敌人 + local condArr = cfg.condition3:toArray(true, "=") + for i = 0, #condArr do + if condArr[i] == param1 then + calTask[id] = (calTask[id] or 0) + 1 + break + end + end + elseif cfg.type == 40 then -- 指定活动关卡通关 + if cfg.condition2 == param1 then + calTask[id] = (calTask[id] or 0) + 1 + end + elseif cfg.type == 41 then -- 通关拾荒指定关卡 + if cfg.condition2 == param1 then + calTask[id] = (calTask[id] or 0) + 1 + end end end end @@ -758,7 +796,19 @@ function RoleTask.bind(Role) end end self:updateProperty({field = keyName, value = calTask, notNotify = notNotify}) - --dump(calTask) + end + + function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) + --print("check calenda task", mainType, subType, param1, param2) + local actEnum = "CalendaTask" + local keyName = "calTask" + if not self.activity then return end + local open, actId = self.activity:isOpen(actEnum) + local actData = csvdb["activity_ctrlCsv"][actId] + if not actData then return end + if not open then return end + + self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) end function Role:checkBattleCommandTask(notNotify, mainType, subType, param1, param2) @@ -771,113 +821,7 @@ function RoleTask.bind(Role) if not actData then return end if not open then return end - local change = false - local calTask = self:getProperty(keyName) or {} - param1 = param1 or 1 - - local cid = actData.condition - for k, taskList in pairs(csvdb["activity_taskCsv"]) do - if k == cid then - for id, cfg in pairs(taskList) do - if cfg.type == mainType then - if subType == 1 then -- 增加数值 - calTask[id] = (calTask[id] or 0) + param1 - elseif subType == 2 then -- 直接赋值 - calTask[id] = param1 - elseif subType == 3 then -- 自定义类型 - if cfg.type == 7 then -- 英雄品质收集进度 - local count = 0 - for _, hero in pairs(self.heros) do - local unitData = csvdb["unitCsv"][hero:getProperty("type")] - if unitData then - if cfg.condition2 <= unitData.rare then - count = count + 1 - end - end - end - if (calTask[id] or 0) < count then - calTask[id] = count - end - elseif cfg.type == 5 then -- 英雄等级收集进度 - local count = 0 - for _, hero in pairs(self.heros) do - if cfg.condition2 <= hero:getProperty("level") then - count = count + 1 - end - end - if (calTask[id] or 0) < count then - calTask[id] = count - end - elseif cfg.type == 16 then -- 英雄星级收集进度 - local count = 0 - for _, hero in pairs(self.heros) do - if cfg.condition2 <= hero:getProperty("wakeL") then - count = count + 1 - end - end - if (calTask[id] or 0) < count then - calTask[id] = count - end - elseif cfg.type == 18 then -- 挂机累计收获id,y个 - for rid, v in pairs(param1) do - if cfg.condition2 == rid then - calTask[id] = (calTask[id] or 0) + v - end - end - elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装 - local count = 0 - for _, hero in pairs(self.heros) do - local rcount = 0 - for _,uid in pairs(hero:getRunes()) do - if uid > 0 then - local runeData = self.runeBag[uid] - if runeData then - local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] - - if csvData and cfg.condition2 <= csvData.rarity then - rcount = rcount + 1 - end - end - end - end - if rcount == 6 then - count = count + 1 - end - end - calTask[id] = count - elseif cfg.type == 20 then -- 开启x品质时钟箱子 - if cfg.condition2 <= (param2 or 0) then - calTask[id] = (calTask[id] or 0) + param1 - end - elseif cfg.type == 15 then -- 通关关卡 - if (calTask[id] or 0) == 0 then - local hangPass = self:getProperty("hangPass") - local diff = math.floor(cfg.condition2 / 10000) - if (hangPass[diff] or 0) >= cfg.condition1 then - 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 - elseif cfg.type == 33 then -- 获得指定类型道具多少个 - if cfg.condition2 == param1 then - calTask[id] = (calTask[id] or 0) + (param2 or 0) - end - end - end - end - end - end - end - self:updateProperty({field = keyName, value = calTask, notNotify = notNotify}) - --dump(calTask) + self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) end end diff --git a/src/preload.lua b/src/preload.lua index eba52bc..ab261fb 100644 --- a/src/preload.lua +++ b/src/preload.lua @@ -2,5 +2,5 @@ local skynet = require "skynet" skynet.timex = function () - return math.floor(skynet.time()) + return math.floor(skynet.time()) + 5 * DAY_SEC end \ No newline at end of file -- libgit2 0.21.2