diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index f7d3b6e..aeb0675 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -208,6 +208,7 @@ actionCodes = { Activity_sudokuRewardRpc = 652, Activity_actSignRpc = 653, Activity_actPaySignRewardNtf = 654, + Activity_actCalendaTaskRpc = 655, } rpcResponseBegin = 10000 diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index 72c974c..87c549d 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -221,4 +221,39 @@ function _M.actPaySignRpc(agent, data) return true end +function _M.actCalendaActRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local taskId = msg.id + local calTask = role:getProperty("CalTask") + local record = calTask["r"] or {} + local flag = record[taskId] or 0 + if flag == 1 then return 1 end + local open, actId = role.activity:isOpen("CalendaTask") + local actData = csvdb["activity_ctrlCsv"][actId] + if not open then return 2 end + if not actData then return 3 end + + local taskCfg = csvdb["activity_taskCsv"][taskId] + if not taskCfg then return 4 end + if taskCfg.key ~= actData.condition then return 5 end + + if (calTask[taskId] or 0) < taskCfg.condition1 then return 6 end + + record[taskId] = 1 + calTask["r"] = record + + role:updateProperty({field = "CalTask", value = calTask}) + + local reward, change = role:award(taskCfg.reward, {log = {desc = "CalendaTask"}}) + + role:log("activity", { + activity_id = taskId, -- 活动ID(或活动指定任务的ID) + activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} + }) + + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) +end + return _M \ No newline at end of file diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index be31860..02844e4 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -354,7 +354,7 @@ function _M.getRewardRpc(agent , data) hangInfo.itemTime = nowTime role:updateProperty({field = "hangBag", value = items}) role:updateProperty({field = "hangInfo", value = hangInfo}) - role:checkTaskEnter("HangGet") + role:checkTaskEnter("HangGet", {reward = reward}) if reward[ItemId.Gold] then role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) end diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index c6a0fd5..a4c2171 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data ) hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) + + role:checkTaskEnter("HeroLvlCollect", {}) SendPacket(actionCodes.Hero_levelUpRpc, '') return true end @@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data) }) SendPacket(actionCodes.Hero_wakeRpc, '') + + role:checkTaskEnter("HeroStarCollect", {}) return true end @@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data) }) end end + + role:checkTaskEnter("RuneQualityCollect", {}) SendPacket(actionCodes.Hero_referRunesRpc, "") return true diff --git a/src/models/Activity.lua b/src/models/Activity.lua index 5a82ef7..a83e9f6 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -362,6 +362,37 @@ activityFunc[Activity.ActivityType.PayBack] = { -- end, } +-- 英雄帖 +activityFunc[Activity.ActivityType.CalendaTask] = { + ["init"] = function(self, actType, isCrossDay, notify) + local calTask = self.owner:getProperty("CalTask") + calTask = {} + local role = self.owner + local buildL = role.dinerData:getProperty("buildL") + local curLevel = buildL:getv(1, 1) + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) + + role:checkTaskEnter("HeroLvlCollect", {}) + role:checkTaskEnter("HeroQualityCollect", {}) + + local curPopular = role.dinerData:getProperty("popular") + role:checkTaskEnter("DinerPopular", {count = curPopular}) + + local rLevel = role:getProperty("level") + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) + + local towerInfo = role:getProperty("towerInfo") + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) + --"PvpWin" + role:checkTaskEnter("HangPass", {}) + role:checkTaskEnter("HeroStarCollect", {}) + role:checkTaskEnter("RuneQualityCollect", {}) + + end, + -- ["close"] = function(self, actType, notify) + -- end, +} + function Activity:initActivity(actId, isCrossDay, notify) local actData = csvdb["activity_ctrlCsv"][actId] if not actData then return end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index e1ceb33..d2c3239 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -451,6 +451,7 @@ function RolePlugin.bind(Role) newHero:saveBattleValue() self.heros[heroId] = newHero self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) + self:checkTaskEnter("HeroQualityCollect", {}) if not params.notNotify then local heroResponse = {} table.insert(heroResponse, newHero:data()) diff --git a/src/models/RoleTask.lua b/src/models/RoleTask.lua index 618105d..5ffa493 100644 --- a/src/models/RoleTask.lua +++ b/src/models/RoleTask.lua @@ -253,7 +253,7 @@ local CalendaTaskListener = { [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, [TaskType.TowerPass]= {{13, 2, f("level")}}, [TaskType.HeroTalent]= {{14, 1}}, - [TaskType.HangPass]= {{15, 2, f("id")}}, + [TaskType.HangPass]= {{15, 3}}, [TaskType.HeroStarCollect]= {{16, 3}}, [TaskType.FoodSell]= {{17, 1, f("count")}}, [TaskType.HangGet]= {{18, 3, f("reward")}}, @@ -586,7 +586,8 @@ function RoleTask.bind(Role) end function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) - print("check calenda taskl", mainType, subType, param1, param2) + --print("check calenda taskl", mainType, subType, param1, param2) + if not self.activity then return end local open, actId = self.activity:isOpen("CalendaTask") local actData = csvdb["activity_ctrlCsv"][actId] if not actData then return end @@ -672,6 +673,14 @@ function RoleTask.bind(Role) if cfg.condition2 <= (param2 or 0) then calTask[id] = (calTask[id] or 0) + param2 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 end end end @@ -679,7 +688,7 @@ function RoleTask.bind(Role) end end self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify}) - dump(calTask) + --dump(calTask) end end -- libgit2 0.21.2