Commit 190e14152f99bb754b251f25e9dc7eace017de5f

Authored by liuzujun
1 parent ffa0e259

英雄帖活动初始化

src/ProtocolCode.lua
... ... @@ -208,6 +208,7 @@ actionCodes = {
208 208 Activity_sudokuRewardRpc = 652,
209 209 Activity_actSignRpc = 653,
210 210 Activity_actPaySignRewardNtf = 654,
  211 + Activity_actCalendaTaskRpc = 655,
211 212 }
212 213  
213 214 rpcResponseBegin = 10000
... ...
src/actions/ActivityAction.lua
... ... @@ -221,4 +221,39 @@ function _M.actPaySignRpc(agent, data)
221 221 return true
222 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 259 return _M
225 260 \ No newline at end of file
... ...
src/actions/HangAction.lua
... ... @@ -354,7 +354,7 @@ function _M.getRewardRpc(agent , data)
354 354 hangInfo.itemTime = nowTime
355 355 role:updateProperty({field = "hangBag", value = items})
356 356 role:updateProperty({field = "hangInfo", value = hangInfo})
357   - role:checkTaskEnter("HangGet")
  357 + role:checkTaskEnter("HangGet", {reward = reward})
358 358 if reward[ItemId.Gold] then
359 359 role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]})
360 360 end
... ...
src/actions/HeroAction.lua
... ... @@ -60,6 +60,8 @@ function _M.levelUpRpc( agent, data )
60 60 hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")})
61 61  
62 62 role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
  63 +
  64 + role:checkTaskEnter("HeroLvlCollect", {})
63 65 SendPacket(actionCodes.Hero_levelUpRpc, '')
64 66 return true
65 67 end
... ... @@ -128,6 +130,8 @@ function _M.wakeRpc(agent, data)
128 130 })
129 131  
130 132 SendPacket(actionCodes.Hero_wakeRpc, '')
  133 +
  134 + role:checkTaskEnter("HeroStarCollect", {})
131 135 return true
132 136 end
133 137  
... ... @@ -595,6 +599,8 @@ function _M.referRunesRpc(agent, data)
595 599 })
596 600 end
597 601 end
  602 +
  603 + role:checkTaskEnter("RuneQualityCollect", {})
598 604  
599 605 SendPacket(actionCodes.Hero_referRunesRpc, "")
600 606 return true
... ...
src/models/Activity.lua
... ... @@ -362,6 +362,37 @@ activityFunc[Activity.ActivityType.PayBack] = {
362 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 396 function Activity:initActivity(actId, isCrossDay, notify)
366 397 local actData = csvdb["activity_ctrlCsv"][actId]
367 398 if not actData then return end
... ...
src/models/RolePlugin.lua
... ... @@ -451,6 +451,7 @@ function RolePlugin.bind(Role)
451 451 newHero:saveBattleValue()
452 452 self.heros[heroId] = newHero
453 453 self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify)
  454 + self:checkTaskEnter("HeroQualityCollect", {})
454 455 if not params.notNotify then
455 456 local heroResponse = {}
456 457 table.insert(heroResponse, newHero:data())
... ...
src/models/RoleTask.lua
... ... @@ -253,7 +253,7 @@ local CalendaTaskListener = {
253 253 [TaskType.RoleLevelUp]= {{12, 2, f("level")}},
254 254 [TaskType.TowerPass]= {{13, 2, f("level")}},
255 255 [TaskType.HeroTalent]= {{14, 1}},
256   - [TaskType.HangPass]= {{15, 2, f("id")}},
  256 + [TaskType.HangPass]= {{15, 3}},
257 257 [TaskType.HeroStarCollect]= {{16, 3}},
258 258 [TaskType.FoodSell]= {{17, 1, f("count")}},
259 259 [TaskType.HangGet]= {{18, 3, f("reward")}},
... ... @@ -586,7 +586,8 @@ function RoleTask.bind(Role)
586 586 end
587 587  
588 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 591 local open, actId = self.activity:isOpen("CalendaTask")
591 592 local actData = csvdb["activity_ctrlCsv"][actId]
592 593 if not actData then return end
... ... @@ -672,6 +673,14 @@ function RoleTask.bind(Role)
672 673 if cfg.condition2 <= (param2 or 0) then
673 674 calTask[id] = (calTask[id] or 0) + param2
674 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 684 end
676 685 end
677 686 end
... ... @@ -679,7 +688,7 @@ function RoleTask.bind(Role)
679 688 end
680 689 end
681 690 self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify})
682   - dump(calTask)
  691 + --dump(calTask)
683 692 end
684 693  
685 694 end
... ...