Commit 7bb30dca2407dc585f93d933ce0456bb041cb4a0
1 parent
02abfcb2
修改发奖
Showing
13 changed files
with
138 additions
and
118 deletions
Show diff stats
src/actions/ActivityAction.lua
... | ... | @@ -32,9 +32,9 @@ function _M.sudokuRpc(agent, data) |
32 | 32 | if (sudoku.task[phase][id] or 0) < curData.con1 then return 2 end |
33 | 33 | |
34 | 34 | sudoku.task[phase][id] = -1 |
35 | - local task = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励 | |
35 | + local task, tchange = role:award(curData.reward, {log = {desc = "sudoku", int1 = id, int2 = phase}}) -- 任务奖励 | |
36 | 36 | |
37 | - local reward = {} | |
37 | + local reward, rchange = {} | |
38 | 38 | local rId = {} |
39 | 39 | for pid, pdata in pairs(csvdb["guide_sudoku_rewardCsv"][phase] or {}) do |
40 | 40 | local pos = pdata.pos:toArray(true, "=") |
... | ... | @@ -60,14 +60,14 @@ function _M.sudokuRpc(agent, data) |
60 | 60 | if not next(reward) then |
61 | 61 | reward = nil |
62 | 62 | else |
63 | - reward = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}}) | |
63 | + reward, rchange = role:award(reward, {log = {desc = "sudokuR", int1 = id, int2 = phase}}) | |
64 | 64 | end |
65 | 65 | |
66 | 66 | role:updateProperty({field = "sudoku", value = sudoku}) |
67 | 67 | |
68 | 68 | role:log("act_action", {desc = "sudoku", int1 = id, int2 = phase}) |
69 | 69 | |
70 | - SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = task, reward = reward, rId = rId})) | |
70 | + SendPacket(actionCodes.Activity_sudokuRpc, MsgPack.pack({task = role:packReward(task, tchange), reward = role:packReward(reward, rchange), rId = rId})) | |
71 | 71 | return true |
72 | 72 | end |
73 | 73 | |
... | ... | @@ -90,7 +90,7 @@ function _M.sudokuRewardRpc(agent, data) |
90 | 90 | end |
91 | 91 | end |
92 | 92 | |
93 | - local reward = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}}) | |
93 | + local reward, change = role:award(globalCsv.guide_sudoku_reward[phase], {log = {desc = "sudokuRP", int1 = phase}}) | |
94 | 94 | |
95 | 95 | sudoku[-1] = phase + 1 |
96 | 96 | sudoku.task[phase] = nil |
... | ... | @@ -100,7 +100,7 @@ function _M.sudokuRewardRpc(agent, data) |
100 | 100 | end |
101 | 101 | role:updateProperty({field = "sudoku", value = sudoku}) |
102 | 102 | |
103 | - SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(reward)) | |
103 | + SendPacket(actionCodes.Activity_sudokuRewardRpc, MsgPack.pack(role:packReward(reward, change))) | |
104 | 104 | return true |
105 | 105 | end |
106 | 106 | |
... | ... | @@ -125,10 +125,10 @@ function _M.signRpc(agent, data) |
125 | 125 | end |
126 | 126 | signs[curDay] = yearMonth |
127 | 127 | |
128 | - local reward = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}}) | |
128 | + local reward, change = role:award(monthData[curDay].item, {log = {desc = "sign", int1 = yearMonth, int2 = curDay}}) | |
129 | 129 | role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) |
130 | 130 | |
131 | - SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(reward)) | |
131 | + SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change))) | |
132 | 132 | return true |
133 | 133 | end |
134 | 134 | |
... | ... | @@ -138,7 +138,7 @@ function _M.actSignRpc(agent, data) |
138 | 138 | if not role.activity:isOpen("Sign") then return 1 end |
139 | 139 | |
140 | 140 | local curData = role.activity:getActData("Sign") |
141 | - local reward = {} | |
141 | + local reward, change = {} | |
142 | 142 | for day, csvData in ipairs(csvdb["new_signInCsv"]) do |
143 | 143 | if day <= (curData[0] or 0) then |
144 | 144 | if not curData[day] then |
... | ... | @@ -154,9 +154,9 @@ function _M.actSignRpc(agent, data) |
154 | 154 | end |
155 | 155 | if next(reward) then |
156 | 156 | role.activity:updateActData("Sign", curData) |
157 | - reward = role:award(reward, {log = {desc = "actSign"}}) | |
157 | + reward, change = role:award(reward, {log = {desc = "actSign"}}) | |
158 | 158 | end |
159 | - SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(reward)) | |
159 | + SendPacket(actionCodes.Activity_actSignRpc, MsgPack.pack(role:packReward(reward, change))) | |
160 | 160 | return true |
161 | 161 | end |
162 | 162 | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -290,7 +290,7 @@ function _M.endHangRpc(agent, data) |
290 | 290 | local chapterData = csvdb["adv_chapterCsv"][chapterId] |
291 | 291 | if not chapterData then return end |
292 | 292 | |
293 | - local reward, isFull | |
293 | + local reward, isFull, change | |
294 | 294 | if skynet.timex() >= info.time then |
295 | 295 | -- 英雄加成 |
296 | 296 | local idleUnit = chapterData.idleUnit:toNumMap() |
... | ... | @@ -321,7 +321,7 @@ function _M.endHangRpc(agent, data) |
321 | 321 | for itemId, count in pairs(idleReward) do |
322 | 322 | idleReward[itemId] = math.floor(count * (maxCampsite.idleValue + upUnit) / 100) |
323 | 323 | end |
324 | - reward = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) | |
324 | + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) | |
325 | 325 | else |
326 | 326 | if cancel then |
327 | 327 | role:changeAdvCount(-chapterData.limitlevel) |
... | ... | @@ -339,7 +339,7 @@ function _M.endHangRpc(agent, data) |
339 | 339 | |
340 | 340 | role:log("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) |
341 | 341 | |
342 | - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, isFull = isFull})) | |
342 | + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) | |
343 | 343 | return true |
344 | 344 | end |
345 | 345 | |
... | ... | @@ -381,9 +381,9 @@ function _M.finishTaskRpc(agent, data) |
381 | 381 | if not isCanContinue(role) then return end |
382 | 382 | local adv = role:getAdvData() |
383 | 383 | local taskId = msg.taskId -- -1 则是主线任务 |
384 | - local status, reward | |
384 | + local status, reward, change | |
385 | 385 | if taskId == -1 then |
386 | - status, reward = adv:finishMTask() | |
386 | + status, reward, change = adv:finishMTask() | |
387 | 387 | else |
388 | 388 | status, reward = adv:finishTask(taskId) |
389 | 389 | adv:checkAchievement(adv.AchievType.TaskLayer, 1, taskId) |
... | ... | @@ -395,7 +395,7 @@ function _M.finishTaskRpc(agent, data) |
395 | 395 | |
396 | 396 | adv:log({desc = "finishTask", int1 = taskId}) |
397 | 397 | |
398 | - SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack({reward = reward})) | |
398 | + SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack(role:packReward(reward, change))) | |
399 | 399 | return true |
400 | 400 | end |
401 | 401 | |
... | ... | @@ -749,11 +749,11 @@ function _M.repayWheelSurfRpc(agent, data) |
749 | 749 | advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond |
750 | 750 | role:updateProperty({field = "advDrawB", value = advDrawB}) |
751 | 751 | local gift = drawData["pool3"]:randWeight(true) |
752 | - local reward = {[gift[1]] = gift[2]} | |
753 | - reward = role:award(reward, {log = {desc = "advRepayWheelSurf", int1 = ptype}}) | |
752 | + local reward, change = {[gift[1]] = gift[2]} | |
753 | + reward, change = role:award(reward, {log = {desc = "advRepayWheelSurf", int1 = ptype}}) | |
754 | 754 | role:log("adv_action", {desc = "advRepayWheelSurf", int1 = ptype}) |
755 | 755 | |
756 | - SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack({reward = reward})) | |
756 | + SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack(role:packReward(reward, change))) | |
757 | 757 | return true |
758 | 758 | end |
759 | 759 | |
... | ... | @@ -766,17 +766,17 @@ function _M.finishAchievRpc(agent, data) |
766 | 766 | |
767 | 767 | local adv = role:getAdvData() |
768 | 768 | |
769 | - local status, reward | |
769 | + local status, reward, change | |
770 | 770 | if ctype == 1 then |
771 | - status, reward = adv:finishAchievement(chapterId, taskId) | |
771 | + status, reward, change = adv:finishAchievement(chapterId, taskId) | |
772 | 772 | elseif ctype == 2 then |
773 | - status, reward = adv:getAchievementReward(chapterId, taskId) | |
773 | + status, reward, change = adv:getAchievementReward(chapterId, taskId) | |
774 | 774 | end |
775 | 775 | if not status then return end |
776 | 776 | adv:updateAchievement() |
777 | 777 | role:log("adv_action", {desc = "finishAchiev", short1 = ctype, int1 = chapterId, int2 = taskId}) |
778 | 778 | |
779 | - SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack({reward = reward})) | |
779 | + SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack(role:packReward(reward, change))) | |
780 | 780 | return true |
781 | 781 | end |
782 | 782 | ... | ... |
src/actions/CarAction.lua
... | ... | @@ -150,7 +150,7 @@ function _M.saleEquipRpc(agent, data ) |
150 | 150 | local own = role:getEquipCount(typ,lv) |
151 | 151 | if math.illegalNum(count, 1, own) then return end |
152 | 152 | end |
153 | - local reward = {} | |
153 | + local reward, change = {} | |
154 | 154 | local allCount = 0 |
155 | 155 | for id, count in pairs(backs) do |
156 | 156 | allCount = allCount + count |
... | ... | @@ -165,11 +165,11 @@ function _M.saleEquipRpc(agent, data ) |
165 | 165 | end |
166 | 166 | end |
167 | 167 | role:checkTaskEnter("SaleEquip", {count = allCount}) |
168 | - reward = role:award(reward, {log = {desc = "saleEquip"}}) | |
168 | + reward, change = role:award(reward, {log = {desc = "saleEquip"}}) | |
169 | 169 | |
170 | 170 | role:log("role_action", {desc = "saleEquip", int1 = allCount}) |
171 | 171 | |
172 | - SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack({reward = reward})) | |
172 | + SendPacket(actionCodes.Car_saleEquipRpc, MsgPack.pack(role:packReward(reward, change))) | |
173 | 173 | return true |
174 | 174 | end |
175 | 175 | |
... | ... | @@ -179,7 +179,7 @@ function _M.saleRuneRpc(agent, data ) |
179 | 179 | local backs = msg.backs |
180 | 180 | if not backs then return end |
181 | 181 | |
182 | - local reward = {} | |
182 | + local reward, change = {} | |
183 | 183 | local count = 0 |
184 | 184 | for _, uid in pairs(backs) do |
185 | 185 | count = count + 1 |
... | ... | @@ -196,9 +196,9 @@ function _M.saleRuneRpc(agent, data ) |
196 | 196 | |
197 | 197 | role:delRunes(backs, {log = {desc = "saleRune"}}) |
198 | 198 | role:checkTaskEnter("DecoRune", {count = count}) |
199 | - reward = role:award(reward, {log = {desc = "saleRune"}}) | |
199 | + reward, change = role:award(reward, {log = {desc = "saleRune"}}) | |
200 | 200 | |
201 | - SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack({reward = reward})) | |
201 | + SendPacket(actionCodes.Car_saleRuneRpc, MsgPack.pack(role:packReward(reward, change))) | |
202 | 202 | return true |
203 | 203 | end |
204 | 204 | ... | ... |
src/actions/DinerAction.lua
... | ... | @@ -141,19 +141,19 @@ function _M.removeSellRpc( agent, data ) |
141 | 141 | end |
142 | 142 | |
143 | 143 | role.dinerData:updateSell(slot) |
144 | - local reward = {} | |
144 | + local reward, change = {} | |
145 | 145 | local cost = dishData.material:toNumMap() |
146 | 146 | for k, n in pairs(cost) do |
147 | 147 | local sum = n*sell.count |
148 | 148 | reward[k] = sum |
149 | 149 | end |
150 | - reward = role:award(reward, {log = {desc = "removeSell"}}) | |
150 | + reward, change = role:award(reward, {log = {desc = "removeSell"}}) | |
151 | 151 | sells[slot].count = 0 |
152 | 152 | |
153 | 153 | role:log("diner_action", {desc = "removeSell", int1 = dish}) |
154 | 154 | |
155 | 155 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
156 | - SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) | |
156 | + SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward, change = change})) | |
157 | 157 | return true |
158 | 158 | end |
159 | 159 | |
... | ... | @@ -195,7 +195,7 @@ function _M.getSellRewardRpc( agent, data ) |
195 | 195 | role:checkTaskEnter("FoodSellGold", {count = v}) |
196 | 196 | end |
197 | 197 | end |
198 | - role:award(gift, {log = {desc = "dinerSell"}}) | |
198 | + local reward, change = role:award(gift, {log = {desc = "dinerSell"}}) | |
199 | 199 | |
200 | 200 | |
201 | 201 | role.dinerData:popularAdd(popular) |
... | ... | @@ -206,7 +206,7 @@ function _M.getSellRewardRpc( agent, data ) |
206 | 206 | |
207 | 207 | role:log("diner_action", {desc = "sell"}) |
208 | 208 | |
209 | - SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward})) | |
209 | + SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward, change = change})) | |
210 | 210 | return true |
211 | 211 | end |
212 | 212 | |
... | ... | @@ -266,7 +266,8 @@ function _M.expediteSellRpc( agent, data ) |
266 | 266 | role:checkTaskEnter("FoodSellGold", {count = v}) |
267 | 267 | end |
268 | 268 | end |
269 | - role:award(gift, {log = {desc = "dinerSell"}}) | |
269 | + local change | |
270 | + reward, change = role:award(gift, {log = {desc = "dinerSell"}}) | |
270 | 271 | |
271 | 272 | |
272 | 273 | role.dinerData:popularAdd(popular) |
... | ... | @@ -278,7 +279,7 @@ function _M.expediteSellRpc( agent, data ) |
278 | 279 | |
279 | 280 | role:log("diner_action", {desc = "sellQ"}) |
280 | 281 | |
281 | - SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular})) | |
282 | + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward, change = change, popular = popular})) | |
282 | 283 | return true |
283 | 284 | end |
284 | 285 | |
... | ... | @@ -493,7 +494,7 @@ function _M.updateTaskRpc( agent, data ) |
493 | 494 | return 5 |
494 | 495 | end |
495 | 496 | |
496 | - | |
497 | + local reward, change | |
497 | 498 | if cmd == 0 then |
498 | 499 | if order.status ~= 0 then |
499 | 500 | return 30 |
... | ... | @@ -522,7 +523,7 @@ function _M.updateTaskRpc( agent, data ) |
522 | 523 | end |
523 | 524 | role:log("diner_action", {desc = "finishTask", int1 = order.id}) |
524 | 525 | |
525 | - role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}}) | |
526 | + reward, change = role:award(taskData.reward, {log = {desc = "dinerFinishTask", int1 = order.id}}) | |
526 | 527 | table.remove(orders,index) |
527 | 528 | role:checkTaskEnter("OverOderTask", {rarity = taskSet.rarity}) |
528 | 529 | else |
... | ... | @@ -530,7 +531,7 @@ function _M.updateTaskRpc( agent, data ) |
530 | 531 | end |
531 | 532 | |
532 | 533 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
533 | - SendPacket(actionCodes.Diner_updateTaskRpc, '') | |
534 | + SendPacket(actionCodes.Diner_updateTaskRpc, MsgPack.pack({reward = reward, change = change})) | |
534 | 535 | return true |
535 | 536 | end |
536 | 537 | |
... | ... | @@ -681,12 +682,12 @@ function _M.getGreenhouseRpc( agent, data ) |
681 | 682 | end |
682 | 683 | end |
683 | 684 | role.dinerData:updateProperty({field = "gfood", value = gfood}) |
684 | - local reward = role:award(reward, {log = {desc = "greenHourse", int1 = level}}) | |
685 | + local reward, change = role:award(reward, {log = {desc = "greenHourse", int1 = level}}) | |
685 | 686 | role:checkTaskEnter("FoodMGet") |
686 | 687 | |
687 | 688 | role:log("diner_action", {desc = "greenHourse"}) |
688 | 689 | |
689 | - SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward})) | |
690 | + SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward, change = change})) | |
690 | 691 | return true |
691 | 692 | end |
692 | 693 | |
... | ... | @@ -798,7 +799,7 @@ function _M.entrustRpc(agent , data) |
798 | 799 | local entrustId = entrust[1] |
799 | 800 | if not entrustId then return end |
800 | 801 | |
801 | - local reward | |
802 | + local reward, change | |
802 | 803 | if ctype == 1 then -- 完成 |
803 | 804 | local curData = csvdb["diner_missionCsv"][entrustId] |
804 | 805 | if not curData then return end |
... | ... | @@ -813,7 +814,7 @@ function _M.entrustRpc(agent , data) |
813 | 814 | return |
814 | 815 | end |
815 | 816 | |
816 | - reward = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) | |
817 | + reward, change = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) | |
817 | 818 | table.remove(entrust, 1) |
818 | 819 | elseif ctype == 2 then -- 放弃 |
819 | 820 | table.remove(entrust, 1) |
... | ... | @@ -824,7 +825,7 @@ function _M.entrustRpc(agent , data) |
824 | 825 | |
825 | 826 | role:log("diner_action", {desc = "entrus", short1 = ctype, int1 = entrustId}) |
826 | 827 | |
827 | - SendPacket(actionCodes.Diner_entrustRpc, MsgPack.pack({reward = reward})) | |
828 | + SendPacket(actionCodes.Diner_entrustRpc, MsgPack.pack({reward = reward, change = change})) | |
828 | 829 | return true |
829 | 830 | end |
830 | 831 | |
... | ... | @@ -845,12 +846,12 @@ function _M.collectRpc(agent , data) |
845 | 846 | for slot, _ in pairs(sells) do |
846 | 847 | role.dinerData:updateSell(slot) |
847 | 848 | end |
848 | - local reward = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}}) | |
849 | + local reward, change = role:award(customerData.reward, {log = {desc = "dinerCollect", int1 = id}}) | |
849 | 850 | customer[id] = 1 |
850 | 851 | role.dinerData:updateProperty({field = "customer", value = customer}) -- 解锁了 |
851 | 852 | role:log("diner_action", {desc = "collect", int1 = id}) |
852 | 853 | |
853 | - SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward})) | |
854 | + SendPacket(actionCodes.Diner_collectRpc, MsgPack.pack({reward = reward, change = change})) | |
854 | 855 | return true |
855 | 856 | end |
856 | 857 | |
... | ... | @@ -874,13 +875,13 @@ function _M.comboRewardRpc(agent , data) |
874 | 875 | end |
875 | 876 | |
876 | 877 | comboStatus[id] = 1 |
877 | - local reward = role:award(comboData.reward, {log = {desc = "dinerCombo", int1 = id}}) | |
878 | + local reward, change = role:award(comboData.reward, {log = {desc = "dinerCombo", int1 = id}}) | |
878 | 879 | |
879 | 880 | role.dinerData:updateProperty({field = "comboStatus", value = comboStatus}) -- 解锁了 |
880 | 881 | |
881 | 882 | role:log("diner_action", {desc = "combo", int1 = id}) |
882 | 883 | |
883 | - SendPacket(actionCodes.Diner_comboRewardRpc, MsgPack.pack({reward = reward})) | |
884 | + SendPacket(actionCodes.Diner_comboRewardRpc, MsgPack.pack({reward = reward, change = change})) | |
884 | 885 | return true |
885 | 886 | end |
886 | 887 | ... | ... |
src/actions/EmailAction.lua
... | ... | @@ -86,7 +86,7 @@ function _M.drawAllAttachRpc(agent, data) |
86 | 86 | local role = agent.role |
87 | 87 | local roleId = role:getProperty("id") |
88 | 88 | |
89 | - local reward = {} | |
89 | + local reward, change = {} | |
90 | 90 | local ids = {} |
91 | 91 | |
92 | 92 | local emails = loadEmails(roleId) |
... | ... | @@ -95,19 +95,18 @@ function _M.drawAllAttachRpc(agent, data) |
95 | 95 | local attachments = getEmailAttachments(email) |
96 | 96 | if attachments ~= "" then |
97 | 97 | local emailId = email:getProperty("id") |
98 | - local items = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}}) | |
99 | 98 | ids[emailId] = 1 |
100 | 99 | red:hset(string.format(R_EMAIL_ITEM, roleId, emailId), "status", 2) |
101 | 100 | role:log("mail_action", {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title"), key2 = attachments}) |
102 | 101 | |
103 | - for key, v in pairs(items) do | |
102 | + for key, v in pairs(attachments:toNumMap()) do | |
104 | 103 | reward[key] = (reward[key] or 0) + v |
105 | 104 | end |
106 | 105 | end |
107 | 106 | end |
108 | 107 | end) |
109 | - | |
110 | - SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward})) | |
108 | + reward, change = role:award(reward, {log = {desc = "draw_attach"}}) | |
109 | + SendPacket(actionCodes.Email_drawAllAttachRpc, MsgPack.pack({ids = ids, reward = reward, change = change})) | |
111 | 110 | return true |
112 | 111 | end |
113 | 112 | |
... | ... | @@ -125,9 +124,9 @@ function _M.drawAttachRpc(agent, data) |
125 | 124 | local attachments = getEmailAttachments(email) |
126 | 125 | if attachments == "" then return end |
127 | 126 | |
128 | - local reward = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}}) | |
127 | + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId, key1 = email:getProperty("title")}}) | |
129 | 128 | redisproxy:hset(rds, "status", 2) -- 领取标记 |
130 | - SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward})) | |
129 | + SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | |
131 | 130 | |
132 | 131 | role:log("mail_action", {desc = "draw_attach", int1 = id, key1 = email:getProperty("title"), key2 = attachments}) |
133 | 132 | return true | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -517,6 +517,12 @@ function _M.ayncPurchase(role, params) |
517 | 517 | return role:handlePurchase(params) or "" |
518 | 518 | end |
519 | 519 | |
520 | +function _M.test(role, params) | |
521 | + local id = tonum(params.pm1, 0) | |
522 | + local store = require ("actions.StoreAction") | |
523 | + store.shopBuyRpc({role = role}, MsgPack.pack({id = id})) | |
524 | + return "成功" | |
525 | +end | |
520 | 526 | |
521 | 527 | |
522 | 528 | return _M |
523 | 529 | \ No newline at end of file | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -203,7 +203,7 @@ function _M.endBattleRpc(agent, data) |
203 | 203 | if role:checkHangPass(carbonId) then |
204 | 204 | return 4 |
205 | 205 | end |
206 | - local reward | |
206 | + local reward, change | |
207 | 207 | if msg.starNum and msg.starNum > 0 then --win |
208 | 208 | role:hangFinish(carbonId) |
209 | 209 | if carbonData.main ~= 1 then |
... | ... | @@ -217,7 +217,7 @@ function _M.endBattleRpc(agent, data) |
217 | 217 | for itemId, count in pairs(carbonData.item_clear:toNumMap()) do |
218 | 218 | reward[itemId] = count |
219 | 219 | end |
220 | - reward = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}}) | |
220 | + reward, change = role:award(reward, {log = {desc = "hangBattle", int1 = carbonId}}) | |
221 | 221 | |
222 | 222 | role:checkTaskEnter("HangPass", {id = carbonId}) |
223 | 223 | end |
... | ... | @@ -229,6 +229,7 @@ function _M.endBattleRpc(agent, data) |
229 | 229 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({ |
230 | 230 | starNum = msg.starNum, |
231 | 231 | reward = reward, |
232 | + change = change, | |
232 | 233 | })) |
233 | 234 | return true |
234 | 235 | end |
... | ... | @@ -276,7 +277,7 @@ function _M.getRewardRpc(agent , data) |
276 | 277 | checkReward(role) |
277 | 278 | local items = role:getProperty("hangBag") |
278 | 279 | if not next(items) then return end |
279 | - local reward = role:award(items, {log = {desc = "hangReward"}}) | |
280 | + local reward, change = role:award(items, {log = {desc = "hangReward"}}) | |
280 | 281 | table.clear(items) |
281 | 282 | local hangInfo = role:getProperty("hangInfo") |
282 | 283 | local nowTime = skynet.timex() |
... | ... | @@ -291,7 +292,8 @@ function _M.getRewardRpc(agent , data) |
291 | 292 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) |
292 | 293 | end |
293 | 294 | SendPacket(actionCodes.Hang_getRewardRpc, MsgPack.pack({ |
294 | - reward = reward | |
295 | + reward = reward, | |
296 | + change = change | |
295 | 297 | })) |
296 | 298 | return true |
297 | 299 | end |
... | ... | @@ -388,14 +390,15 @@ function _M.quickRpc(agent , data) |
388 | 390 | local cur = pool[math.randWeight(pool, 3)] |
389 | 391 | reward[cur[1]] = (reward[cur[1]] or 0) + cur[2] |
390 | 392 | end |
391 | - | |
392 | - reward = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) | |
393 | + local change | |
394 | + reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) | |
393 | 395 | if reward[ItemId.Gold] then |
394 | 396 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) |
395 | 397 | end |
396 | 398 | role:checkTaskEnter("HangQuick") |
397 | 399 | SendPacket(actionCodes.Hang_quickRpc, MsgPack.pack({ |
398 | - reward = reward | |
400 | + reward = reward, | |
401 | + change = change | |
399 | 402 | })) |
400 | 403 | return true |
401 | 404 | end |
... | ... | @@ -497,7 +500,7 @@ function _M.endBonusBattleRpc(agent, data) |
497 | 500 | if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then return 2 end |
498 | 501 | local bonusData = csvdb["bonus_battleCsv"][id] |
499 | 502 | |
500 | - local reward | |
503 | + local reward, change | |
501 | 504 | if starNum and starNum > 0 then |
502 | 505 | -- 胜利扣除次数 |
503 | 506 | local bonusC = role.dailyData:getProperty("bonusC") |
... | ... | @@ -511,7 +514,7 @@ function _M.endBonusBattleRpc(agent, data) |
511 | 514 | if chance[1] ~= 0 then |
512 | 515 | reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] |
513 | 516 | end |
514 | - reward = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
517 | + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
515 | 518 | role:checkTaskEnter("BonusPass", {id = id}) |
516 | 519 | end |
517 | 520 | |
... | ... | @@ -519,7 +522,9 @@ function _M.endBonusBattleRpc(agent, data) |
519 | 522 | |
520 | 523 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({ |
521 | 524 | starNum = starNum, |
522 | - reward = reward})) | |
525 | + reward = reward, | |
526 | + change = change | |
527 | + })) | |
523 | 528 | return true |
524 | 529 | end |
525 | 530 | |
... | ... | @@ -534,12 +539,12 @@ function _M.hangGiftRpc(agent, data) |
534 | 539 | local hangGift = role:getProperty("hangGift") |
535 | 540 | if hangGift[id] then return 2 end |
536 | 541 | |
537 | - local reward = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) | |
542 | + local reward, change = role:award(carbonData.item_clear_special, {log = {desc = "hangGift", int1 = id}}) | |
538 | 543 | role:log("hang_action", {desc = "hangGift", int1 = id}) |
539 | 544 | |
540 | 545 | role:changeUpdates({{type = "hangGift", field = id, value = 1}}) |
541 | 546 | |
542 | - SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack(reward)) | |
547 | + SendPacket(actionCodes.Hang_hangGiftRpc, MsgPack.pack({reward = reward, change = change})) | |
543 | 548 | return true |
544 | 549 | end |
545 | 550 | |
... | ... | @@ -577,9 +582,9 @@ function _M.chatLineRpc(agent, data) |
577 | 582 | chatline[id] = skynet.timex() |
578 | 583 | role:updateProperty({field = "chatline", value = chatline}) |
579 | 584 | |
580 | - local reward = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}}) | |
585 | + local reward, change = role:award(idleData.chatline_reward, {log = {desc = "chatline", int1 = id}}) | |
581 | 586 | |
582 | - SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack(reward)) | |
587 | + SendPacket(actionCodes.Hang_chatLineRpc, MsgPack.pack({reward = reward, change = change})) | |
583 | 588 | return true |
584 | 589 | end |
585 | 590 | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -600,15 +600,12 @@ function _M.createHeroRandomRpc(agent, data) |
600 | 600 | |
601 | 601 | local temp = randomData.gift1:randWeight(true) |
602 | 602 | if not temp or not next(temp) then return end |
603 | - local reward = {} | |
604 | - if role:isHaveHero(temp[1]) then | |
605 | - reward = {[temp[1]] = cost} | |
606 | - else | |
607 | - reward = {[temp[1] + ItemStartId.Hero] = 1} | |
608 | - end | |
603 | + | |
609 | 604 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) |
610 | - reward = role:award(reward, {log = {desc = "createHeroRandom"}}) | |
611 | - SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({reward = reward})) | |
605 | + local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}}) | |
606 | + | |
607 | + | |
608 | + SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) | |
612 | 609 | return true |
613 | 610 | end |
614 | 611 | |
... | ... | @@ -677,9 +674,10 @@ function _M.getResetRewardRpc(agent, data) |
677 | 674 | for itemId, count in pairs(reward) do |
678 | 675 | reward[itemId] = math.floor(count * globalCsv.unit_back_discount) |
679 | 676 | end |
680 | - reward = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) | |
677 | + local change | |
678 | + reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) | |
681 | 679 | |
682 | - SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack({reward = reward})) | |
680 | + SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack(role:packReward(reward, change))) | |
683 | 681 | return true |
684 | 682 | end |
685 | 683 | ... | ... |
src/actions/PvpAction.lua
... | ... | @@ -334,7 +334,7 @@ function _M.endBattleRpc(agent, data) |
334 | 334 | if not match then return end |
335 | 335 | |
336 | 336 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) |
337 | - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) | |
337 | + local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) | |
338 | 338 | local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) |
339 | 339 | |
340 | 340 | _pvpBattleInfoCacheC = {} --重新发阵容了 没毛病 |
... | ... | @@ -395,6 +395,7 @@ function _M.endBattleRpc(agent, data) |
395 | 395 | |
396 | 396 | SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({ |
397 | 397 | reward = reward, |
398 | + change = change, | |
398 | 399 | myScore = myScore, |
399 | 400 | matchScore = matchScore, |
400 | 401 | oldmyScore = oldmyScore, |
... | ... | @@ -621,7 +622,7 @@ function _M.endBattleHRpc(agent, data) |
621 | 622 | |
622 | 623 | -- 战斗结束了发奖 |
623 | 624 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
624 | - local reward = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) | |
625 | + local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) | |
625 | 626 | local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 |
626 | 627 | if role:isTimeResetOpen(TimeReset.PvpHight) then |
627 | 628 | myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) |
... | ... | @@ -694,6 +695,7 @@ function _M.endBattleHRpc(agent, data) |
694 | 695 | |
695 | 696 | SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({ |
696 | 697 | reward = reward, |
698 | + change = change, | |
697 | 699 | myScore = myScore, |
698 | 700 | matchScore = matchScore, |
699 | 701 | oldmyScore = oldmyScore, |
... | ... | @@ -837,10 +839,10 @@ function _M.highDivisionGiftRpc(agent, data) |
837 | 839 | pvpHGift = {}, |
838 | 840 | }) |
839 | 841 | |
840 | - local reward = role:award(newReward, {log = {desc = "pvpDivisionH"}}) | |
842 | + local reward, change = role:award(newReward, {log = {desc = "pvpDivisionH"}}) | |
841 | 843 | role:log("pvp_action", {desc = "pvpDivisionH"}) |
842 | 844 | |
843 | - SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack({reward = reward})) | |
845 | + SendPacket(actionCodes.Pvp_highDivisionGiftRpc, MsgPack.pack(role:packReward(reward, change))) | |
844 | 846 | return true |
845 | 847 | end |
846 | 848 | |
... | ... | @@ -871,11 +873,11 @@ function _M.shopBuyRpc(agent, data) |
871 | 873 | for id, c in pairs(gift) do |
872 | 874 | gift[id] = c * count |
873 | 875 | end |
874 | - local reward = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}}) | |
876 | + local reward, change = role:award(gift, {log = {desc = "pvpShop", int1 = id, int2 = count}}) | |
875 | 877 | |
876 | 878 | role:log("pvp_action", {desc = "pvpShop", int1 = id, int2 = count}) |
877 | 879 | |
878 | - SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack({reward = reward})) | |
880 | + SendPacket(actionCodes.Pvp_shopBuyRpc, MsgPack.pack(role:packReward(reward, change))) | |
879 | 881 | return true |
880 | 882 | end |
881 | 883 | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -408,9 +408,9 @@ function _M.saleItemRpc(agent, data) |
408 | 408 | end |
409 | 409 | |
410 | 410 | role:costItems(backs, {log = {desc = "saleItem"}}) |
411 | - local reward = role:award(reward, {log = {desc = "saleItem"}}) | |
411 | + local reward, change = role:award(reward, {log = {desc = "saleItem"}}) | |
412 | 412 | role:checkTaskEnter("DecoFrag", {count = fragCount}) |
413 | - SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack({reward = reward})) | |
413 | + SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack(role:packReward(reward, change))) | |
414 | 414 | return true |
415 | 415 | end |
416 | 416 | |
... | ... | @@ -447,9 +447,10 @@ function _M.openItemRpc(agent, data) |
447 | 447 | reward[0] = nil |
448 | 448 | |
449 | 449 | role:costItems({[itemId] = count}, {log = {desc = "openItem"}}) |
450 | - reward = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) | |
450 | + local change | |
451 | + reward, change = role:award(reward, {log = {desc = "openItem", int1 = itemId, int2 = count}}) | |
451 | 452 | |
452 | - SendPacket(actionCodes.Role_openItemRpc, MsgPack.pack({reward = reward})) | |
453 | + SendPacket(actionCodes.Role_openItemRpc, MsgPack.pack(role:packReward(reward, change))) | |
453 | 454 | return true |
454 | 455 | end |
455 | 456 | |
... | ... | @@ -461,7 +462,7 @@ function _M.openTimeBoxRpc(agent, data) |
461 | 462 | if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot)) then return end |
462 | 463 | |
463 | 464 | local boxL = role:getProperty("boxL") |
464 | - local reward = {} | |
465 | + local reward, change = {} | |
465 | 466 | if oper == 1 then -- 打开 |
466 | 467 | local itemId = msg.itemId |
467 | 468 | if role:getItemCount(itemId) < 1 then return end |
... | ... | @@ -509,7 +510,7 @@ function _M.openTimeBoxRpc(agent, data) |
509 | 510 | reward[0] = nil |
510 | 511 | |
511 | 512 | boxL[slot] = nil |
512 | - reward = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}}) | |
513 | + reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}}) | |
513 | 514 | role:checkTaskEnter("OpenBox", {id = boxId}) |
514 | 515 | else |
515 | 516 | return |
... | ... | @@ -517,7 +518,7 @@ function _M.openTimeBoxRpc(agent, data) |
517 | 518 | |
518 | 519 | role:setProperty("boxL") --刷新 |
519 | 520 | role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端 |
520 | - SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({reward = reward})) | |
521 | + SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack(role:packReward(reward, change))) | |
521 | 522 | return true |
522 | 523 | end |
523 | 524 | |
... | ... | @@ -568,9 +569,10 @@ function _M.openSpeedUpBoxRpc(agent, data) |
568 | 569 | end |
569 | 570 | |
570 | 571 | role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) |
571 | - reward = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) | |
572 | + local change | |
573 | + reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) | |
572 | 574 | |
573 | - SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack({reward = reward})) | |
575 | + SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) | |
574 | 576 | return true |
575 | 577 | end |
576 | 578 | |
... | ... | @@ -596,8 +598,8 @@ function _M.storyBookRewardRpc(agent, data) |
596 | 598 | storyStatus[storyId] = storyStatus[storyId] or {} |
597 | 599 | storyStatus[storyId].s = -1 |
598 | 600 | role:changeUpdates({{ type = "storyB", field = storyId, value = storyStatus[storyId] }}) |
599 | - local reward = role:award(storyBookData.gift, {log = {desc = "storybookReward", int1 = storyId}}) | |
600 | - SendPacket(actionCodes.Role_storyBookRewardRpc, MsgPack.pack({reward = reward})) | |
601 | + local reward, change = role:award(storyBookData.gift, {log = {desc = "storybookReward", int1 = storyId}}) | |
602 | + SendPacket(actionCodes.Role_storyBookRewardRpc, MsgPack.pack(role:packReward(reward, change))) | |
601 | 603 | return true |
602 | 604 | end |
603 | 605 | |
... | ... | @@ -648,7 +650,7 @@ function _M.taskRpc(agent, data) |
648 | 650 | return 3 |
649 | 651 | end |
650 | 652 | |
651 | - local reward = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) | |
653 | + local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) | |
652 | 654 | local active = (taskStatus["a"] or 0) + taskData.active |
653 | 655 | |
654 | 656 | role:changeUpdates({ |
... | ... | @@ -656,7 +658,7 @@ function _M.taskRpc(agent, data) |
656 | 658 | { type = roleField[taskType], field = "a", value = active} |
657 | 659 | }) |
658 | 660 | |
659 | - SendPacket(actionCodes.Role_taskRpc, MsgPack.pack({reward = reward})) | |
661 | + SendPacket(actionCodes.Role_taskRpc, MsgPack.pack(role:packReward(reward, change))) | |
660 | 662 | return true |
661 | 663 | end |
662 | 664 | |
... | ... | @@ -681,12 +683,12 @@ function _M.taskActiveRpc(agent, data) |
681 | 683 | return |
682 | 684 | end |
683 | 685 | |
684 | - local reward = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}}) | |
686 | + local reward, change = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}}) | |
685 | 687 | role:changeUpdates({ |
686 | 688 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } |
687 | 689 | }) |
688 | 690 | |
689 | - SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack({reward = reward})) | |
691 | + SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) | |
690 | 692 | return true |
691 | 693 | end |
692 | 694 | |
... | ... | @@ -712,7 +714,7 @@ function _M.achiveRpc(agent, data) |
712 | 714 | return 3 |
713 | 715 | end |
714 | 716 | |
715 | - local reward = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}}) | |
717 | + local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}}) | |
716 | 718 | role:changeUpdates({ |
717 | 719 | { type = "achiveV", field = taskId, value = skynet.timex() } |
718 | 720 | }) |
... | ... | @@ -745,7 +747,7 @@ function _M.achiveRpc(agent, data) |
745 | 747 | end |
746 | 748 | end |
747 | 749 | |
748 | - SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack({reward = reward})) | |
750 | + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change))) | |
749 | 751 | return true |
750 | 752 | end |
751 | 753 | |
... | ... | @@ -921,11 +923,12 @@ function _M.drawCodeRpc(agent, data) |
921 | 923 | if ret == 0 then |
922 | 924 | local giftId = tonumber(result.giftId) |
923 | 925 | role:setProperty("codeStr", codestr:setv(giftId, 1)) |
924 | - local reward = role:award(result.gift, {log = {desc = "drawCode", key1 = code, int1 = giftId}}) | |
926 | + local reward, change = role:award(result.gift, {log = {desc = "drawCode", key1 = code, int1 = giftId}}) | |
925 | 927 | |
926 | 928 | SendPacket(actionCodes.Role_drawCodeRpc, MsgPack.pack({ |
927 | 929 | result = ret, |
928 | 930 | reward = reward, |
931 | + change = change, | |
929 | 932 | })) |
930 | 933 | return true |
931 | 934 | end |
... | ... | @@ -1046,8 +1049,8 @@ function _M.goldBuyRpc(agent, data) |
1046 | 1049 | end |
1047 | 1050 | role.dailyData:updateProperty({field = "goldBuyT", value = curT + 1}) |
1048 | 1051 | role:costItems({[ItemId.Diamond] = costD}, {log = {desc = "goldBuy"}}) |
1049 | - local reward = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}}) | |
1050 | - SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack({reward = reward})) | |
1052 | + local reward, change = role:award({[ItemId.Gold] = goldC}, {log = {desc = "goldBuy"}}) | |
1053 | + SendPacket(actionCodes.Role_goldBuyRpc, MsgPack.pack(role:packReward(reward, change))) | |
1051 | 1054 | return true |
1052 | 1055 | end |
1053 | 1056 | ... | ... |
src/actions/TowerAction.lua
... | ... | @@ -97,14 +97,14 @@ function _M.endBattleRpc(agent, data) |
97 | 97 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) |
98 | 98 | |
99 | 99 | |
100 | - local reward | |
100 | + local reward, change | |
101 | 101 | if msg.starNum and msg.starNum > 0 then --win |
102 | 102 | curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 |
103 | 103 | --排行榜 |
104 | 104 | role:setTowerRank(towerInfo.l) |
105 | 105 | |
106 | 106 | towerInfo.l = towerInfo.l + 1 |
107 | - reward = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) | |
107 | + reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) | |
108 | 108 | role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) |
109 | 109 | end |
110 | 110 | |
... | ... | @@ -115,7 +115,7 @@ function _M.endBattleRpc(agent, data) |
115 | 115 | |
116 | 116 | role:log("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) |
117 | 117 | |
118 | - SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward})) | |
118 | + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({reward = reward, change = change})) | |
119 | 119 | return true |
120 | 120 | end |
121 | 121 | ... | ... |
src/adv/AdvTask.lua
... | ... | @@ -183,12 +183,12 @@ function AdvTask.bind(Adv) |
183 | 183 | |
184 | 184 | -- 完成主线任务 |
185 | 185 | function Adv:finishMTask() |
186 | - local ok, reward | |
186 | + local ok, reward, change | |
187 | 187 | if self.advMTask.status == -1 then --已完成带领取 |
188 | 188 | local mainTaskData = csvdb["adv_questCsv"][self.advMTask.id] |
189 | 189 | if not mainTaskData then return end |
190 | 190 | if mainTaskData.reward == 1 then |
191 | - reward = self.owner:award(mainTaskData.rewardValue, {log = {desc = "advMainTask", int1 = self.advMTask.id}}) | |
191 | + reward, change = self.owner:award(mainTaskData.rewardValue, {log = {desc = "advMainTask", int1 = self.advMTask.id}}) | |
192 | 192 | end |
193 | 193 | self.advMTask.id = self.advMTask.id + 1 |
194 | 194 | self.advMTask.status = 0 |
... | ... | @@ -204,7 +204,7 @@ function AdvTask.bind(Adv) |
204 | 204 | ok = true |
205 | 205 | advTaskChange.m = true |
206 | 206 | end |
207 | - return ok, reward | |
207 | + return ok, reward, change | |
208 | 208 | end |
209 | 209 | |
210 | 210 | function Adv:updateTask(notNotify) |
... | ... | @@ -388,7 +388,7 @@ function AdvTask.bind(Adv) |
388 | 388 | local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId] |
389 | 389 | local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1 |
390 | 390 | |
391 | - local reward = {} | |
391 | + local reward, change = {} | |
392 | 392 | if status >= achievData.value1 then |
393 | 393 | insertChange(self, chapterId, taskId, -1) |
394 | 394 | local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0 |
... | ... | @@ -396,8 +396,8 @@ function AdvTask.bind(Adv) |
396 | 396 | insertChange(self, chapterId, -1, count) |
397 | 397 | |
398 | 398 | -- 发放奖励 |
399 | - reward = self.owner:award(achievData.reward, {log = {desc = "advAchiev", int1 = chapterId, int2 = taskId}}) | |
400 | - return true, reward | |
399 | + reward, change = self.owner:award(achievData.reward, {log = {desc = "advAchiev", int1 = chapterId, int2 = taskId}}) | |
400 | + return true, reward, change | |
401 | 401 | end |
402 | 402 | end |
403 | 403 | |
... | ... | @@ -408,9 +408,9 @@ function AdvTask.bind(Adv) |
408 | 408 | local status = ((self.owner:getProperty(achievField)[chapterId] or {})["pts"] or {})[taskId] or 0 |
409 | 409 | if status == -1 or count < achievData.pt then return end |
410 | 410 | |
411 | - local reward = self.owner:award(achievData.reward, {log = {desc = "advAchievReward", int1 = chapterId, int2 = taskId}}) | |
411 | + local reward, change = self.owner:award(achievData.reward, {log = {desc = "advAchievReward", int1 = chapterId, int2 = taskId}}) | |
412 | 412 | insertChange(self, chapterId, taskId, -1, true) |
413 | - return true, reward | |
413 | + return true, reward, change | |
414 | 414 | end |
415 | 415 | |
416 | 416 | function Adv:updateAchievement(notNotify) | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -145,10 +145,16 @@ function RolePlugin.bind(Role) |
145 | 145 | end |
146 | 146 | end |
147 | 147 | end |
148 | - | |
148 | + if not next(allChange) then allChange = nil end | |
149 | 149 | return reward, allChange --实际获得的奖励 和 最高级奖励转化过程 |
150 | 150 | end |
151 | 151 | |
152 | + | |
153 | + function Role:packReward(reward, change) | |
154 | + if not reward then return nil end | |
155 | + return {reward = reward, change = change} | |
156 | + end | |
157 | + | |
152 | 158 | function Role:awardExpireItem(expireTime, gift, params) |
153 | 159 | if expireTime <= skynet.timex() then |
154 | 160 | return | ... | ... |