Commit 190e14152f99bb754b251f25e9dc7eace017de5f

Authored by liuzujun
1 parent ffa0e259

英雄帖活动初始化

src/ProtocolCode.lua
@@ -208,6 +208,7 @@ actionCodes = { @@ -208,6 +208,7 @@ actionCodes = {
208 Activity_sudokuRewardRpc = 652, 208 Activity_sudokuRewardRpc = 652,
209 Activity_actSignRpc = 653, 209 Activity_actSignRpc = 653,
210 Activity_actPaySignRewardNtf = 654, 210 Activity_actPaySignRewardNtf = 654,
  211 + Activity_actCalendaTaskRpc = 655,
211 } 212 }
212 213
213 rpcResponseBegin = 10000 214 rpcResponseBegin = 10000
src/actions/ActivityAction.lua
@@ -221,4 +221,39 @@ function _M.actPaySignRpc(agent, data) @@ -221,4 +221,39 @@ function _M.actPaySignRpc(agent, data)
221 return true 221 return true
222 end 222 end
223 223
  224 +function _M.actCalendaActRpc(agent, data)
  225 + local role = agent.role
  226 + local msg = MsgPack.unpack(data)
  227 + local taskId = msg.id
  228 + local calTask = role:getProperty("CalTask")
  229 + local record = calTask["r"] or {}
  230 + local flag = record[taskId] or 0
  231 + if flag == 1 then return 1 end
  232 + local open, actId = role.activity:isOpen("CalendaTask")
  233 + local actData = csvdb["activity_ctrlCsv"][actId]
  234 + if not open then return 2 end
  235 + if not actData then return 3 end
  236 +
  237 + local taskCfg = csvdb["activity_taskCsv"][taskId]
  238 + if not taskCfg then return 4 end
  239 + if taskCfg.key ~= actData.condition then return 5 end
  240 +
  241 + if (calTask[taskId] or 0) < taskCfg.condition1 then return 6 end
  242 +
  243 + record[taskId] = 1
  244 + calTask["r"] = record
  245 +
  246 + role:updateProperty({field = "CalTask", value = calTask})
  247 +
  248 + local reward, change = role:award(taskCfg.reward, {log = {desc = "CalendaTask"}})
  249 +
  250 + role:log("activity", {
  251 + activity_id = taskId, -- 活动ID(或活动指定任务的ID)
  252 + activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表
  253 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  254 + })
  255 +
  256 + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change)))
  257 +end
  258 +
224 return _M 259 return _M
225 \ No newline at end of file 260 \ No newline at end of file
src/actions/HangAction.lua
@@ -354,7 +354,7 @@ function _M.getRewardRpc(agent , data) @@ -354,7 +354,7 @@ function _M.getRewardRpc(agent , data)
354 hangInfo.itemTime = nowTime 354 hangInfo.itemTime = nowTime
355 role:updateProperty({field = "hangBag", value = items}) 355 role:updateProperty({field = "hangBag", value = items})
356 role:updateProperty({field = "hangInfo", value = hangInfo}) 356 role:updateProperty({field = "hangInfo", value = hangInfo})
357 - role:checkTaskEnter("HangGet") 357 + role:checkTaskEnter("HangGet", {reward = reward})
358 if reward[ItemId.Gold] then 358 if reward[ItemId.Gold] then
359 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) 359 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
360 end 360 end
src/actions/HeroAction.lua
@@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data ) @@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data )
60 hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) 60 hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")})
61 61
62 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) 62 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
  63 +
  64 + role:checkTaskEnter("HeroLvlCollect", {})
63 SendPacket(actionCodes.Hero_levelUpRpc, '') 65 SendPacket(actionCodes.Hero_levelUpRpc, '')
64 return true 66 return true
65 end 67 end
@@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data) @@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data)
128 }) 130 })
129 131
130 SendPacket(actionCodes.Hero_wakeRpc, '') 132 SendPacket(actionCodes.Hero_wakeRpc, '')
  133 +
  134 + role:checkTaskEnter("HeroStarCollect", {})
131 return true 135 return true
132 end 136 end
133 137
@@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data) @@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data)
595 }) 599 })
596 end 600 end
597 end 601 end
  602 +
  603 + role:checkTaskEnter("RuneQualityCollect", {})
