diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 8733b8e..a984944 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -232,7 +232,7 @@ actionCodes = { Activity_commonSignRpc = 666, Activity_friendHelpRpc = 667, Activity_battleCommandRpc = 668, - Activity_actCalendaTmpTaskRpc = 669, + Activity_actBattleCommandTaskRpc = 669, Activity_newSignRpc = 670, Activity_advLevelRpc = 671, Activity_buyBattleCommandLvlRpc = 672, diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index c0446f1..4142c1e 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -266,15 +266,15 @@ function _M.actCalendaTaskRpc(agent, data) return true end -function _M.actCalendaTmpTaskRpc(agent, data) +function _M.actBattleCommandTaskRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local taskId = msg.id - local calTask = role:getProperty("calTask1") or {} + local calTask = role:getProperty("bcTask") or {} local record = calTask["r"] or {} local flag = record[taskId] or 0 if flag == 1 then return 1 end - local open, actId = role.activity:isOpen("CalendaTaskTmp") + local open, actId = role.activity:isOpen("BattleCommandTask") local actData = csvdb["activity_ctrlCsv"][actId] if not open then return 2 end if not actData then return 3 end @@ -287,22 +287,28 @@ function _M.actCalendaTmpTaskRpc(agent, data) if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end + local open, actId = role.activity:isOpen("BattleCommand") + local actData = csvdb["activity_ctrlCsv"][actId] + if not open then return 2 end + if not actData then return 3 end + + record[taskId] = 1 calTask["r"] = record - role:updateProperty({field = "calTask", value = calTask}) + role:updateProperty({field = "bcTask", value = calTask}) - local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}}) + local reward, change = role:award(taskCfg.reward, {log = {desc = "battleCommandTask"}}) role:log("activity", { activity_id = taskId, -- 活动ID(或活动指定任务的ID) - activity_type = role.activity.ActivityType.CalendaTaskTmp, -- 活动类型,见活动类型枚举表 + activity_type = role.activity.ActivityType.BattleCommandTask, -- 活动类型,见活动类型枚举表 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} }) role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) - SendPacket(actionCodes.Activity_actCalendaTmpTaskRpc, MsgPack.pack(role:packReward(reward, change))) + SendPacket(actionCodes.Activity_actBattleCommandTaskRpc, MsgPack.pack(role:packReward(reward, change))) return true end diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index b5f3e33..6cf02cd 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -146,6 +146,7 @@ function _M.startAdvRpc( agent, data ) if not checkFormat(role) then return 7 end + local cost = 0 if AdvCommon.isEndless(chapterId) then -- 无尽模式判断 if chapterId ~= role.advElChapter then return end -- 不是当前进行的章节 @@ -164,6 +165,7 @@ function _M.startAdvRpc( agent, data ) end role.dailyData:updateProperty({field = "advElC", delta = 1}) + cost = 1 else -- 普通模式判断 if layer >= chapterData.limitlevel then return 4 end @@ -178,7 +180,9 @@ function _M.startAdvRpc( agent, data ) if not role:advChapterIsOpen(chapterId) then return 5 end role:changeAdvCount(relayData.supply) + cost = relayData.supply end + role:checkTaskEnter("AdvCostPower", {count = cost}) local support = {} -- 支援效果 if AdvCommon.isEndless(chapterId) then diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 92c2bde..28a2b0e 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -976,6 +976,9 @@ function _M.drawHeroRpc(agent, data) end role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) + if btype ~= 3 then + role:checkTaskEnter("DrawHeroNotFriend", {pool = btype, count = drawCount[drawType]}) + end if ssrCount > 0 then role:checkTaskEnter("DrawSSR", {count = ssrCount}) end diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 6448222..00a83df 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -165,6 +165,7 @@ function _M.loginRpc( agent, data ) role.activity:checkActivityStatus(now, false, false) role:log("onLogin") end + role:checkTaskEnter("Login", {}) redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) @@ -850,6 +851,8 @@ function _M.taskRpc(agent, data) -- 日常活动完成 if taskType == 1 then role:checkTaskEnter("DailyTask", {pre = (taskStatus["a"] or 0), cur = active}) + else + role:checkTaskEnter("WeekTask", {pre = (taskStatus["a"] or 0), cur = active}) end role:changeUpdates({ diff --git a/src/csvdata b/src/csvdata index 34a04e7..3a1129d 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 34a04e7f3c37fcb088e46c2c5a05fe558cb67946 +Subproject commit 3a1129db7ff72ddc39e74f565bcf3742af5ec87b diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 598d80a..091df57 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -38,7 +38,7 @@ Activity.ActivityType = { NewSign = 36, -- 活动签到,单独的签到界面 HeroBackFree = 37, -- 无损耗归还 - CalendaTaskTmp = 38, -- 新春任务活动 + BattleCommandTask = 38, -- 战令任务活动 } local function checkActivityType(activityType) @@ -471,7 +471,7 @@ activityFunc[Activity.ActivityType.PayBack] = { -- 英雄帖 activityFunc[Activity.ActivityType.CalendaTask] = { ["init"] = function(self, actType, isCrossDay, notify) - local calTask = self.owner:getProperty("CalTask") + local calTask = self.owner:getProperty("calTask") calTask = {} local role = self.owner local buildL = role.dinerData:getProperty("buildL") @@ -497,32 +497,49 @@ activityFunc[Activity.ActivityType.CalendaTask] = { end, ["crossDay"] = function(self, actType, notify, actId) - local actData = self.owner:getProperty("CalTask") or {} + local actData = self.owner:getProperty("calTask") or {} local record = actData["r"] or {} local actCfg = csvdb["activity_taskCsv"][actId] if not actCfg then return end local change = false for taskId, cfg in pairs(actCfg) do - if cfg["resetType"] == 1 then -- 每日充值 + if cfg["resetType"] == 1 then -- 每日重置 record[taskId] = nil actData[taskId] = nil change = true end end if change then - self.owner:updateProperty({field="CalTask", value=actData}) + self.owner:updateProperty({field="calTask", value=actData}) + end + end, + ["crossWeek"] = function(self, actType, notify, actId) + local actData = self.owner:getProperty("calTask") or {} + local record = actData["r"] or {} + local actCfg = csvdb["activity_taskCsv"][actId] + if not actCfg then return end + local change = false + for taskId, cfg in pairs(actCfg) do + if cfg["resetType"] == 2 then -- 每周重置 + record[taskId] = nil + actData[taskId] = nil + change = true + end + end + if change then + self.owner:updateProperty({field="calTask", value=actData}) end end, ["close"] = function(self, actType, notify) - self.owner:updateProperty({field="CalTask", value={}}) + self.owner:updateProperty({field="calTask", value={}}) end, } -- 活动任务 仅供春节活动使用 防冲突 -activityFunc[Activity.ActivityType.CalendaTaskTmp] = { +activityFunc[Activity.ActivityType.BattleCommandTask] = { ["init"] = function(self, actType, isCrossDay, notify) - local calTask = self.owner:getProperty("CalTask1") - calTask = {} + local bcTask = self.owner:getProperty("bcTask") + bcTask = {} local role = self.owner local buildL = role.dinerData:getProperty("buildL") local curLevel = buildL:getv(1, 1) @@ -547,7 +564,7 @@ activityFunc[Activity.ActivityType.CalendaTaskTmp] = { end, ["crossDay"] = function(self, actType, notify, actId) - local actData = self.owner:getProperty("CalTask1") or {} + local actData = self.owner:getProperty("bcTask") or {} local record = actData["r"] or {} local actCfg = csvdb["activity_taskCsv"][actId] if not actCfg then return end @@ -560,11 +577,28 @@ activityFunc[Activity.ActivityType.CalendaTaskTmp] = { end end if change then - self.owner:updateProperty({field="CalTask1", value=actData}) + self.owner:updateProperty({field="bcTask", value=actData}) + end + end, + ["crossWeek"] = function(self, actType, notify, actId) + local actData = self.owner:getProperty("bcTask") or {} + local record = actData["r"] or {} + local actCfg = csvdb["activity_taskCsv"][actId] + if not actCfg then return end + local change = false + for taskId, cfg in pairs(actCfg) do + if cfg["resetType"] == 2 then -- 每周重置 + record[taskId] = nil + actData[taskId] = nil + change = true + end + end + if change then + self.owner:updateProperty({field="bcTask", value=actData}) end end, ["close"] = function(self, actType, notify) - self.owner:updateProperty({field="CalTask1", value={}}) + self.owner:updateProperty({field="bcTask", value={}}) end, } @@ -696,6 +730,18 @@ function Activity:refreshDailyData(notify) end end +function Activity:refreshWeekData(notify) + for actId, status in pairs(self._isOpen) do + local actData = csvdb["activity_ctrlCsv"][actId] + if status and actData then + local actType = actData.showType + if activityFunc[actType] and activityFunc[actType]['crossWeek'] then + activityFunc[actType]["crossWeek"](self, actType, notify, actId) + end + end + end +end + function Activity:checkActivity(notNotify, activityType, ...) if not activityType then return end if not self:isOpen(activityType) then return end @@ -963,7 +1009,7 @@ activityFunc[Activity.ActivityType.CommonSignIn] = { local actData = self:getActData(actType) or {} local actCfg = csvdb["activity_ctrlCsv"][actId] if not actCfg then return end - local conArr = actCfg.condition2:toArray("true", "=") + local conArr = actCfg.condition2:toArray(true, "=") -- 0 登录即可, 1 达到指定活跃度 if conArr[1] ~= 1 then return @@ -978,7 +1024,7 @@ activityFunc[Activity.ActivityType.CommonSignIn] = { activityFunc[Activity.ActivityType.BattleCommand] = { ["init"] = function (self, actType, isCrossDay, notify, actId) - local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0} + local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0, week = 0} self:updateActData(actType, data, not notify) end, ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count @@ -987,8 +1033,13 @@ activityFunc[Activity.ActivityType.BattleCommand] = { local actCfg = csvdb["activity_ctrlCsv"][actId] if not actCfg then return end if actCfg.condition1 == "" then return end - local itemId = tonumber(actCfg.condition2) + local arr = actCfg.condition2:toArray(true, "=") + local itemId, limit = arr[1], arr[2] if itemId == id and count > 0 then + if actData["week"] >= limit then + return + end + actData["week"] = actData["week"] + count local total = actData["sum"] + count local curLvl = actData["lvl"] or 0 if actCfg.condition == 1 then -- 代表sum需要转换为等级 @@ -1009,6 +1060,11 @@ activityFunc[Activity.ActivityType.BattleCommand] = { self:updateActData(actType, actData) end end, + ["crossWeek"] = function(self, actType, notify, actId) + local actData = self:getActData(actType) or {} + actData["week"] = 0 + self:updateActData(actType, actData, true) + end, } diff --git a/src/models/Role.lua b/src/models/Role.lua index 607c61e..5a28d68 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -184,7 +184,7 @@ Role.schema = { feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 calTask = {"table", {}}, -- 英雄令活动 日历任务活动 - calTask1 = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 + bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv } @@ -412,7 +412,7 @@ function Role:data() feedback = self:getProperty("feedback"), ctime = self:getProperty("ctime"), calTask = self:getProperty("calTask"), - calTask1 = self:getProperty("calTask1"), + bcTask = self:getProperty("bcTask"), radioTask = self:getProperty("radioTask"), } end diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index aa2c5df..1a0b258 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -98,6 +98,7 @@ local ItemReason = { actPaySign = 1008, -- 活动付费签到 calendaTask = 1009, -- 英雄帖 actMilecrisis = 1010, -- 物资危机 + battleCommandTask = 1011, -- 将军令任务 -- 餐厅 greenHourse = 1101, -- 食材获得 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 3d8ec18..a7be49f 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -135,6 +135,15 @@ function RolePlugin.bind(Role) self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log}) end, } + + if count > 0 then + local itemCfg = csvdb["itemCsv"][itemId] + local itemType = 0 + if itemCfg then + itemType = itemCfg.type + end + self:checkTaskEnter("AddItem", {id = itemId, count = count, type = itemType}) + end -- 对数量筛查 count = checkItemCount(self, itemId, count) if count ~= 0 then @@ -362,9 +371,6 @@ function RolePlugin.bind(Role) if not params.notNotify then SendPacket(actionCodes.Role_updateItems, MsgPack.pack({[params.itemId] = nums})) end - if params.count > 0 then - self:checkTaskEnter("AddItem", {id = params.itemId, count = params.count}) - end end function Role:checkItemEnough(itemCountT) @@ -518,6 +524,8 @@ function RolePlugin.bind(Role) end self:notifyUpdateProperty("diamond", self:getAllDiamond()) + + self:checkTaskEnter("CostDiamond", {count = count}) return true end diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 85567e0..c0e154c 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -15,6 +15,7 @@ local TaskType = { HeroLvlCollect = 10, -- 英雄等级收集进度 HeroQualityCollect = 11, -- 英雄品质收集进度 HeroStarCollect = 12, -- 英雄星级收集进度 + DrawHeroNotFriend = 13, -- 非友情招募 -- count --装备相关 AddEquip = 101, -- 获得装备 - equipId rarity @@ -53,6 +54,7 @@ local TaskType = { AdvMineLayer = 414, -- 宝藏洞激活 AdvKillBoss = 415, -- 拾荒击杀boss AdvHangHeroCnt = 416, -- 拾荒人数 + AdvCostPower = 417, -- 消耗体力 --爬塔相关 TowerPass = 501, -- 爬塔通关 - level @@ -98,6 +100,9 @@ local TaskType = { RadioTaskStart = 905, -- 电台任务开始 FinishSpeTask = 906, -- 指定任务完成 AddItem = 907, -- 获得道具 + Login = 908, -- 登入 + CostDiamond = 909, -- 消耗钻石 + WeekTask = 910, -- 完成每周活跃任务 --功能未实现 todo AdvShop = 1002, -- 冒险商城 @@ -284,42 +289,20 @@ local CalendaTaskListener = { [TaskType.AdvMineKill] = {{26, 1}}, [TaskType.PvpBattle] = {{27, 1}}, [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}}, - + [TaskType.Login] = {{29, 1}}, + [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.CostDiamond] = {{34, 1, f("count")}}, + [TaskType.DrawHeroNotFriend] = {{35, 1, f("count")}}, + [TaskType.AdvCostPower] = {{36, 1, f("count")}}, } } -local CalendaTaskTmpListener = { - func = "checkCalendaTaskTmp", - listen = { - [TaskType.DrawHero] = {{1, 1, f("count")}}, - [TaskType.BonusPass]= {{2, 1, f("count")}}, - [TaskType.AdvStart]= {{3, 1}}, - [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, - [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 - [TaskType.AdvHang]= {{6, 1}}, ---- - [TaskType.HeroQualityCollect]= {{7, 3}}, - [TaskType.OverOderTask]= {{8, 1}}, - [TaskType.VillageApply]= {{9, 1}}, - [TaskType.PvpWin]= {{10, 2, f("score")}}, - [TaskType.DinerPopular]= {{11, 2, f("count")}}, - [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, - [TaskType.TowerPass]= {{13, 2, f("level")}}, - [TaskType.HeroTalent]= {{14, 1}}, - [TaskType.HangPass]= {{15, 3}}, - [TaskType.HeroStarCollect]= {{16, 3}}, - [TaskType.FoodSell]= {{17, 1, f("count")}}, - [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")}}, - - } +local BattleCommandTaskListener = { + func = "checkBattleCommandTask", + listen = CalendaTaskListener["listen"] } local TaskListeners = { @@ -330,7 +313,7 @@ local TaskListeners = { ActivityListener, StoreListener, CalendaTaskListener, - CalendaTaskTmpListener, + BattleCommandTaskListener, } local RoleTask = {} @@ -659,15 +642,17 @@ function RoleTask.bind(Role) end function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) - --print("check calenda taskl", 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("CalendaTask") + 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 - local calTask = self:getProperty("calTask") or {} + local calTask = self:getProperty(keyName) or {} param1 = param1 or 1 local cid = actData.condition @@ -742,7 +727,7 @@ function RoleTask.bind(Role) calTask[id] = count elseif cfg.type == 20 then -- 开启x品质时钟箱子 if cfg.condition2 <= (param2 or 0) then - calTask[id] = (calTask[id] or 0) + param2 + calTask[id] = (calTask[id] or 0) + param1 end elseif cfg.type == 15 then -- 通关关卡 if (calTask[id] or 0) == 0 then @@ -761,26 +746,32 @@ function RoleTask.bind(Role) 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 = "calTask", value = calTask, notNotify = notNotify}) + self:updateProperty({field = keyName, value = calTask, notNotify = notNotify}) --dump(calTask) end - function Role:checkCalendaTaskTmp(notNotify, mainType, subType, param1, param2) - --print("check calenda taskl", mainType, subType, param1, param2) + function Role:checkBattleCommandTask(notNotify, mainType, subType, param1, param2) + --print("check battle command task", mainType, subType, param1, param2) + local actEnum = "BattleCommandTask" + local keyName = "bcTask" if not self.activity then return end - local open, actId = self.activity:isOpen("CalendaTaskTmp") + 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 - local calTask = self:getProperty("calTask1") or {} + local calTask = self:getProperty(keyName) or {} param1 = param1 or 1 local cid = actData.condition @@ -855,7 +846,7 @@ function RoleTask.bind(Role) calTask[id] = count elseif cfg.type == 20 then -- 开启x品质时钟箱子 if cfg.condition2 <= (param2 or 0) then - calTask[id] = (calTask[id] or 0) + param2 + calTask[id] = (calTask[id] or 0) + param1 end elseif cfg.type == 15 then -- 通关关卡 if (calTask[id] or 0) == 0 then @@ -874,13 +865,17 @@ function RoleTask.bind(Role) 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 = "calTask1", value = calTask, notNotify = notNotify}) + self:updateProperty({field = keyName, value = calTask, notNotify = notNotify}) --dump(calTask) end diff --git a/src/models/RoleTimeReset.lua b/src/models/RoleTimeReset.lua index 8ecba88..f5174c1 100644 --- a/src/models/RoleTimeReset.lua +++ b/src/models/RoleTimeReset.lua @@ -41,6 +41,8 @@ ResetFunc["CrossWeek"] = function(self, notify, response) response.wTask = {} response.dinerS = {} + + self.activity:refreshWeekData(notify) end ResetFunc["CrossMonth"] = function(self, notify, response) -- libgit2 0.21.2