diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index e7aae65..f784abc 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -11,6 +11,10 @@ function _M.addSellRpc( agent, data ) local msg = MsgPack.unpack(data) for _,sellData in pairs(msg) do local slot = sellData.slot + local sells = json.decode(role.dinerData:getProperty("sells")) + if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then + return 0 + end if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then return 1 end @@ -65,19 +69,17 @@ function _M.addSellRpc( agent, data ) role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) end - local sells = json.decode(role.dinerData:getProperty("sells")) + sells = json.decode(role.dinerData:getProperty("sells")) if not sells[slot] then sells[slot] = { - dish = dish, - level = dishLevel, reward = "", - count = 0, } end - local sell = sells[slot] - sell.count = sell.count + count - sell.time = skynet.timex() - calSell.deltaTime - sell.hot = role.dinerData:getProperty("hot"):getv(sell.dish, 0) + sells[slot].dish = dish + sells[slot].level = dishLevel + sells[slot].count = count + sells[slot].time = skynet.timex() - calSell.deltaTime + sells[slot].hot = role.dinerData:getProperty("hot"):getv(sells[slot].dish, 0) role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) end SendPacket(actionCodes.Diner_addSellRpc, "") @@ -120,7 +122,8 @@ function _M.removeSellRpc( agent, data ) role:addItem({itemId = k,count = sum}) reward[k] = sum end - sells[slot] = nil + + sells[slot].count = 0 role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) return true -- libgit2 0.21.2