Commit e68ee005598cf8beb9ce123c3489a3f71d5b336b

Authored by liuzujun
2 parents 3e20f499 d6a66c74

Merge code

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