Commit 78e5b90eaa9ec78faa9e6510dfc7737995e44d4a
1 parent
18bf12f3
完成需求:新玩家任务
Showing
6 changed files
with
170 additions
and
1 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -254,6 +254,7 @@ actionCodes = { | @@ -254,6 +254,7 @@ actionCodes = { | ||
| 254 | Activity_advLevelRpc = 671, | 254 | Activity_advLevelRpc = 671, |
| 255 | Activity_buyBattleCommandLvlRpc = 672, | 255 | Activity_buyBattleCommandLvlRpc = 672, |
| 256 | Activity_returnerTaskRpc = 673, | 256 | Activity_returnerTaskRpc = 673, |
| 257 | + Activity_actNewUserTaskRpc = 674, | ||
| 257 | 258 | ||
| 258 | Radio_startQuestRpc = 700, | 259 | Radio_startQuestRpc = 700, |
| 259 | Radio_finishQuestRpc = 701, | 260 | Radio_finishQuestRpc = 701, |
src/actions/ActivityAction.lua
| @@ -320,6 +320,47 @@ function _M.actBattleCommandTaskRpc(agent, data) | @@ -320,6 +320,47 @@ function _M.actBattleCommandTaskRpc(agent, data) | ||
| 320 | return true | 320 | return true |
| 321 | end | 321 | end |
| 322 | 322 | ||
| 323 | +function _M.actNewUserTaskRpc(agent, data) | ||
| 324 | + local role = agent.role | ||
| 325 | + local msg = MsgPack.unpack(data) | ||
| 326 | + local taskId = msg.id | ||
| 327 | + local calTask = role:getProperty("nbTask") or {} | ||
| 328 | + local record = calTask["r"] or {} | ||
| 329 | + local flag = record[taskId] or 0 | ||
| 330 | + if flag == 1 then return 1 end | ||
| 331 | + local open, actId = role.activity:isOpen("NewUserTask") | ||
| 332 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
| 333 | + if not open then return 2 end | ||
| 334 | + if not actData then return 3 end | ||
| 335 | + | ||
| 336 | + local taskList = csvdb["activity_taskCsv"][actData.condition] | ||
| 337 | + if not taskList then return 4 end | ||
| 338 | + local taskCfg = taskList[taskId] | ||
| 339 | + if not taskCfg then return 5 end | ||
| 340 | + if taskCfg.key ~= actData.condition then return 6 end | ||
| 341 | + | ||
| 342 | + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end | ||
| 343 | + | ||
| 344 | + record[taskId] = 1 | ||
| 345 | + calTask["r"] = record | ||
| 346 | + | ||
| 347 | + role:updateProperty({field = "nbTask", value = calTask}) | ||
| 348 | + | ||
| 349 | + local reward, change = role:award(taskCfg.reward, {log = {desc = "newUserTask"}}) | ||
| 350 | + | ||
| 351 | + role:log("activity", { | ||
| 352 | + activity_id = taskId, -- 活动ID(或活动指定任务的ID) | ||
| 353 | + activity_type = role.activity.ActivityType.NewUserTask, -- 活动类型,见活动类型枚举表 | ||
| 354 | + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
| 355 | + }) | ||
| 356 | + | ||
| 357 | + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) | ||
| 358 | + | ||
| 359 | + SendPacket(actionCodes.Activity_actNewUserTaskRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 360 | + | ||
| 361 | + return true | ||
| 362 | +end | ||
| 363 | + | ||
| 323 | function _M.exchangeRpc(agent, data) | 364 | function _M.exchangeRpc(agent, data) |
| 324 | local role = agent.role | 365 | local role = agent.role |
| 325 | local msg = MsgPack.unpack(data) | 366 | local msg = MsgPack.unpack(data) |
src/models/Activity.lua
| @@ -39,6 +39,7 @@ Activity.ActivityType = { | @@ -39,6 +39,7 @@ Activity.ActivityType = { | ||
| 39 | HeroBackFree = 37, -- 无损耗归还 | 39 | HeroBackFree = 37, -- 无损耗归还 |
| 40 | 40 | ||
| 41 | BattleCommandTask = 38, -- 战令任务活动 | 41 | BattleCommandTask = 38, -- 战令任务活动 |
| 42 | + NewUserTask = 41, -- 新用户任务 | ||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | local function checkActivityType(activityType) | 45 | local function checkActivityType(activityType) |
| @@ -641,6 +642,110 @@ activityFunc[Activity.ActivityType.Exchange] = { | @@ -641,6 +642,110 @@ activityFunc[Activity.ActivityType.Exchange] = { | ||
| 641 | end, | 642 | end, |
| 642 | } | 643 | } |
| 643 | 644 | ||
| 645 | +-- 新用户活动任务 | ||
| 646 | +activityFunc[Activity.ActivityType.NewUserTask] = { | ||
| 647 | + ["init"] = function(self, actType, isCrossDay, notify) | ||
| 648 | + local nbTask = self.owner:getProperty("nbTask") | ||
| 649 | + nbTask = {} | ||
| 650 | + self.owner:updateProperty({field="nbTask", value=nbTask}) | ||
| 651 | + local role = self.owner | ||
| 652 | + local buildL = role.dinerData:getProperty("buildL") | ||
| 653 | + local curLevel = buildL:getv(1, 1) | ||
| 654 | + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) | ||
| 655 | + | ||
| 656 | + role:checkTaskEnter("HeroLvlCollect", {}) | ||
| 657 | + role:checkTaskEnter("HeroQualityCollect", {}) | ||
| 658 | + | ||
| 659 | + local curPopular = role.dinerData:getProperty("popular") | ||
| 660 | + role:checkTaskEnter("DinerPopular", {count = curPopular}) | ||
| 661 | + | ||
| 662 | + local rLevel = role:getProperty("level") | ||
| 663 | + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | ||
| 664 | + | ||
| 665 | + local towerInfo = role:getProperty("towerInfo") | ||
| 666 | + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1}) | ||
| 667 | + --"PvpWin" | ||
| 668 | + --role:checkTaskEnter("HangPass", {id = 0}) | ||
| 669 | + role:checkCalendaTask(true, 15, 3) | ||
| 670 | + role:checkTaskEnter("HeroStarCollect", {}) | ||
| 671 | + role:checkTaskEnter("RuneQualityCollect", {}) | ||
| 672 | + | ||
| 673 | + end, | ||
| 674 | + ["crossDay"] = function(self, actType, notify, actId) | ||
| 675 | + local actData = self.owner:getProperty("nbTask") or {} | ||
| 676 | + local record = actData["r"] or {} | ||
| 677 | + local actCfg = csvdb["activity_taskCsv"][actId] | ||
| 678 | + if not actCfg then return end | ||
| 679 | + local change = false | ||
| 680 | + for taskId, cfg in pairs(actCfg) do | ||
| 681 | + if cfg["resetType"] == 1 then -- 每日重置 | ||
| 682 | + record[taskId] = nil | ||
| 683 | + actData[taskId] = nil | ||
| 684 | + change = true | ||
| 685 | + end | ||
| 686 | + end | ||
| 687 | + if change then | ||
| 688 | + self.owner:updateProperty({field="nbTask", value=actData}) | ||
| 689 | + end | ||
| 690 | + end, | ||
| 691 | + ["crossWeek"] = function(self, actType, notify, actId) | ||
| 692 | + local actData = self.owner:getProperty("nbTask") or {} | ||
| 693 | + local record = actData["r"] or {} | ||
| 694 | + local actCfg = csvdb["activity_taskCsv"][actId] | ||
| 695 | + if not actCfg then return end | ||
| 696 | + local change = false | ||
| 697 | + for taskId, cfg in pairs(actCfg) do | ||
| 698 | + if cfg["resetType"] == 2 then -- 每周重置 | ||
| 699 | + record[taskId] = nil | ||
| 700 | + actData[taskId] = nil | ||
| 701 | + change = true | ||
| 702 | + end | ||
| 703 | + end | ||
| 704 | + if change then | ||
| 705 | + self.owner:updateProperty({field="nbTask", value=actData}) | ||
| 706 | + end | ||
| 707 | + end, | ||
| 708 | + ["close"] = function(self, actType, notify) | ||
| 709 | + self.owner:updateProperty({field="nbTask", value={}}) | ||
| 710 | + end, | ||
| 711 | +} | ||
| 712 | + | ||
| 713 | +-- 兑换 | ||
| 714 | +activityFunc[Activity.ActivityType.Exchange] = { | ||
| 715 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
| 716 | + local actData = self:getActData(actType) or {} | ||
| 717 | + actData[actId] = {} | ||
| 718 | + self:updateActData(actType, actData, not notify) | ||
| 719 | + end, | ||
| 720 | + ["login"] = function(self, actType, actId) | ||
| 721 | + activityFunc[Activity.ActivityType.Exchange]["crossDay"](self, actType, true, actId) | ||
| 722 | + end, | ||
| 723 | + ["crossDay"] = function(self, actType, notify, actId) | ||
| 724 | + local actData = self:getActData(actType) or {} | ||
| 725 | + local lastTs = actData["ts"] or 0 | ||
| 726 | + local timeNow = skynet.timex() | ||
| 727 | + local cfg = csvdb["activity_ctrlCsv"][actId] | ||
| 728 | + if not cfg then return end | ||
| 729 | + local refreshTimes = cfg.condition2:toArray(false, "=") | ||
| 730 | + for i = 1, #refreshTimes do | ||
| 731 | + local rt = toUnixtime(refreshTimes[i]..string_format("%02x", RESET_TIME)) | ||
| 732 | + if timeNow >= rt and rt > lastTs then | ||
| 733 | + lastTs = rt | ||
| 734 | + actData = {} | ||
| 735 | + end | ||
| 736 | + end | ||
| 737 | + if not next(actData) then | ||
| 738 | + actData["ts"] = timeNow | ||
| 739 | + self:updateActData(actType, actData, not notify) | ||
| 740 | + end | ||
| 741 | + end, | ||
| 742 | + ["close"] = function(self, actType, notify, actId) | ||
| 743 | + local actData = self:getActData(actType) or {} | ||
| 744 | + actData[actId] = nil | ||
| 745 | + self:updateActData(actType, actData, not notify) | ||
| 746 | + end, | ||
| 747 | +} | ||
| 748 | + | ||
| 644 | -- 扭蛋机 | 749 | -- 扭蛋机 |
| 645 | activityFunc[Activity.ActivityType.Gachakon] = { | 750 | activityFunc[Activity.ActivityType.Gachakon] = { |
| 646 | ["init"] = function(self, actType, isCrossDay, notify, actId) | 751 | ["init"] = function(self, actType, isCrossDay, notify, actId) |
src/models/Role.lua
| @@ -193,8 +193,9 @@ Role.schema = { | @@ -193,8 +193,9 @@ Role.schema = { | ||
| 193 | downCvR = {"number", 0}, -- 下载cv扩展包奖励 | 193 | downCvR = {"number", 0}, -- 下载cv扩展包奖励 |
| 194 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 | 194 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 |
| 195 | 195 | ||
| 196 | - calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | 196 | + calTask = {"table", {}}, -- 英雄帖活动 日历任务活动 |
| 197 | bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 | 197 | bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 |
| 198 | + nbTask = {"table", {}}, -- 新用户活动 | ||
| 198 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | 199 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv |
| 199 | 200 | ||
| 200 | seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}} | 201 | seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}} |
| @@ -436,6 +437,7 @@ function Role:data() | @@ -436,6 +437,7 @@ function Role:data() | ||
| 436 | ctime = self:getProperty("ctime"), | 437 | ctime = self:getProperty("ctime"), |
| 437 | calTask = self:getProperty("calTask"), | 438 | calTask = self:getProperty("calTask"), |
| 438 | bcTask = self:getProperty("bcTask"), | 439 | bcTask = self:getProperty("bcTask"), |
| 440 | + nbTask = self:getProperty("nbTask"), | ||
| 439 | radioTask = self:getProperty("radioTask"), | 441 | radioTask = self:getProperty("radioTask"), |
| 440 | 442 | ||
| 441 | seaport = self:getProperty("seaport"), | 443 | seaport = self:getProperty("seaport"), |
src/models/RoleLog.lua
| @@ -104,6 +104,7 @@ local ItemReason = { | @@ -104,6 +104,7 @@ local ItemReason = { | ||
| 104 | calendaTask = 1009, -- 英雄帖 | 104 | calendaTask = 1009, -- 英雄帖 |
| 105 | actMilecrisis = 1010, -- 物资危机 | 105 | actMilecrisis = 1010, -- 物资危机 |
| 106 | battleCommandTask = 1011, -- 将军令任务 | 106 | battleCommandTask = 1011, -- 将军令任务 |
| 107 | + newUserTask = 1012, -- 新玩家任务 | ||
| 107 | 108 | ||
| 108 | -- 餐厅 | 109 | -- 餐厅 |
| 109 | greenHourse = 1101, -- 食材获得 | 110 | greenHourse = 1101, -- 食材获得 |
src/models/RoleTask.lua
| @@ -323,6 +323,11 @@ local BattleCommandTaskListener = { | @@ -323,6 +323,11 @@ local BattleCommandTaskListener = { | ||
| 323 | listen = CalendaTaskListener["listen"] | 323 | listen = CalendaTaskListener["listen"] |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | +local NewUserTaskListener = { | ||
| 327 | + func = "checkNewUserTask", | ||
| 328 | + listen = CalendaTaskListener["listen"] | ||
| 329 | +} | ||
| 330 | + | ||
| 326 | local ReturnerTask = { | 331 | local ReturnerTask = { |
| 327 | func = "checkReturnerTask", | 332 | func = "checkReturnerTask", |
| 328 | listen = CalendaTaskListener["listen"] | 333 | listen = CalendaTaskListener["listen"] |
| @@ -338,6 +343,7 @@ local TaskListeners = { | @@ -338,6 +343,7 @@ local TaskListeners = { | ||
| 338 | CalendaTaskListener, | 343 | CalendaTaskListener, |
| 339 | BattleCommandTaskListener, | 344 | BattleCommandTaskListener, |
| 340 | ReturnerTask, | 345 | ReturnerTask, |
| 346 | + NewUserTaskListener, | ||
| 341 | } | 347 | } |
| 342 | 348 | ||
| 343 | local RoleTask = {} | 349 | local RoleTask = {} |
| @@ -835,6 +841,19 @@ function RoleTask.bind(Role) | @@ -835,6 +841,19 @@ function RoleTask.bind(Role) | ||
| 835 | self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) | 841 | self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) |
| 836 | end | 842 | end |
| 837 | 843 | ||
| 844 | + function Role:checkNewUserTask(notNotify, mainType, subType, param1, param2) | ||
| 845 | + --print("check new user task", mainType, subType, param1, param2) | ||
| 846 | + local actEnum = "NewUserTask" | ||
| 847 | + local keyName = "nbTask" | ||
| 848 | + if not self.activity then return end | ||
| 849 | + local open, actId = self.activity:isOpen(actEnum) | ||
| 850 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
| 851 | + if not actData then return end | ||
| 852 | + if not open then return end | ||
| 853 | + | ||
| 854 | + self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) | ||
| 855 | + end | ||
| 856 | + | ||
| 838 | function Role:checkReturnerTask(notNotify, mainType, subType, param1, param2) | 857 | function Role:checkReturnerTask(notNotify, mainType, subType, param1, param2) |
| 839 | -- print("check returner task", mainType, subType, param1, param2) | 858 | -- print("check returner task", mainType, subType, param1, param2) |
| 840 | local returner = self:getProperty("returner") or {} | 859 | local returner = self:getProperty("returner") or {} |