598 604
599 SendPacket(actionCodes.Hero_referRunesRpc, "") 605 SendPacket(actionCodes.Hero_referRunesRpc, "")
600 return true 606 return true
src/models/Activity.lua
@@ -362,6 +362,37 @@ activityFunc[Activity.ActivityType.PayBack] = { @@ -362,6 +362,37 @@ activityFunc[Activity.ActivityType.PayBack] = {
362 -- end, 362 -- end,
363 } 363 }
364 364
  365 +-- 英雄帖
  366 +activityFunc[Activity.ActivityType.CalendaTask] = {
  367 + ["init"] = function(self, actType, isCrossDay, notify)
  368 + local calTask = self.owner:getProperty("CalTask")
  369 + calTask = {}
  370 + local role = self.owner
  371 + local buildL = role.dinerData:getProperty("buildL")
  372 + local curLevel = buildL:getv(1, 1)
  373 + role:checkTaskEnter("DinerLevelUp", {level = curLevel})
  374 +
  375 + role:checkTaskEnter("HeroLvlCollect", {})
  376 + role:checkTaskEnter("HeroQualityCollect", {})
  377 +
  378 + local curPopular = role.dinerData:getProperty("popular")
  379 + role:checkTaskEnter("DinerPopular", {count = curPopular})
  380 +
  381 + local rLevel = role:getProperty("level")
  382 + role:checkTaskEnter("RoleLevelUp", {level = rLevel})
  383 +
  384 + local towerInfo = role:getProperty("towerInfo")
  385 + role:checkTaskEnter("TowerPass", {level = towerInfo.l})
  386 + --"PvpWin"
  387 + role:checkTaskEnter("HangPass", {})
  388 + role:checkTaskEnter("HeroStarCollect", {})
  389 + role:checkTaskEnter("RuneQualityCollect", {})
  390 +
  391 + end,
  392 + -- ["close"] = function(self, actType, notify)
  393 + -- end,
  394 +}
  395 +
365 function Activity:initActivity(actId, isCrossDay, notify) 396 function Activity:initActivity(actId, isCrossDay, notify)
366 local actData = csvdb["activity_ctrlCsv"][actId] 397 local actData = csvdb["activity_ctrlCsv"][actId]
367 if not actData then return end 398 if not actData then return end
src/models/RolePlugin.lua
@@ -451,6 +451,7 @@ function RolePlugin.bind(Role) @@ -451,6 +451,7 @@ function RolePlugin.bind(Role)
451 newHero:saveBattleValue() 451 newHero:saveBattleValue()
452 self.heros[heroId] = newHero 452 self.heros[heroId] = newHero
453 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) 453 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify)
  454 + self:checkTaskEnter("HeroQualityCollect", {})
454 if not params.notNotify then 455 if not params.notNotify then
455 local heroResponse = {} 456 local heroResponse = {}
456 table.insert(heroResponse, newHero:data()) 457 table.insert(heroResponse, newHero:data())
src/models/RoleTask.lua
@@ -253,7 +253,7 @@ local CalendaTaskListener = { @@ -253,7 +253,7 @@ local CalendaTaskListener = {
253 [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, 253 [TaskType.RoleLevelUp]= {{12, 2, f("level")}},
254 [TaskType.TowerPass]= {{13, 2, f("level")}}, 254 [TaskType.TowerPass]= {{13, 2, f("level")}},
255 [TaskType.HeroTalent]= {{14, 1}}, 255 [TaskType.HeroTalent]= {{14, 1}},
256 - [TaskType.HangPass]= {{15, 2, f("id")}}, 256 + [TaskType.HangPass]= {{15, 3}},
257 [TaskType.HeroStarCollect]= {{16, 3}}, 257 [TaskType.HeroStarCollect]= {{16, 3}},
258 [TaskType.FoodSell]= {{17, 1, f("count")}}, 258 [TaskType.FoodSell]= {{17, 1, f("count")}},
259 [TaskType.HangGet]= {{18, 3, f("reward")}}, 259 [TaskType.HangGet]= {{18, 3, f("reward")}},
@@ -586,7 +586,8 @@ function RoleTask.bind(Role) @@ -586,7 +586,8 @@ function RoleTask.bind(Role)
586 end 586 end
587 587
588 function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) 588 function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2)
589 - print("check calenda taskl", mainType, subType, param1, param2) 589 + --print("check calenda taskl", mainType, subType, param1, param2)
  590 + if not self.activity then return end
590 local open, actId = self.activity:isOpen("CalendaTask") 591 local open, actId = self.activity:isOpen("CalendaTask")
591 local actData = csvdb["activity_ctrlCsv"][actId] 592 local actData = csvdb["activity_ctrlCsv"][actId]
592 if not actData then return end 593 if not actData then return end
@@ -672,6 +673,14 @@ function RoleTask.bind(Role) @@ -672,6 +673,14 @@ function RoleTask.bind(Role)
672 if cfg.condition2 <= (param2 or 0) then 673 if cfg.condition2 <= (param2 or 0) then
673 calTask[id] = (calTask[id] or 0) + param2 674 calTask[id] = (calTask[id] or 0) + param2
674 end 675 end
  676 + elseif cfg.type == 15 then -- 通关关卡
  677 + if (calTask[id] or 0) == 0 then
  678 + local hangPass = self:getProperty("hangPass")
  679 + local diff = math.floor(cfg.condition2 / 10000)
  680 + if (hangPass[diff] or 0) >= cfg.condition1 then
  681 + calTask[id] = 1
  682 + end
  683 + end
675 end 684 end
676 end 685 end
677 end 686 end
@@ -679,7 +688,7 @@ function RoleTask.bind(Role) @@ -679,7 +688,7 @@ function RoleTask.bind(Role)
679 end 688 end
680 end 689 end
681 self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify}) 690 self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify})
682 - dump(calTask) 691 + --dump(calTask)
683 end 692 end
684 693
685 end 694 end