Commit d763fb14d2fc4a7e0600002915f07e1a54aff6b8
1 parent
f0b81492
签到 九宫格
Showing
6 changed files
with
227 additions
and
6 deletions
Show diff stats
src/ProtocolCode.lua
@@ -180,6 +180,9 @@ actionCodes = { | @@ -180,6 +180,9 @@ actionCodes = { | ||
180 | Email_checkRpc = 603, | 180 | Email_checkRpc = 603, |
181 | Email_delRpc = 604, | 181 | Email_delRpc = 604, |
182 | 182 | ||
183 | + Activity_sudokuRpc = 650, | ||
184 | + Activity_signRpc = 651, | ||
185 | + Activity_sudokuRewardRpc = 652, | ||
183 | } | 186 | } |
184 | 187 | ||
185 | rpcResponseBegin = 10000 | 188 | rpcResponseBegin = 10000 |
@@ -0,0 +1,138 @@ | @@ -0,0 +1,138 @@ | ||
1 | +local ipairs = ipairs | ||
2 | +local table = table | ||
3 | +local math = math | ||
4 | +local string = string | ||
5 | +local redisproxy = redisproxy | ||
6 | +local MsgPack = MsgPack | ||
7 | +local string_format = string.format | ||
8 | +local tonumber = tonumber | ||
9 | +local table_insert = table.insert | ||
10 | +local table_unpack = table.unpack | ||
11 | +local table_find = table.find | ||
12 | +local table_nums = table.nums | ||
13 | +local math_random = math.randomInt | ||
14 | + | ||
15 | + | ||
16 | +local _M = {} | ||
17 | + | ||
18 | + | ||
19 | +function _M.sudokuRpc(agent, data) | ||
20 | + local role = agent.role | ||
21 | + local msg = MsgPack.unpack(data) | ||
22 | + local id = msg.id | ||
23 | + | ||
24 | + local sudoku = role:getProperty("sudoku") | ||
25 | + local phase = sudoku[-1] or 1 | ||
26 | + local curData = (csvdb["guide_sudokuCsv"][phase] or {})[id] | ||
27 | + if phase == -1 or not curData then return 1 end | ||
28 | + | ||
29 | + sudoku.task = sudoku.task or {} | ||
30 | + sudoku.task[phase] = sudoku.task[phase] or {} | ||
31 | + | ||
32 | + if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end | ||
33 | + | ||
34 | + sudoku.task[phase][id] = -1 | ||
35 | + local task = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励 | ||
36 | + | ||
37 | + local reward = {} | ||
38 | + local rId = {} | ||
39 | + for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do | ||
40 | + local pos = pdata.pos:toArray(true, "=") | ||
41 | + local ok, is = true, false | ||
42 | + for _, one in pairs(pos) do | ||
43 | + if one == id then | ||
44 | + is = true | ||
45 | + end | ||
46 | + if sudoku.task[phase][one] ~= -1 then | ||
47 | + ok = false | ||
48 | + break | ||
49 | + end | ||
50 | + end | ||
51 | + | ||
52 | + if ok and is then | ||
53 | + for itemId, count in pairs(pdata.reward:toNumMap()) do | ||
54 | + reward[itemId] = (reward[itemId] or 0) + count | ||
55 | + end | ||
56 | + table.insert(rId, pid) | ||
57 | + end | ||
58 | + end | ||
59 | + | ||
60 | + if not next(reward) then | ||
61 | + reward = nil | ||
62 | + else | ||
63 | + reward = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}}) | ||
64 | + end | ||
65 | + | ||
66 | + role:updateProperty({field = "sudoku", value = sudoku}) | ||
67 | + | ||
68 | + role:log("act_action", {desc = "sudoku", int1 = id, int2 = phase}) | ||
69 | + | ||
70 | + SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = task, reward = reward, rId = rId})) | ||
71 | + return true | ||
72 | +end | ||
73 | + | ||
74 | +function _M.sudokuRewardRpc(agent, data) | ||
75 | + local role = agent.role | ||
76 | + | ||
77 | + | ||
78 | + local sudoku = role:getProperty("sudoku") | ||
79 | + local phase = sudoku[-1] or 1 | ||
80 | + | ||
81 | + local curData = csvdb["guide_sudokuCsv"][phase] | ||
82 | + if not curData then return end | ||
83 | + if not globalCsv.guide_sudoku_reward[phase] then return end | ||
84 | + | ||
85 | + local curTask = (sudoku.task or {})[phase] or {} | ||
86 | + | ||
87 | + for id, _ in pairs(curData) do | ||
88 | + if curTask[id] ~= -1 then | ||
89 | + return | ||
90 | + end | ||
91 | + end | ||
92 | + | ||
93 | + local reward = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}}) | ||
94 | + | ||
95 | + sudoku[-1] = phase + 1 | ||
96 | + sudoku.task[phase] = nil | ||
97 | + if not csvdb["guide_sudokuCsv"][sudoku[-1]] then | ||
98 | + sudoku[-1] = -1 | ||
99 | + sudoku.task = nil | ||
100 | + end | ||
101 | + role:updateProperty({field = "sudoku", value = sudoku}) | ||
102 | + | ||
103 | + SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(reward)) | ||
104 | + return true | ||
105 | +end | ||
106 | + | ||
107 | + | ||
108 | +function _M.signRpc(agent, data) | ||
109 | + local role = agent.role | ||
110 | + | ||
111 | + local serverT = skynet.timex() | ||
112 | + local tm = os.date("*t", serverT) | ||
113 | + | ||
114 | + local curDay = tm.day | ||
115 | + | ||
116 | + local yearMonth = tm.year * 100 + tm.month | ||
117 | + local monthData = csvdb["daily_signInCsv"][yearMonth] | ||
118 | + if not monthData or not monthData[curDay] then | ||
119 | + return 1 | ||
120 | + end | ||
121 | + | ||
122 | + local signs = role:getProperty("sign") | ||
123 | + if signs[curDay] == yearMonth then -- 未重置的还可以签到正常(本月已经签到) | ||
124 | + return 2 | ||
125 | + end | ||
126 | + signs[curDay] = yearMonth | ||
127 | + | ||
128 | + local raward = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}}) | ||
129 | + role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) | ||
130 | + | ||
131 | + SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(raward)) | ||
132 | + return true | ||
133 | +end | ||
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | ||
138 | +return _M | ||
0 | \ No newline at end of file | 139 | \ No newline at end of file |
src/actions/DinerAction.lua
@@ -399,7 +399,7 @@ function _M.talentUpRpc( agent, data ) | @@ -399,7 +399,7 @@ function _M.talentUpRpc( agent, data ) | ||
399 | -- role:award(treePoint) | 399 | -- role:award(treePoint) |
400 | -- end | 400 | -- end |
401 | 401 | ||
402 | - role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1]}) | 402 | + role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1], level = dishLevel + 1}) |
403 | 403 | ||
404 | role:log("diner_action", {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}) | 404 | role:log("diner_action", {desc = "talentUp", int1 = dish, int2 = dishLevel + 1}) |
405 | 405 |
src/models/Role.lua
@@ -146,6 +146,8 @@ Role.schema = { | @@ -146,6 +146,8 @@ Role.schema = { | ||
146 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} | 146 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
147 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} | 147 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
148 | newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr | 148 | newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr |
149 | + | ||
150 | + sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 | ||
149 | } | 151 | } |
150 | 152 | ||
151 | 153 | ||
@@ -351,6 +353,8 @@ function Role:data() | @@ -351,6 +353,8 @@ function Role:data() | ||
351 | rmbC = self:getProperty("rmbC"), | 353 | rmbC = self:getProperty("rmbC"), |
352 | -- repayHero = self:getProperty("repayHero"), | 354 | -- repayHero = self:getProperty("repayHero"), |
353 | newerDraw = self:getProperty("newerDraw"), | 355 | newerDraw = self:getProperty("newerDraw"), |
356 | + | ||
357 | + sudoku = self:getProperty("sudoku"), | ||
354 | } | 358 | } |
355 | end | 359 | end |
356 | 360 |
src/models/RoleLog.lua
@@ -32,6 +32,7 @@ local LogType = { | @@ -32,6 +32,7 @@ local LogType = { | ||
32 | diner_action = "common", | 32 | diner_action = "common", |
33 | tower_action = "common", | 33 | tower_action = "common", |
34 | gm_action = "common", | 34 | gm_action = "common", |
35 | + act_action = "common", | ||
35 | } | 36 | } |
36 | 37 | ||
37 | -- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-* | 38 | -- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-* |
src/models/RoleTask.lua
@@ -59,11 +59,12 @@ local TaskType = { | @@ -59,11 +59,12 @@ local TaskType = { | ||
59 | FoodSellGold = 607, -- 贩卖获得齿轮 - count | 59 | FoodSellGold = 607, -- 贩卖获得齿轮 - count |
60 | DinerPopular = 608, -- 人气值 - count | 60 | DinerPopular = 608, -- 人气值 - count |
61 | DinerLevelUp = 609, -- 餐厅升级 - level type | 61 | DinerLevelUp = 609, -- 餐厅升级 - level type |
62 | - DinerTalentUp = 610, -- 天赋升级 - type | 62 | + DinerTalentUp = 610, -- 天赋升级 - type level |
63 | 63 | ||
64 | -- 车厢相关 | 64 | -- 车厢相关 |
65 | PotionMake = 701, -- 营养剂制作 - id count | 65 | PotionMake = 701, -- 营养剂制作 - id count |
66 | OpenBox = 702, -- 拆解时间箱 - id | 66 | OpenBox = 702, -- 拆解时间箱 - id |
67 | + SupportSkill = 703, -- 后勤支援技升级 - id level | ||
67 | 68 | ||
68 | 69 | ||
69 | -- pvp相关 | 70 | -- pvp相关 |
@@ -87,8 +88,8 @@ local TaskType = { | @@ -87,8 +88,8 @@ local TaskType = { | ||
87 | ShopAll = 1013, -- 在任意商店购买 | 88 | ShopAll = 1013, -- 在任意商店购买 |
88 | } | 89 | } |
89 | 90 | ||
90 | -local function f(field) | ||
91 | - return {type = "field", value = field} | 91 | +local function f(field, func) |
92 | + return {type = "field", value = field, func = func} | ||
92 | end | 93 | end |
93 | 94 | ||
94 | -- 剧情任务监听 | 95 | -- 剧情任务监听 |
@@ -183,11 +184,33 @@ local AchievListener = { | @@ -183,11 +184,33 @@ local AchievListener = { | ||
183 | } | 184 | } |
184 | } | 185 | } |
185 | 186 | ||
187 | +local SudokuListerer = { | ||
188 | + func = "checkSudokuTask", | ||
189 | + listen = { | ||
190 | + [TaskType.HangPass] = {{1, 1, f("id")}}, | ||
191 | + [TaskType.DrawHero] = {{4, f("count")}}, | ||
192 | + [TaskType.HeroLevelUp] = {{5, f("level")}}, | ||
193 | + [TaskType.Wake] = {{6, f("wakeL")}}, | ||
194 | + [TaskType.AddFriend] = {{7, f("count")}}, | ||
195 | + [TaskType.GetFriendP] = {{8, f("count")}}, | ||
196 | + [TaskType.AdvStart] = {{9, 1}}, | ||
197 | + [TaskType.AdvDraw] = {{10, f("count")}}, | ||
198 | + [TaskType.DinerLevelUp] = {{11, f("level"), f("type")}}, | ||
199 | + [TaskType.FoodSell] = {{12, f("count")}}, | ||
200 | + [TaskType.OpenBox] = {{13, 1}}, | ||
201 | + [TaskType.TowerPass] = {{14, f("level")}}, | ||
202 | + [TaskType.PvpWin] = {{15, 1}}, | ||
203 | + [TaskType.DinerTalentUp] = {{16, f("level"), f("type")}}, | ||
204 | + [TaskType.RuneUp] = {{17, 1}}, | ||
205 | + } | ||
206 | +} | ||
207 | + | ||
186 | 208 | ||
187 | local TaskListeners = { | 209 | local TaskListeners = { |
188 | StoryListener, | 210 | StoryListener, |
189 | CommonListener, | 211 | CommonListener, |
190 | AchievListener, | 212 | AchievListener, |
213 | + SudokuListerer, | ||
191 | } | 214 | } |
192 | 215 | ||
193 | local RoleTask = {} | 216 | local RoleTask = {} |
@@ -207,7 +230,11 @@ function RoleTask.bind(Role) | @@ -207,7 +230,11 @@ function RoleTask.bind(Role) | ||
207 | for __, v in ipairs(vs) do | 230 | for __, v in ipairs(vs) do |
208 | if type(v) == "table" and v.type then | 231 | if type(v) == "table" and v.type then |
209 | if v.type == "field" then | 232 | if v.type == "field" then |
210 | - table.insert(pms, params[v.value]) | 233 | + local value = params[v.value] |
234 | + if v.func then | ||
235 | + value = v.func(value) | ||
236 | + end | ||
237 | + table.insert(pms, value) | ||
211 | else | 238 | else |
212 | table.insert(pms, v) | 239 | table.insert(pms, v) |
213 | end | 240 | end |
@@ -333,7 +360,6 @@ function RoleTask.bind(Role) | @@ -333,7 +360,6 @@ function RoleTask.bind(Role) | ||
333 | local achiveStatus = self:getProperty("achiveT") | 360 | local achiveStatus = self:getProperty("achiveT") |
334 | 361 | ||
335 | local IsFindMax = { | 362 | local IsFindMax = { |
336 | - [1] = true, | ||
337 | [4] = true, | 363 | [4] = true, |
338 | [6] = true, | 364 | [6] = true, |
339 | [7] = true, | 365 | [7] = true, |
@@ -442,6 +468,55 @@ function RoleTask.bind(Role) | @@ -442,6 +468,55 @@ function RoleTask.bind(Role) | ||
442 | end | 468 | end |
443 | end | 469 | end |
444 | 470 | ||
471 | + -- 九宫格任务 | ||
472 | + function Role:checkSudokuTask(notNotify, stype, count, cond) | ||
473 | + local change = false | ||
474 | + local sudoku = self:getProperty("sudoku") | ||
475 | + | ||
476 | + local curPhase = sudoku[-1] or 1 | ||
477 | + if curPhase == -1 then return end | ||
478 | + | ||
479 | + local IsFindMax = { | ||
480 | + [5] = true, | ||
481 | + [6] = true, | ||
482 | + [7] = true, | ||
483 | + [11] = true, | ||
484 | + [14] = true, | ||
485 | + [16] = true, | ||
486 | + } | ||
487 | + | ||
488 | + sudoku.task = sudoku.task or {} | ||
489 | + local hangPass = self:getProperty("hangPass") | ||
490 | + for pause, guide_sudokuData in pairs(csvdb["guide_sudokuCsv"]) do | ||
491 | + if pause >= curPhase then | ||
492 | + sudoku.task[pause] = sudoku.task[pause] or {} | ||
493 | + for id , sudikuData in pairs(guide_sudokuData) do | ||
494 | + local curStatus = sudoku.task[pause][id] or 0 | ||
495 | + | ||
496 | + if curStatus ~= -1 and sudikuData.type == stype and (sudikuData.unlock == 0 or hangPass[sudikuData.unlock]) then | ||
497 | + if IsFindMax[sudikuData.type] then -- 最大值 | ||
498 | + if sudikuData.con2 == 0 or sudikuData.con2 == cond then | ||
499 | + if (count or 0) > curStatus then | ||
500 | + change = true | ||
501 | + sudoku.task[pause][id] = count | ||
502 | + end | ||
503 | + end | ||
504 | + else --通用增加 | ||
505 | + if sudikuData.con2 == 0 or sudikuData.con2 == cond then | ||
506 | + change = true | ||
507 | + sudoku.task[pause][id] = curStatus + (count or 1) | ||
508 | + end | ||
509 | + end | ||
510 | + end | ||
511 | + end | ||
512 | + end | ||
513 | + end | ||
514 | + | ||
515 | + if change then | ||
516 | + self:updateProperty({field = "sudoku", value = sudoku, notNotify = notNotify}) | ||
517 | + end | ||
518 | + end | ||
519 | + | ||
445 | end | 520 | end |
446 | 521 | ||
447 | return RoleTask | 522 | return RoleTask |
448 | \ No newline at end of file | 523 | \ No newline at end of file |