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