diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 6b5133f..b4e88bd 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -100,8 +100,6 @@ function _M.removeSellRpc( agent, data ) if not sell then return 2 end - role.dinerData:updateSell(slot) - local dish = sell.dish local dishSet = csvdb["diner_dishCsv"][dish] if not dishSet then @@ -116,6 +114,7 @@ function _M.removeSellRpc( agent, data ) return 5 end + role.dinerData:updateSell(slot) local reward = {} local cost = dishData.material:toNumMap() for k, n in pairs(cost) do @@ -123,7 +122,6 @@ function _M.removeSellRpc( agent, data ) role:addItem({itemId = k,count = sum}) reward[k] = sum end - sells[slot].count = 0 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) @@ -187,15 +185,17 @@ function _M.expediteSellRpc( agent, data ) sells = json.decode(role.dinerData:getProperty("sells")) for slot, sell in pairs(sells) do local result = role.dinerData:expediteSell(slot) - local rewards = result.reward:toNumMap() - for k,v in pairs(result.reward:toNumMap()) do - reward = reward:incrv(k,v) - end - popular = popular + result.popular + if result then + local rewards = result.reward:toNumMap() + for k,v in pairs(result.reward:toNumMap()) do + reward = reward:incrv(k,v) + end + popular = popular + result.popular - if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then - if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then - dirty = true + if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then + if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then + dirty = true + end end end end @@ -304,7 +304,7 @@ function _M.talentUpRpc( agent, data ) end sells = json.decode(role.dinerData:getProperty("sells")) for _, sell in pairs(sells) do - if sell.dish == msg.dish then + if sell.dish == msg.dish and sell.count > 0 then return 7 end end -- libgit2 0.21.2