Commit 53e8037ecfe65008cdf1c093d842bb49caf23542
1 parent
0b9d9fba
任务
Showing
18 changed files
with
579 additions
and
127 deletions
Show diff stats
src/ProtocolCode.lua
... | ... | @@ -29,6 +29,9 @@ actionCodes = { |
29 | 29 | Role_storyBookRewardRpc = 114, |
30 | 30 | Role_unLockStoryBookRpc = 115, |
31 | 31 | Role_openTimeBoxRpc = 116, |
32 | + Role_taskRpc = 117, | |
33 | + Role_taskActiveRpc = 118, | |
34 | + Role_achiveRpc = 119, | |
32 | 35 | |
33 | 36 | Adv_startAdvRpc = 151, |
34 | 37 | Adv_startHangRpc = 152, |
... | ... | @@ -73,8 +76,8 @@ actionCodes = { |
73 | 76 | Hang_roleFormatRpc = 255, |
74 | 77 | Hang_getRewardRpc = 256, |
75 | 78 | Hang_quickRpc = 257, |
76 | - Hang_getRewardItemRpc = 258, | |
77 | - Hang_getRewardCoinRpc = 259, | |
79 | + -- Hang_getRewardItemRpc = 258, | |
80 | + -- Hang_getRewardCoinRpc = 259, | |
78 | 81 | |
79 | 82 | Diner_updateProperty = 300, |
80 | 83 | Diner_addSellRpc = 301, | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -112,7 +112,7 @@ function _M.startAdvRpc( agent, data ) |
112 | 112 | end |
113 | 113 | |
114 | 114 | role:getAdvData():initByChapter(chapterId, layer) |
115 | - | |
115 | + role:checkTaskEnter("AdvStart", {id = chapterId}) | |
116 | 116 | SendPacket(actionCodes.Adv_startAdvRpc, '') |
117 | 117 | return true |
118 | 118 | end |
... | ... | @@ -161,7 +161,7 @@ function _M.startHangRpc(agent, data) |
161 | 161 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
162 | 162 | |
163 | 163 | role.dailyData:updateProperty({field = "advC", delta = 1}) |
164 | - | |
164 | + role:checkTaskEnter("AdvStart", {id = chapterId}) | |
165 | 165 | SendPacket(actionCodes.Adv_startHangRpc, '') |
166 | 166 | return true |
167 | 167 | end |
... | ... | @@ -247,6 +247,7 @@ function _M.finishTaskRpc(agent, data) |
247 | 247 | end |
248 | 248 | adv:updateTask() |
249 | 249 | if not status then return end |
250 | + role:checkTaskEnter("AdvOverTask", {id = taskId}) | |
250 | 251 | SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack({reward = reward})) |
251 | 252 | return true |
252 | 253 | end | ... | ... |
src/actions/CarAction.lua
... | ... | @@ -38,6 +38,7 @@ function _M.makePotionRpc( agent, data ) |
38 | 38 | role:costItems(cost) |
39 | 39 | potionBag[potionId] = own + count |
40 | 40 | role:updateProperty({field = "potionBag", value = potionBag}) |
41 | + role:checkTaskEnter("PotionMake", {count = count, id = potionId}) | |
41 | 42 | SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag})) |
42 | 43 | return true |
43 | 44 | end |
... | ... | @@ -86,7 +87,7 @@ function _M.equipUpRpc( agent, data ) |
86 | 87 | role:costItems(cost) |
87 | 88 | role:addEquip(typ, lv, -costCount) |
88 | 89 | role:addEquip(typ, nextLv ,count) |
89 | - | |
90 | + role:checkTaskEnter("EquipUp", {}) | |
90 | 91 | SendPacket(actionCodes.Car_equipUpRpc, '') |
91 | 92 | return true |
92 | 93 | end |
... | ... | @@ -118,6 +119,7 @@ function _M.runeUpRpc( agent, data ) |
118 | 119 | |
119 | 120 | role:costItems(cost) |
120 | 121 | ownRune:updateProperty({field = "level",value = level+1}) |
122 | + role:checkTaskEnter("RuneUp") | |
121 | 123 | SendPacket(actionCodes.Car_runeUpRpc, '') |
122 | 124 | return true |
123 | 125 | end | ... | ... |
src/actions/DinerAction.lua
... | ... | @@ -155,6 +155,9 @@ function _M.getSellRewardRpc( agent, data ) |
155 | 155 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
156 | 156 | for k, v in pairs(reward:toNumMap()) do |
157 | 157 | role:addItem({itemId = k,count = v}) |
158 | + if k == ItemId.Gold then | |
159 | + role:checkTaskEnter("FoodSellGold", {count = v}) | |
160 | + end | |
158 | 161 | end |
159 | 162 | |
160 | 163 | role.dinerData:popularAdd(popular) |
... | ... | @@ -162,7 +165,6 @@ function _M.getSellRewardRpc( agent, data ) |
162 | 165 | if dirty then |
163 | 166 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) |
164 | 167 | end |
165 | - | |
166 | 168 | SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward})) |
167 | 169 | return true |
168 | 170 | end |
... | ... | @@ -226,6 +228,7 @@ function _M.expediteSellRpc( agent, data ) |
226 | 228 | if dirty then |
227 | 229 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) |
228 | 230 | end |
231 | + role:checkTaskEnter("FoodSellQuick") | |
229 | 232 | SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular})) |
230 | 233 | return true |
231 | 234 | end |
... | ... | @@ -263,7 +266,7 @@ function _M.levelUpRpc( agent, data ) |
263 | 266 | |
264 | 267 | role:costItems(cost) |
265 | 268 | role.dinerData:updateProperty({field = "buildL", value = buildL:setv(index, curLevel + 1)}) |
266 | - | |
269 | + role:checkTaskEnter("DinerLevelUp", {type = index, level = curLevel + 1}) | |
267 | 270 | SendPacket(actionCodes.Diner_levelUpRpc, '') |
268 | 271 | return true |
269 | 272 | end |
... | ... | @@ -337,6 +340,8 @@ function _M.talentUpRpc( agent, data ) |
337 | 340 | role:award(treePoint) |
338 | 341 | end |
339 | 342 | |
343 | + role:checkTaskEnter("DinerTalentUp", {type = talentData.effect:toArray(true,"=")[1]}) | |
344 | + | |
340 | 345 | SendPacket(actionCodes.Diner_talentUpRpc, '') |
341 | 346 | return true |
342 | 347 | end |
... | ... | @@ -431,6 +436,7 @@ function _M.updateTaskRpc( agent, data ) |
431 | 436 | end |
432 | 437 | orders[index].status = 1 |
433 | 438 | orders[index].lock = 1 |
439 | + role:checkTaskEnter("GetOderTask", {rarity = taskSet.rarity}) | |
434 | 440 | elseif cmd == 1 then |
435 | 441 | if order.status ~= 1 then |
436 | 442 | return 31 |
... | ... | @@ -448,6 +454,7 @@ function _M.updateTaskRpc( agent, data ) |
448 | 454 | role:addItem({itemId = typ, count = count}) |
449 | 455 | end |
450 | 456 | table.remove(orders,index) |
457 | + role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity}) | |
451 | 458 | else |
452 | 459 | return 33 |
453 | 460 | end |
... | ... | @@ -593,7 +600,7 @@ function _M.getGreenhouseRpc( agent, data ) |
593 | 600 | end |
594 | 601 | role.dinerData:updateProperty({field = "gfood", value = gfood}) |
595 | 602 | local reward = role:award(reward) |
596 | - | |
603 | + role:checkTaskEnter("FoodMGet") | |
597 | 604 | SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward})) |
598 | 605 | return true |
599 | 606 | end | ... | ... |
src/actions/GmAction.lua
src/actions/HangAction.lua
... | ... | @@ -139,6 +139,7 @@ function _M.startBattleRpc(agent, data) |
139 | 139 | hangInfo.key = key |
140 | 140 | local nowTime = skynet.timex() |
141 | 141 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
142 | + role:checkTaskEnter("HangBattle", {id = carbonId}) | |
142 | 143 | SendPacket(actionCodes.Hang_startBattleRpc, MsgPack.pack({key = key})) |
143 | 144 | return true |
144 | 145 | end |
... | ... | @@ -229,71 +230,73 @@ function _M.getRewardRpc(agent , data) |
229 | 230 | role:updateProperty({field = "hangBag", value = items}) |
230 | 231 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
231 | 232 | role:checkTaskEnter("HangGet") |
232 | - | |
233 | - SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ | |
234 | - reward = reward | |
235 | - })) | |
236 | - return true | |
237 | -end | |
238 | - | |
239 | -function _M.getRewardItemRpc(agent , data) | |
240 | - local role = agent.role | |
241 | - checkReward(role) | |
242 | - local items = role:getProperty("hangBag") | |
243 | - if not next(items) then return end | |
244 | - | |
245 | - local notNeed = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1} | |
246 | - local reward = {} | |
247 | - for itemId , count in pairs(items) do | |
248 | - if not notNeed[itemId] then | |
249 | - reward[itemId] = count | |
250 | - items[itemId] = nil | |
251 | - end | |
233 | + if reward[ItemId.Gold] then | |
234 | + role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) | |
252 | 235 | end |
253 | - if not next(reward) then return end | |
254 | - local reward = role:award(reward) | |
255 | - | |
256 | - local hangInfo = role:getProperty("hangInfo") | |
257 | - local nowTime = skynet.timex() | |
258 | - hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max | |
259 | - hangInfo.itemTime = nowTime | |
260 | - role:updateProperty({field = "hangBag", value = items}) | |
261 | - role:updateProperty({field = "hangInfo", value = hangInfo}) | |
262 | - | |
263 | - SendPacket(actionCodes.Hang_getRewardItemRpc, MsgPack.pack({ | |
236 | + SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ | |
264 | 237 | reward = reward |
265 | 238 | })) |
266 | 239 | return true |
267 | 240 | end |
268 | 241 | |
269 | -function _M.getRewardCoinRpc(agent , data) | |
270 | - local role = agent.role | |
271 | - checkReward(role) | |
272 | - local items = role:getProperty("hangBag") | |
273 | - if not next(items) then return end | |
274 | - | |
275 | - local need = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1} | |
276 | - local reward = {} | |
277 | - for itemId , count in pairs(items) do | |
278 | - if need[itemId] then | |
279 | - reward[itemId] = count | |
280 | - items[itemId] = nil | |
281 | - end | |
282 | - end | |
283 | - local reward = role:award(reward) | |
242 | +-- function _M.getRewardItemRpc(agent , data) | |
243 | +-- local role = agent.role | |
244 | +-- checkReward(role) | |
245 | +-- local items = role:getProperty("hangBag") | |
246 | +-- if not next(items) then return end | |
247 | + | |
248 | +-- local notNeed = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1} | |
249 | +-- local reward = {} | |
250 | +-- for itemId , count in pairs(items) do | |
251 | +-- if not notNeed[itemId] then | |
252 | +-- reward[itemId] = count | |
253 | +-- items[itemId] = nil | |
254 | +-- end | |
255 | +-- end | |
256 | +-- if not next(reward) then return end | |
257 | +-- local reward = role:award(reward) | |
258 | + | |
259 | +-- local hangInfo = role:getProperty("hangInfo") | |
260 | +-- local nowTime = skynet.timex() | |
261 | +-- hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max | |
262 | +-- hangInfo.itemTime = nowTime | |
263 | +-- role:updateProperty({field = "hangBag", value = items}) | |
264 | +-- role:updateProperty({field = "hangInfo", value = hangInfo}) | |
265 | + | |
266 | +-- SendPacket(actionCodes.Hang_getRewardItemRpc, MsgPack.pack({ | |
267 | +-- reward = reward | |
268 | +-- })) | |
269 | +-- return true | |
270 | +-- end | |
271 | + | |
272 | +-- function _M.getRewardCoinRpc(agent , data) | |
273 | +-- local role = agent.role | |
274 | +-- checkReward(role) | |
275 | +-- local items = role:getProperty("hangBag") | |
276 | +-- if not next(items) then return end | |
277 | + | |
278 | +-- local need = {[ItemId.Gold] = 1, [ItemId.Exp] = 1, [ItemId.PlayerExp] = 1} | |
279 | +-- local reward = {} | |
280 | +-- for itemId , count in pairs(items) do | |
281 | +-- if need[itemId] then | |
282 | +-- reward[itemId] = count | |
283 | +-- items[itemId] = nil | |
284 | +-- end | |
285 | +-- end | |
286 | +-- local reward = role:award(reward) | |
284 | 287 | |
285 | - local hangInfo = role:getProperty("hangInfo") | |
286 | - local nowTime = skynet.timex() | |
287 | - hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max | |
288 | - hangInfo.coinTime = nowTime | |
289 | - role:updateProperty({field = "hangBag", value = items}) | |
290 | - role:updateProperty({field = "hangInfo", value = hangInfo}) | |
291 | - | |
292 | - SendPacket(actionCodes.Hang_getRewardCoinRpc, MsgPack.pack({ | |
293 | - reward = reward | |
294 | - })) | |
295 | - return true | |
296 | -end | |
288 | +-- local hangInfo = role:getProperty("hangInfo") | |
289 | +-- local nowTime = skynet.timex() | |
290 | +-- hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max | |
291 | +-- hangInfo.coinTime = nowTime | |
292 | +-- role:updateProperty({field = "hangBag", value = items}) | |
293 | +-- role:updateProperty({field = "hangInfo", value = hangInfo}) | |
294 | + | |
295 | +-- SendPacket(actionCodes.Hang_getRewardCoinRpc, MsgPack.pack({ | |
296 | +-- reward = reward | |
297 | +-- })) | |
298 | +-- return true | |
299 | +-- end | |
297 | 300 | |
298 | 301 | function _M.quickRpc(agent , data) |
299 | 302 | local role = agent.role |
... | ... | @@ -330,7 +333,7 @@ function _M.quickRpc(agent , data) |
330 | 333 | end |
331 | 334 | |
332 | 335 | reward = role:award(reward) |
333 | - | |
336 | + role:checkTaskEnter("HangQuick") | |
334 | 337 | SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ |
335 | 338 | reward = reward |
336 | 339 | })) | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -30,6 +30,7 @@ function _M.levelUpRpc( agent, data ) |
30 | 30 | role:costItems(cost) |
31 | 31 | hero:updateProperty({field = "level", delta = 1}) |
32 | 32 | |
33 | + role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) | |
33 | 34 | SendPacket(actionCodes.Hero_levelUpRpc, '') |
34 | 35 | return true |
35 | 36 | end |
... | ... | @@ -87,8 +88,11 @@ function _M.wakeRpc(agent, data) |
87 | 88 | end |
88 | 89 | hero:updateProperty({field = "wakeL", delta = 1}) |
89 | 90 | |
90 | - role:checkTaskEnter("Wake", {heroType = typ, wakeL = hero:getProperty("wakeL")}) | |
91 | - | |
91 | + local curLevel = hero:getProperty("wakeL") | |
92 | + if curLevel == 4 then -- 解锁cg | |
93 | + role:checkTaskEnter("WakeCG", {heroType = typ}) | |
94 | + end | |
95 | + | |
92 | 96 | SendPacket(actionCodes.Hero_wakeRpc, '') |
93 | 97 | return true |
94 | 98 | end |
... | ... | @@ -154,6 +158,14 @@ function _M.talentRpc(agent, data) |
154 | 158 | end |
155 | 159 | end |
156 | 160 | hero:updateProperty({field = "talent", value = talent}) |
161 | + local aheadLevel = 0 | |
162 | + for i = 1, talent:getv(0, 1) - 1 do | |
163 | + aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i] | |
164 | + end | |
165 | + aheadLevel = aheadLevel + talent:getv(index, 0) | |
166 | + | |
167 | + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel}) | |
168 | + | |
157 | 169 | SendPacket(actionCodes.Hero_talentRpc, '') |
158 | 170 | return true |
159 | 171 | end |
... | ... | @@ -766,6 +778,7 @@ function _M.drawHeroRpc(agent, data) |
766 | 778 | |
767 | 779 | role:costItems(cost) |
768 | 780 | |
781 | + local ssrCount = 0 | |
769 | 782 | local reward = {} |
770 | 783 | for i = 1, drawCount[drawType] do |
771 | 784 | |
... | ... | @@ -779,6 +792,11 @@ function _M.drawHeroRpc(agent, data) |
779 | 792 | local idx = math.randWeight(resultPool, 3) |
780 | 793 | local temp = resultPool[idx] |
781 | 794 | local itemData = csvdb["itemCsv"][temp[1]] |
795 | + | |
796 | + if itemData.type == ItemType.Hero and itemData.quality == 4 then | |
797 | + ssrCount = ssrCount + 1 | |
798 | + end | |
799 | + | |
782 | 800 | if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then |
783 | 801 | local fragId = itemData.id - ItemStartId.Hero |
784 | 802 | local heroData = csvdb["unitCsv"][fragId] |
... | ... | @@ -791,6 +809,10 @@ function _M.drawHeroRpc(agent, data) |
791 | 809 | end |
792 | 810 | end |
793 | 811 | |
812 | + role:checkTaskEnter("DrawHero", {pool = pool, count = drawCount[drawType]}) | |
813 | + if ssrCount > 0 then | |
814 | + role:checkTaskEnter("DrawSSR", {count = ssrCount}) | |
815 | + end | |
794 | 816 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
795 | 817 | return true |
796 | 818 | end | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -284,17 +284,21 @@ function _M.saleItemRpc(agent, data) |
284 | 284 | if not backs then return end |
285 | 285 | |
286 | 286 | local reward = {} |
287 | + local fragCount = 0 | |
287 | 288 | for itemId, count in pairs(backs) do |
288 | 289 | if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end |
289 | 290 | local itemData = csvdb["itemCsv"][itemId] |
290 | 291 | if itemData.sell_effect == "" then return end |
292 | + if itemData.type == ItemType.HeroFragment or itemData.type == ItemType.HeroFCommon then | |
293 | + fragCount = fragCount + count | |
294 | + end | |
291 | 295 | local sellEffect = itemData.sell_effect:toArray(true, "=") |
292 | 296 | reward[sellEffect[1]] = (reward[sellEffect[1]] or 0) + sellEffect[2] * count |
293 | 297 | end |
294 | 298 | |
295 | 299 | role:costItems(backs) |
296 | 300 | local reward = role:award(reward) |
297 | - | |
301 | + role:checkTaskEnter("DecoFrag", {count = fragCount}) | |
298 | 302 | SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack({reward = reward})) |
299 | 303 | return true |
300 | 304 | end |
... | ... | @@ -405,6 +409,7 @@ function _M.openTimeBoxRpc(agent, data) |
405 | 409 | |
406 | 410 | boxL[slot] = nil |
407 | 411 | reward = role:award(reward) |
412 | + role:checkTaskEnter("OpenBox") | |
408 | 413 | else |
409 | 414 | return |
410 | 415 | end |
... | ... | @@ -459,5 +464,92 @@ function _M.unLockStoryBookRpc(agent, data) |
459 | 464 | return true |
460 | 465 | end |
461 | 466 | |
467 | +function _M.taskRpc(agent, data) | |
468 | + local role = agent.role | |
469 | + local msg = MsgPack.unpack(data) | |
470 | + local taskType = msg.type -- 1 日常 2 周长 | |
471 | + local taskId = msg.id --任务id | |
472 | + local roleField = {"dTask", "wTask"} | |
473 | + if not roleField[taskType] then return 1 end | |
474 | + | |
475 | + local taskData = csvdb["task_loopCsv"][taskType][taskId] | |
476 | + if not taskData then return 2 end | |
477 | + | |
478 | + local taskStatus = role:getProperty(roleField[taskType]) | |
479 | + local tStatus = taskStatus["t"] or {} | |
480 | + | |
481 | + if (tStatus[taskId] or 0) < taskData.condition1 then | |
482 | + return 3 | |
483 | + end | |
484 | + | |
485 | + local reward = role:award(taskData.reward) | |
486 | + local active = (taskStatus["a"] or 0) + taskData.active | |
487 | + | |
488 | + role:changeUpdates({ | |
489 | + { type = roleField[taskType], field = {"t", taskId}, value = -1 }, | |
490 | + { type = roleField[taskType], field = "a", value = active} | |
491 | + }) | |
492 | + | |
493 | + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack({reward = reward})) | |
494 | + return true | |
495 | +end | |
496 | + | |
497 | +function _M.taskActiveRpc(agent, data) | |
498 | + local role = agent.role | |
499 | + local msg = MsgPack.unpack(data) | |
500 | + local taskType = msg.type -- 1 日常 2 周长 | |
501 | + local taskId = msg.id --任务id | |
502 | + local roleField = {"dTask", "wTask"} | |
503 | + if not roleField[taskType] then return end | |
504 | + | |
505 | + local taskData = csvdb["task_activeCsv"][taskType][taskId] | |
506 | + if not taskData then return end | |
507 | + | |
508 | + local taskStatus = role:getProperty(roleField[taskType]) | |
509 | + local tStatus = taskStatus["at"] or {} | |
510 | + | |
511 | + if tStatus[taskId] == -1 or (taskStatus["a"] or 0) < taskData.active then | |
512 | + return | |
513 | + end | |
514 | + | |
515 | + local reward = role:award(taskData.reward) | |
516 | + role:changeUpdates({ | |
517 | + { type = roleField[taskType], field = {"at", taskId}, value = -1 } | |
518 | + }) | |
519 | + | |
520 | + SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack({reward = reward})) | |
521 | + return true | |
522 | +end | |
523 | + | |
524 | +function _M.achiveRpc(agent, data) | |
525 | + local role = agent.role | |
526 | + local msg = MsgPack.unpack(data) | |
527 | + local taskId = msg.id --任务id | |
528 | + | |
529 | + local achiveTask = csvdb["achievementCsv"][taskId] | |
530 | + if not achiveTask then return end | |
531 | + | |
532 | + local achiveT = role:getProperty("achiveT") | |
533 | + local achiveV = role:getProperty("achiveV") | |
534 | + | |
535 | + if achiveV[taskId] == -1 then return end | |
536 | + | |
537 | + local curStatus = achiveT[achiveTask.type] or 0 | |
538 | + local maxc = achiveTask.condition1 | |
539 | + | |
540 | + if maxc > curStatus then | |
541 | + return | |
542 | + end | |
543 | + | |
544 | + local reward = role:award(achiveTask.reward) | |
545 | + | |
546 | + role:changeUpdates({ | |
547 | + { type = "achiveV", field = taskId, value = -1 } | |
548 | + }) | |
549 | + | |
550 | + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack({reward = reward})) | |
551 | + return true | |
552 | +end | |
553 | + | |
462 | 554 | |
463 | 555 | return _M |
464 | 556 | \ No newline at end of file | ... | ... |
src/actions/TowerAction.lua
... | ... | @@ -63,7 +63,7 @@ function _M.startBattleRpc(agent, data) |
63 | 63 | towerInfo.k = key |
64 | 64 | |
65 | 65 | role:updateProperty({field = "towerInfo", value = towerInfo}) |
66 | - | |
66 | + role:checkTaskEnter("TowerBattle", {level = towerInfo.l}) | |
67 | 67 | SendPacket(actionCodes.Tower_startBattleRpc, '') |
68 | 68 | return true |
69 | 69 | end |
... | ... | @@ -91,6 +91,7 @@ function _M.endBattleRpc(agent, data) |
91 | 91 | |
92 | 92 | towerInfo.l = towerInfo.l + 1 |
93 | 93 | reward = role:award(curTower.reward) |
94 | + role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) | |
94 | 95 | end |
95 | 96 | |
96 | 97 | towerInfo.c = curCount | ... | ... |
src/adv/Adv.lua
... | ... | @@ -162,24 +162,31 @@ end |
162 | 162 | |
163 | 163 | |
164 | 164 | --关卡通关,非层 score < 0 失败 |
165 | -function Adv:over(success) | |
165 | +function Adv:over(success, isAllPass) | |
166 | 166 | local score = self:getScore() |
167 | 167 | local scoreInfo = self.score |
168 | 168 | local reward |
169 | 169 | if success then |
170 | 170 | reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap()) |
171 | - self.owner:checkTaskEnter("AdvPass", {id = self.chapterId}) | |
171 | + self.owner:checkTaskEnter("AdvPass", {id = self.chapterId, level = self.level, score = score}) | |
172 | + if isAllPass then | |
173 | + self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId}) | |
174 | + end | |
172 | 175 | |
173 | 176 | -- 冒险队等级升一下子 |
174 | 177 | local advL = self.owner:getProperty("advL") |
178 | + local oldL = advL[1] | |
175 | 179 | advL[2] = (advL[2] or 0) + 1 |
176 | 180 | for level = ((advL[1] or 0) + 1), #csvdb["adv_rankCsv"] do |
177 | 181 | local ldata = csvdb["adv_rankCsv"][level] |
178 | - if ldata.unlock >= advL[2] then | |
182 | + if ldata.unlock <= advL[2] then | |
179 | 183 | advL[1] = level |
180 | 184 | self.owner:award(ldata.reward) |
181 | 185 | end |
182 | 186 | end |
187 | + if advL[1] > oldL then | |
188 | + self.owner:checkTaskEnter("AdvLevel", {level = advL[1]}) | |
189 | + end | |
183 | 190 | self.owner:updateProperty("advL", advL) |
184 | 191 | |
185 | 192 | if self.owner:isFuncOpen(FuncOpenType.AdvWheelSurf) then |
... | ... | @@ -434,7 +441,7 @@ local function clickOut(self, room, block, params) |
434 | 441 | self:checkAchievement(Adv.AchievType.OverWin, 1, self.level) |
435 | 442 | local levellimit = csvdb["adv_chapterCsv"][self.chapterId].limitlevel |
436 | 443 | if params.relay or (not AdvCommon.isEndless(self.chapterId) and (self.level >= levellimit or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1))) then --关卡结束 |
437 | - self:over(true) | |
444 | + self:over(true, not AdvCommon.isEndless(self.chapterId) and self.level >= levellimit) | |
438 | 445 | else |
439 | 446 | self:initByChapter(self.chapterId, self.level + 1, true, true) |
440 | 447 | self:backNext() --下一关 |
... | ... | @@ -485,9 +492,9 @@ local function chooseCommon(self, room, block, chooseData, choose) |
485 | 492 | end |
486 | 493 | return true |
487 | 494 | end, |
488 | - --制定属性 > | |
495 | + --制定属性 | |
489 | 496 | [4] = function() |
490 | - if (self.battle.player[AttsEnumEx[cond[2]]] or 0) > cond[3] then | |
497 | + if (self.battle.player[AttsEnumEx[cond[2]]] or 0) >= cond[3] then | |
491 | 498 | return true |
492 | 499 | end |
493 | 500 | end, |
... | ... | @@ -497,6 +504,12 @@ local function chooseCommon(self, room, block, chooseData, choose) |
497 | 504 | return true |
498 | 505 | end |
499 | 506 | end, |
507 | + -- sp 到达指定值 | |
508 | + [6] = function() | |
509 | + if self.battle.player.sp >= cond[2] then | |
510 | + return true | |
511 | + end | |
512 | + end, | |
500 | 513 | } |
501 | 514 | assert(not cond[1] or checkCond[cond[1]], "error cond, event_[link]chooseCsv id :" .. block.event.id) |
502 | 515 | |
... | ... | @@ -788,6 +801,7 @@ function Adv:usePotion(potionId, potionLevel, target) |
788 | 801 | end |
789 | 802 | self:afterRound() |
790 | 803 | self:saveDB() |
804 | + self.owner:checkTaskEnter("AdvUsePotion") | |
791 | 805 | return true |
792 | 806 | end |
793 | 807 | ... | ... |
src/adv/AdvBattle.lua
... | ... | @@ -197,6 +197,8 @@ function Battle:battleBegin(roomId, blockId, params) |
197 | 197 | if player.hp > 0 then |
198 | 198 | enemy:hurt(enemy.hp, self.player, {hurtType = 5}) |
199 | 199 | self.player:effectBattleBuff() |
200 | + | |
201 | + self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) | |
200 | 202 | end |
201 | 203 | if player.hp > self.player.hp then |
202 | 204 | self.player:recover(player.hp - self.player.hp, player) | ... | ... |
src/adv/AdvBlock.lua
src/adv/AdvBuff.lua
... | ... | @@ -20,6 +20,7 @@ Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) |
20 | 20 | Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff |
21 | 21 | Buff.CHANGE_DROP = 18 -- 转换掉落 |
22 | 22 | Buff.BATTLE_PASSIVE = 19 -- 切换为战斗中的被动技 |
23 | +Buff.EXP_ADD = 20 -- 增加exp(每回合) | |
23 | 24 | |
24 | 25 | --角色一些属性的变化 |
25 | 26 | local function commonAttr(_Buff, attrName) |
... | ... | @@ -59,7 +60,7 @@ local BuffFactory = { |
59 | 60 | if value > 0 then |
60 | 61 | self.owner:recover(value, self.release) |
61 | 62 | elseif value < 0 then |
62 | - self.owner:hurt(-value, self.release, {hurtType = 2, buffId = self.id}) | |
63 | + self.owner:hurt(-value, self.release, {hurtType = self.buffData.effectValue5 == "1" and 6 or 2, buffId = self.id}) | |
63 | 64 | end |
64 | 65 | end |
65 | 66 | _Buff._effectValue = function(self) |
... | ... | @@ -193,6 +194,7 @@ local BuffFactory = { |
193 | 194 | return self.buffData.effectValue2, self.buffData.effectValue1 |
194 | 195 | end |
195 | 196 | end, |
197 | + | |
196 | 198 | [Buff.HP_CHANGE_NOW] = function(_Buff) |
197 | 199 | _Buff._init = function(self, data) --初始化变化值 |
198 | 200 | self._changeV = 0 |
... | ... | @@ -215,7 +217,7 @@ local BuffFactory = { |
215 | 217 | if value > 0 then |
216 | 218 | self.owner:recover(value, self.release) |
217 | 219 | elseif value < 0 then |
218 | - self.owner:hurt(-value, self.release, {hurtType = 2, buffId = self.id}) | |
220 | + self.owner:hurt(-value, self.release, {hurtType = self.buffData.effectValue5 == "1" and 6 or 2, buffId = self.id}) | |
219 | 221 | end |
220 | 222 | end |
221 | 223 | _Buff._effectValue = function(self) |
... | ... | @@ -225,6 +227,17 @@ local BuffFactory = { |
225 | 227 | return {cv = self._changeV} |
226 | 228 | end |
227 | 229 | end, |
230 | + | |
231 | + [Buff.EXP_ADD] = function(_Buff) | |
232 | + --cType 0 or nil 值 1 百分比 | |
233 | + _Buff._afterRound = function(self) | |
234 | + local value = self:effect() | |
235 | + self.owner.battle.player:addExp(value) | |
236 | + end | |
237 | + _Buff._effectValue = function(self) | |
238 | + return self.buffData.effectValue1 | |
239 | + end | |
240 | + end, | |
228 | 241 | } |
229 | 242 | |
230 | 243 | function Buff:ctor(owner, id) | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -224,7 +224,7 @@ function BaseObject:getInjuredValue(value) |
224 | 224 | end |
225 | 225 | |
226 | 226 | --最终伤害 = [ (敌方攻击 - 己方防御) * (1+伤害增加百分比-伤害减少百分比)*(1+受伤增加百分比-受伤减少百分比)+(伤害增加固定值-伤害增加固定值+受伤增加固定值-受伤增加固定值)]*(1+侍宠百分比)-侍宠固定值 |
227 | --- params -- hurtType 1 普攻伤害 2 buff伤害 3 反弹伤害 4 真实伤害 5 客户端发回来的伤害 --直接作用 | |
227 | +-- params -- hurtType 1 普攻伤害 2 buff伤害 3 反弹伤害 4 真实伤害 5 客户端发回来的伤害 --直接作用 6 buff伤害(真实) | |
228 | 228 | --进入这个方法之前计算好释放者加成的伤害 |
229 | 229 | function BaseObject:hurt(value, releaser, params) |
230 | 230 | params = params or {} |
... | ... | @@ -245,7 +245,7 @@ function BaseObject:hurt(value, releaser, params) |
245 | 245 | team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser}) |
246 | 246 | end |
247 | 247 | end |
248 | - if params.hurtType ~= 5 then | |
248 | + if params.hurtType ~= 5 and params.hurtType ~= 6 then | |
249 | 249 | if not params.hurtType or params.hurtType ~= 4 then |
250 | 250 | value = self:getInjuredValue(value) --减伤计算 |
251 | 251 | end |
... | ... | @@ -308,7 +308,7 @@ function BaseObject:hurt(value, releaser, params) |
308 | 308 | team:triggerPassive(Passive.TEAM_DEAD) |
309 | 309 | end |
310 | 310 | |
311 | - if params.hurtType == 2 and self ~= self.battle.player then | |
311 | + if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then | |
312 | 312 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.KillByBuff, 1, params.buffId) |
313 | 313 | end |
314 | 314 | |
... | ... | @@ -350,7 +350,7 @@ function BaseObject:releaseSkill(skillId, target) |
350 | 350 | end |
351 | 351 | |
352 | 352 | --0 全部 1 我方 2 敌方 |
353 | -function BaseObject:getTeam(nType, noSelf, mapIdx) | |
353 | +function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock) | |
354 | 354 | mapIdx = mapIdx or self.battle.adv:getCurMapIdx() |
355 | 355 | nType = nType or 0 |
356 | 356 | local team = {} |
... | ... | @@ -364,7 +364,7 @@ function BaseObject:getTeam(nType, noSelf, mapIdx) |
364 | 364 | local function addEnemy() |
365 | 365 | for _, enemy in pairs(self.battle.enemys[mapIdx]) do |
366 | 366 | if not noSelf or enemy ~= self then |
367 | - if not enemy.isDead and not enemy.lock then -- 已经翻开的 | |
367 | + if not enemy.isDead and (includeLock or not enemy.lock) then -- 已经翻开的 | |
368 | 368 | table.insert(team, enemy) |
369 | 369 | end |
370 | 370 | end | ... | ... |
src/models/Diner.lua
... | ... | @@ -178,6 +178,7 @@ function Diner:updateSell(slot, calOnly) |
178 | 178 | self:checkDinerTask(DinerTask.SellDish, deltaCount, sell.dish) |
179 | 179 | self:checkDinerTask(DinerTask.SellDishType, deltaCount, math.ceil(sell.dish / 100)) |
180 | 180 | self:checkDinerTask(DinerTask.SellDishRare, deltaCount, dishData.rarity) |
181 | + self.owner:checkTaskEnter("FoodSell", {count = deltaCount}) | |
181 | 182 | end |
182 | 183 | return { |
183 | 184 | deltaCount = deltaCount, |
... | ... | @@ -250,6 +251,7 @@ function Diner:popularAdd(popular) |
250 | 251 | local roleId = self.owner:getProperty("id") |
251 | 252 | -- 更新排行榜 |
252 | 253 | local curPopular = self:getProperty("popular") |
254 | + self.owner:checkTaskEnter("DinerPopular", {count = curPopular}) | |
253 | 255 | redisproxy:pipelining(function (red) |
254 | 256 | red:zadd(dbKey, curPopular, roleId) --更新分数 |
255 | 257 | red:hset(RANK_DINER_INFO, roleId, MsgPack.pack({ | ... | ... |
src/models/Role.lua
... | ... | @@ -75,7 +75,13 @@ Role.schema = { |
75 | 75 | towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} |
76 | 76 | towerF = {"table", {}}, -- 爬塔阵容 |
77 | 77 | |
78 | - spTask = {"table", {}} -- 特殊任务 -- {id = status} | |
78 | + spTask = {"table", {}}, -- 特殊任务 -- {id = status} | |
79 | + | |
80 | + dTask = {"table", {}}, -- 每日任务 {t = {id = status}, a = 0, at = {id = status}} t 任务完成情况 a 获得的活跃数值 at 活跃任务完成情况 | |
81 | + wTask = {"table", {}}, -- 每周任务 {t = {id = status}, a = 0, at = {id = status}} t 任务完成情况 a 获得的活跃数值 at 活跃任务完成情况 | |
82 | + | |
83 | + achiveT = {"table", {}}, -- 成就计数统计 achivement_type {id = status} | |
84 | + achiveV = {"table", {}}, -- 成就领奖统计 achivement {id = status} | |
79 | 85 | } |
80 | 86 | |
81 | 87 | |
... | ... | @@ -213,7 +219,10 @@ function Role:data() |
213 | 219 | towerInfo = self:getProperty("towerInfo"), |
214 | 220 | towerF = self:getProperty("towerF"), |
215 | 221 | spTask = self:getProperty("spTask"), |
216 | - | |
222 | + dTask = self:getProperty("dTask"), | |
223 | + wTask = self:getProperty("wTask"), | |
224 | + achiveT = self:getProperty("achiveT"), | |
225 | + achiveV = self:getProperty("achiveV"), | |
217 | 226 | } |
218 | 227 | end |
219 | 228 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -27,15 +27,24 @@ function RolePlugin.bind(Role) |
27 | 27 | |
28 | 28 | self.dailyData:refreshDailyData(notify) |
29 | 29 | self.dinerData:refreshDailyData(notify) |
30 | + self:setProperty("dTask", {}) | |
31 | + response.dTask = {} | |
32 | + | |
33 | + | |
34 | + if isCrossWeek(ltime, now) then | |
35 | + self:setProperty("wTask", {}) | |
36 | + response.wTask = {} | |
37 | + end | |
30 | 38 | |
31 | 39 | if notify then |
32 | 40 | self:notifyUpdateProperties(response) |
33 | 41 | end |
34 | - | |
42 | + | |
35 | 43 | if RESET_TIME == RESET_RANK_TIME then |
36 | 44 | self:onResetRank_raw(ltime, now, notify) |
37 | 45 | end |
38 | 46 | self:setProperty("ltime", now) |
47 | + | |
39 | 48 | return true |
40 | 49 | end |
41 | 50 | end |
... | ... | @@ -114,12 +123,13 @@ function RolePlugin.bind(Role) |
114 | 123 | local typ = math.floor((itemId-7000)/100) |
115 | 124 | local lv = (itemId-7000)%100 |
116 | 125 | self:addEquip(typ, lv, count ,pms) |
117 | - self:checkTaskEnter("AddEquip", {equipId = itemId}, pms.notNotify) | |
126 | + local equipCsv = (csvdb["equipCsv"][typ] or {})[lv] | |
127 | + self:checkTaskEnter("AddEquip", {equipId = itemId, rarity = equipCsv.rarity}, pms.notNotify) | |
118 | 128 | end, |
119 | 129 | [ItemType.Rune] = function() |
120 | 130 | local typ = math.floor((itemId-2000)/100) |
121 | 131 | for _= 1, count do |
122 | - self:addRune({type = typ,id = itemId}) | |
132 | + self:addRune({type = typ,id = itemId, pms.notNotify}) | |
123 | 133 | end |
124 | 134 | end, |
125 | 135 | [ItemType.AdvItem] = function() --冒险道具不会进入 玩家仓库 |
... | ... | @@ -323,7 +333,8 @@ function RolePlugin.bind(Role) |
323 | 333 | local roleId = self:getProperty("id") |
324 | 334 | local heroType = params.type |
325 | 335 | if self:isHaveHero(heroType) then return end |
326 | - if not csvdb["unitCsv"][heroType] then return false end | |
336 | + local unitData = csvdb["unitCsv"][heroType] | |
337 | + if not unitData then return false end | |
327 | 338 | |
328 | 339 | local heroId = tonum(redisproxy:hincrby(string.format(R_INCR, roleId), "hero", 1)) |
329 | 340 | |
... | ... | @@ -341,7 +352,7 @@ function RolePlugin.bind(Role) |
341 | 352 | newHero.owner = self |
342 | 353 | newHero:saveBattleValue() |
343 | 354 | self.heros[heroId] = newHero |
344 | - self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL")}, params.notNotify) | |
355 | + self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) | |
345 | 356 | if not params.notNotify then |
346 | 357 | local heroResponse = {} |
347 | 358 | table.insert(heroResponse, newHero:data()) |
... | ... | @@ -498,6 +509,7 @@ function RolePlugin.bind(Role) |
498 | 509 | table.insert(response, newRune:data()) |
499 | 510 | SendPacket(actionCodes.Role_loadRunes, MsgPack.pack(response)) |
500 | 511 | end |
512 | + self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = set.rarity}, params.notNotify) | |
501 | 513 | return 0 |
502 | 514 | else |
503 | 515 | return 1 | ... | ... |
src/models/RoleTask.lua
... | ... | @@ -2,20 +2,79 @@ |
2 | 2 | |
3 | 3 | -- 增加 checkTaskEnter 内的参数 记得增加注释 |
4 | 4 | local TaskType = { |
5 | - HangPass = 1, -- 挂机通关 - id | |
6 | - AdvPass = 2, -- 冒险通过关 - id | |
5 | + -- hero 相关 | |
6 | + DrawHero = 1, -- 招募 - pool count | |
7 | + AddHero = 2, -- 增加角色 - heroType wakeL camp job | |
7 | 8 | LoveBreak = 3, -- 好感度进阶 - heroType loveL |
8 | 9 | Wake = 4, -- 觉醒 - heroType wakeL |
9 | - AddHero = 5, -- 增加角色 - heroType wakeL | |
10 | - AddEquip = 6, -- 获得装备 - equipId | |
11 | - DecoRune = 7, -- 分解符文 - count | |
12 | - SaleEquip = 8, -- 出售装备 - count | |
13 | - MakeFood = 9, -- 制作料理 - id count | |
14 | - HangGet = 10, -- 挂机收货 | |
15 | - FoodMGet = 11, -- 食材获取 | |
16 | - | |
17 | - --todo | |
18 | - PvpWin = 100, -- pvp胜利 | |
10 | + HeroLevelUp = 5, -- 角色升级 - level | |
11 | + DecoFrag = 6, -- 碎片分解 - count | |
12 | + WakeCG = 7, -- 觉醒到解锁CG - heroType | |
13 | + HeroTalent = 8, -- 天赋升级 - heroType alv | |
14 | + DrawSSR = 9, -- 抽到SSR - count | |
15 | + | |
16 | + --装备相关 | |
17 | + AddEquip = 101, -- 获得装备 - equipId rarity | |
18 | + SaleEquip = 102, -- 出售装备 - count | |
19 | + EquipUp = 103, -- 装备强化 | |
20 | + | |
21 | + -- 符文(零件)相关 | |
22 | + RuneUp = 201, -- 符文强化 | |
23 | + DecoRune = 202, -- 分解符文 - count | |
24 | + AddRune = 203, -- 分解符文 - id type rarity | |
25 | + | |
26 | + | |
27 | + -- 挂机相关 | |
28 | + HangPass = 301, -- 挂机通关 - id | |
29 | + HangGet = 302, -- 挂机收货 | |
30 | + HangQuick = 303, -- 快速挂机 | |
31 | + HangBattle = 304, -- 挂机战斗 - id | |
32 | + HangGetGold = 305, -- 挂机获得齿轮 - count | |
33 | + | |
34 | + -- 冒险相关 | |
35 | + AdvPass = 401, -- 冒险通过关 - id level score | |
36 | + AdvStart = 402, -- 冒险开始(包括挂机) - id | |
37 | + AdvBattleWin = 403, -- 冒险内战斗胜利 - id | |
38 | + AdvAllPass = 404, -- 冒险章节通关 - id | |
39 | + AdvLevel = 405, -- 探险者协会升级 - level | |
40 | + AdvOverTask = 406, -- 完成任务 - id | |
41 | + AdvOpenBlock = 407, -- 打开地块 - id | |
42 | + AdvUsePotion = 408, -- 使用营养剂 | |
43 | + | |
44 | + --爬塔相关 | |
45 | + TowerPass = 501, -- 爬塔通关 - level | |
46 | + TowerBattle = 502, -- 爬塔战斗 - level | |
47 | + | |
48 | + -- 餐厅相关 | |
49 | + FoodMGet = 601, -- 食材获取 | |
50 | + MakeFood = 602, -- 制作料理 - id count | |
51 | + GetOderTask = 603, -- 接受餐厅订单 - rarity | |
52 | + OverOderTask = 604, -- 完成特别订单 - rarity | |
53 | + FoodSell = 605, -- 料理贩卖 - count | |
54 | + FoodSellQuick = 606, -- 料理快速贩卖 | |
55 | + FoodSellGold = 607, -- 贩卖获得齿轮 - count | |
56 | + DinerPopular = 608, -- 人气值 - count | |
57 | + DinerLevelUp = 609, -- 餐厅升级 - level type | |
58 | + DinerTalentUp = 610, -- 天赋升级 - type | |
59 | + | |
60 | + -- 车厢相关 | |
61 | + PotionMake = 701, -- 营养剂制作 - id count | |
62 | + OpenBox = 702, -- 拆解时间箱 | |
63 | + | |
64 | + | |
65 | + --功能未实现 todo | |
66 | + PvpWin = 1000, -- pvp胜利 - score | |
67 | + PvpBattle = 1001, -- pvp挑战 | |
68 | + AdvShop = 1002, -- 冒险商城 | |
69 | + GiveFriendP = 1003, -- 赠送友情点 | |
70 | + UnionBoss = 1004, -- 工会boss | |
71 | + UnionBattle = 1005, -- 工会战 | |
72 | + AddUnion = 1006, -- 加入一个公会 | |
73 | + AddFriend = 1007, -- 加入一个好友 - count | |
74 | + BindPhone = 1008, -- 绑定手机 | |
75 | + WeChat = 1009, -- 关注微信 | |
76 | + WeBlog = 1010, -- 关注微博 | |
77 | + SignIn = 1011, -- 签到 | |
19 | 78 | } |
20 | 79 | |
21 | 80 | local function v(value) |
... | ... | @@ -26,19 +85,95 @@ local function f(field) |
26 | 85 | return {type = "field", value = field} |
27 | 86 | end |
28 | 87 | |
88 | +-- 剧情任务监听 | |
29 | 89 | local StoryListener = { |
30 | 90 | func = "checkStoryStatus", |
31 | 91 | listen = { |
32 | - [TaskType.HangPass] = {v(1), f("id")}, | |
33 | - [TaskType.AdvPass] = {v(4), f("id")}, | |
34 | - [TaskType.LoveBreak] = {v(2), f("heroType")}, | |
35 | - [TaskType.Wake] = {v(3), f("heroType"), f("wakeL")}, | |
36 | - [TaskType.AddHero] = {v(3), f("heroType"), f("wakeL")}, | |
92 | + [TaskType.HangPass] = {{v(1), f("id")}}, | |
93 | + [TaskType.AdvPass] = {{v(4), f("id")}}, | |
94 | + [TaskType.LoveBreak] = {{v(2), f("heroType")}}, | |
95 | + [TaskType.Wake] = {{v(3), f("heroType"), f("wakeL")}}, | |
96 | + [TaskType.AddHero] = {{v(3), f("heroType"), f("wakeL")}}, | |
97 | + } | |
98 | +} | |
99 | + | |
100 | +-- 通用任务监听 | |
101 | +local CommonListener = { | |
102 | + func = "checkCommonTasks", | |
103 | + listen = { | |
104 | + [TaskType.HangGet] = {{v(1)}}, | |
105 | + [TaskType.HangQuick] = {{v(2)}}, | |
106 | + [TaskType.HangBattle] = {{v(3)}}, | |
107 | + [TaskType.DrawHero] = {{v(4), f("count"), f("pool")}}, | |
108 | + [TaskType.TowerBattle] = {{v(5)}}, | |
109 | + [TaskType.PvpBattle] = {{v(6)}}, | |
110 | + [TaskType.PvpWin] = {{v(7)}}, | |
111 | + [TaskType.AdvStart] = {{v(8)}}, | |
112 | + [TaskType.AdvBattleWin] = {{v(9)}}, | |
113 | + [TaskType.AdvShop] = {{v(10)}}, | |
114 | + [TaskType.GetOderTask] = {{v(11)}}, | |
115 | + [TaskType.OverOderTask] = {{v(12)}}, | |
116 | + [TaskType.MakeFood] = {{v(13), f("count")}}, | |
117 | + [TaskType.FoodSell] = {{v(14), f("count")}}, | |
118 | + [TaskType.FoodSellQuick] = {{v(15)}}, | |
119 | + [TaskType.FoodMGet] = {{v(16)}}, | |
120 | + [TaskType.HeroLevelUp] = {{v(17)}}, | |
121 | + [TaskType.Wake] = {{v(18)}}, | |
122 | + [TaskType.EquipUp] = {{v(19)}}, | |
123 | + [TaskType.GiveFriendP] = {{v(20)}}, | |
124 | + [TaskType.UnionBoss] = {{v(21)}}, | |
125 | + } | |
126 | +} | |
127 | + | |
128 | +-- 成就监听 | |
129 | +local AchievListener = { | |
130 | + func = "checkAchievTask", | |
131 | + listen = { | |
132 | + [TaskType.HangPass] = {{v(1), f("id")}}, | |
133 | + [TaskType.UnionBattle] = {{v(2)}}, | |
134 | + [TaskType.PvpWin] = {{v(3)}, {v(4), f("score")}}, | |
135 | + [TaskType.AdvAllPass] = {{v(5), f("id")}}, | |
136 | + [TaskType.AdvLevel] = {{v(6), f("level")}}, | |
137 | + [TaskType.AdvPass] = {{v(7), f("score")}}, | |
138 | + [TaskType.AdvBattleWin] = {{v(8)}}, | |
139 | + [TaskType.AdvOverTask] = {{v(9)}}, | |
140 | + [TaskType.AdvOpenBlock] = {{v(10)}}, | |
141 | + [TaskType.AdvUsePotion] = {{v(11)}}, | |
142 | + [TaskType.AdvStart] = {{v(12)}}, | |
143 | + [TaskType.FoodSell] = {{v(13), f("count")}}, | |
144 | + [TaskType.OverOderTask] = {{v(14)}}, | |
145 | + [TaskType.FoodSellGold] = {{v(15), f("count")}}, | |
146 | + [TaskType.DinerPopular] = {{v(16), f("count")}}, | |
147 | + [TaskType.TowerPass] = {{v(17), f("level")}}, | |
148 | + [TaskType.OpenBox] = {{v(18)}}, | |
149 | + [TaskType.DinerLevelUp] = {{v(19), f("level"), f("type")}}, | |
150 | + [TaskType.DinerTalentUp] = {{v(20), v(1), f("type")}}, | |
151 | + [TaskType.HangGetGold] = {{v(21), f("count")}}, | |
152 | + [TaskType.HeroLevelUp] = {{v(22), f("level")}}, | |
153 | + [TaskType.Wake] = {{v(23), f("wakeL")}}, | |
154 | + [TaskType.WakeCG] = {{v(24)}}, | |
155 | + [TaskType.HeroTalent] = {{v(25), f("alv")}}, | |
156 | + [TaskType.AddHero] = {{v(26), f("heroType")}, {v(27)}}, | |
157 | + [TaskType.DrawSSR] = {{v(28), f("count")}}, | |
158 | + [TaskType.DrawHero] = {{v(29), f("count"), f("pool")}}, | |
159 | + [TaskType.AddEquip] = {{v(30), f("rarity")}, {v(34), 1, f("rarity")}}, | |
160 | + [TaskType.AddRune] = {{v(31), f("rarity")}, {v(35), 1, f("rarity")}}, | |
161 | + [TaskType.EquipUp] = {{v(32)}}, | |
162 | + [TaskType.RuneUp] = {{v(33)}}, | |
163 | + [TaskType.AddUnion] = {{v(36)}}, | |
164 | + [TaskType.AddFriend] = {{v(37), f("count")}}, | |
165 | + [TaskType.BindPhone] = {{v(38), 1}}, | |
166 | + [TaskType.WeChat] = {{v(38), 2}}, | |
167 | + [TaskType.WeBlog] = {{v(38), 3}}, | |
168 | + [TaskType.SignIn] = {{v(39)}}, | |
37 | 169 | } |
38 | 170 | } |
39 | 171 | |
172 | + | |
40 | 173 | local TaskListeners = { |
41 | 174 | StoryListener, |
175 | + CommonListener, | |
176 | + AchievListener, | |
42 | 177 | } |
43 | 178 | |
44 | 179 | local RoleTask = {} |
... | ... | @@ -54,33 +189,26 @@ function RoleTask.bind(Role) |
54 | 189 | for _, listener in ipairs(TaskListeners) do |
55 | 190 | if listener and listener.listen and listener.listen[taskType] and listener["func"] then |
56 | 191 | local pms = {} |
57 | - for _, v in ipairs(listener.listen[taskType]) do | |
58 | - if type(v) == "table" and v.type then | |
59 | - if v.type == "value" then | |
60 | - table.insert(pms, v.value) | |
61 | - elseif v.type == "field" then | |
62 | - table.insert(pms, params[v.value]) | |
192 | + for _, vs in ipairs(listener.listen[taskType]) do | |
193 | + for __, v in ipairs(vs) do | |
194 | + if type(v) == "table" and v.type then | |
195 | + if v.type == "value" then | |
196 | + table.insert(pms, v.value) | |
197 | + elseif v.type == "field" then | |
198 | + table.insert(pms, params[v.value]) | |
199 | + else | |
200 | + table.insert(pms, v) | |
201 | + end | |
63 | 202 | else |
64 | 203 | table.insert(pms, v) |
65 | 204 | end |
66 | - else | |
67 | - table.insert(pms, v) | |
68 | 205 | end |
206 | + self[listener["func"]](self, notNotify, table.unpack(pms)) | |
69 | 207 | end |
70 | - self[listener["func"]](self, notNotify, table.unpack(pms)) | |
71 | 208 | end |
72 | 209 | end |
73 | 210 | end |
74 | 211 | |
75 | - function Role:checkDailyTask() | |
76 | - end | |
77 | - | |
78 | - function Role:checkWeekTask() | |
79 | - end | |
80 | - | |
81 | - function Role:checkAchievTask() | |
82 | - end | |
83 | - | |
84 | 212 | --剧情相关----begin------------- |
85 | 213 | local function checkStoryStatusByHang(role, data, status, cond1) -- cond1 carbonId |
86 | 214 | if tonumber(data.unlockData) ~= cond1 then return end |
... | ... | @@ -158,6 +286,147 @@ function RoleTask.bind(Role) |
158 | 286 | end |
159 | 287 | |
160 | 288 | --剧情相关----end------------- |
289 | + | |
290 | + function Role:checkCommonTasks(notNotify, stype, count, cond1, cond2) | |
291 | + count = count or 1 | |
292 | + self:checkLoopTask(notNotify, stype, count, cond1, cond2) | |
293 | + end | |
294 | + | |
295 | + function Role:checkLoopTask(notNotify, stype, count, cond1, cond2) | |
296 | + local tasks = {self:getProperty("dTask")["t"] or {}, self:getProperty("wTask")["t"] or {}} | |
297 | + local isChange = {false, false} | |
298 | + for key, status in ipairs(tasks) do | |
299 | + local taskDatas = csvdb["task_loopCsv"][key] | |
300 | + for taskId, data in pairs(taskDatas) do | |
301 | + if status[taskId] ~= -1 and data.type == stype and (data.condition2 == 0 or data.condition2 == cond1) then | |
302 | + status[taskId] = (status[taskId] or 0) + count | |
303 | + isChange[key] = 1 | |
304 | + end | |
305 | + end | |
306 | + end | |
307 | + local change = {} | |
308 | + if isChange[1] then | |
309 | + table.insert(change, {type = "dTask", field = "t", value = tasks[1]}) | |
310 | + end | |
311 | + if isChange[2] then | |
312 | + table.insert(change, {type = "wTask", field = "t", value = tasks[2]}) | |
313 | + end | |
314 | + if next(change) then | |
315 | + self:changeUpdates(change, notNotify) | |
316 | + end | |
317 | + end | |
318 | + | |
319 | + function Role:checkAchievTask(notNotify, stype, v1, v2) | |
320 | + local change = {} | |
321 | + local achiveStatus = self:getProperty("achiveT") | |
322 | + | |
323 | + local IsFindMax = { | |
324 | + [4] = true, | |
325 | + [6] = true, | |
326 | + [7] = true, | |
327 | + [16] = true, | |
328 | + [17] = true, | |
329 | + [19] = true, | |
330 | + [22] = true, | |
331 | + [23] = true, | |
332 | + [25] = true, | |
333 | + } | |
334 | + | |
335 | + for tId , achiveData in ipairs(csvdb["achievement_typeCsv"]) do | |
336 | + local curStatus = achiveStatus[tId] or 0 | |
337 | + if achiveData.type == stype then | |
338 | + if achiveData.type == 1 then --取出难度 | |
339 | + v2 = math.floor(v1 / 10000) | |
340 | + end | |
341 | + | |
342 | + if achiveData.type == 26 then | |
343 | + local campS = {} | |
344 | + local jobS = {} | |
345 | + for _, hero in pairs(self.heros) do | |
346 | + local unitData = csvdb["unitCsv"][hero:getProperty("type")] | |
347 | + campS[unitData.camp] = (campS[unitData.camp] or 0) + 1 | |
348 | + jobS[unitData.job] = (jobS[unitData.job] or 0) + 1 | |
349 | + end | |
350 | + local nStatus = 0 | |
351 | + if achiveData.condition2 == 1 then | |
352 | + for k , v in pairs(jobS) do | |
353 | + nStatus = math.max(nStatus, v) | |
354 | + end | |
355 | + elseif achiveData.condition2 == 2 then | |
356 | + for k , v in pairs(campS) do | |
357 | + nStatus = math.max(nStatus, v) | |
358 | + end | |
359 | + end | |
360 | + if nStatus > curStatus then | |
361 | + table.insert(change, {type = "achiveT", field = tId, value = nStatus}) | |
362 | + end | |
363 | + elseif achiveData.type == 30 then --装备套装 | |
364 | + if achiveData.condition2 == 0 or achiveData.condition2 == v1 then | |
365 | + local suitS = {} | |
366 | + for equipType, equips in pairs(self:getProperty("equips")) do | |
367 | + for lv, c in pairs(equips) do | |
368 | + local equipData = csvdb["equipCsv"][equipType][lv] | |
369 | + if achiveData.condition2 == 0 or achiveData.condition2 == equipData.rarity then | |
370 | + if equipData.suit ~= "" then | |
371 | + suitS[equipData.suit] = suitS[equipData.suit] or {} | |
372 | + suitS[equipData.suit][equipType] = 1 | |
373 | + end | |
374 | + end | |
375 | + end | |
376 | + end | |
377 | + local nStatus = 0 | |
378 | + for k , v in pairs(suitS) do | |
379 | + local n = 0 | |
380 | + for _, __ in pairs(v) do | |
381 | + n = n + 1 | |
382 | + end | |
383 | + nStatus = math.max(nStatus, n) | |
384 | + end | |
385 | + if nStatus > curStatus then | |
386 | + table.insert(change, {type = "achiveT", field = tId, value = nStatus}) | |
387 | + end | |
388 | + end | |
389 | + elseif achiveData.type == 31 then -- 符文套装 | |
390 | + if achiveData.condition2 == 0 or achiveData.condition2 == v1 then | |
391 | + local suitS = {} | |
392 | + for _, rune in pairs(self.runeBag) do | |
393 | + local runeData = csvdb["runeCsv"][rune:getProperty("type")][rune:getProperty("id")] | |
394 | + if achiveData.condition2 == 0 or achiveData.condition2 == equipData.rarity then | |
395 | + if runeData.suit ~= "" then | |
396 | + suitS[runeData.suit] = suitS[runeData.suit] or {} | |
397 | + suitS[runeData.suit][runeData.type] = 1 | |
398 | + end | |
399 | + end | |
400 | + end | |
401 | + local nStatus = 0 | |
402 | + for k , v in pairs(suitS) do | |
403 | + local n = 0 | |
404 | + for _, __ in pairs(v) do | |
405 | + n = n + 1 | |
406 | + end | |
407 | + nStatus = math.max(nStatus, n) | |
408 | + end | |
409 | + if nStatus > curStatus then | |
410 | + table.insert(change, {type = "achiveT", field = tId, value = nStatus}) | |
411 | + end | |
412 | + end | |
413 | + elseif IsFindMax[achiveData.type] then -- 最大值 | |
414 | + if achiveData.condition2 == 0 or achiveData.condition2 == v2 then | |
415 | + if (v1 or 0) > curStatus then | |
416 | + table.insert(change, {type = "achiveT", field = tId, value = v1}) | |
417 | + end | |
418 | + end | |
419 | + else --通用增加 | |
420 | + if achiveData.condition2 == 0 or achiveData.condition2 == v2 then | |
421 | + table.insert(change, {type = "achiveT", field = tId, value = curStatus + (v1 or 1)}) | |
422 | + end | |
423 | + end | |
424 | + end | |
425 | + end | |
426 | + if next(change) then | |
427 | + self:changeUpdates(change, notNotify) | |
428 | + end | |
429 | + end | |
161 | 430 | end |
162 | 431 | |
163 | 432 | return RoleTask |
164 | 433 | \ No newline at end of file | ... | ... |