From 84e7c06eace294ea35bd4b07195887cf64ab4cf2 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Wed, 7 Aug 2019 10:19:39 +0800 Subject: [PATCH] 回收 --- src/actions/RoleAction.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index be4466b..5748331 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -278,15 +278,20 @@ end function _M.saleItemRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) - local itemId = msg.itemId - local count = msg.count - if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end - local itemData = csvdb["itemCsv"][itemId] - if itemData.sell_effect == "" then return end - local sellEffect = itemData.sell_effect:toArray(true, "=") - - role:costItems({[itemId] = count}) - local reward = role:award({[sellEffect[1]] = sellEffect[2] * count}) + local backs = msg.backs + if not backs then return end + + local reward = {} + for itemId, count in pairs(backs) do + if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end + local itemData = csvdb["itemCsv"][itemId] + if itemData.sell_effect == "" then return end + local sellEffect = itemData.sell_effect:toArray(true, "=") + reward[sellEffect[1]] = (reward[sellEffect[1]] or 0) + sellEffect[2] * count + end + + role:costItems(backs) + local reward = role:award(reward) SendPacket(actionCodes.Role_saleItemRpc, MsgPack.pack({reward = reward})) return true -- libgit2 0.21.2