Commit 5a307eb68007a91728c7352fc325f6cfa6878723
1 parent
448dee6b
fix diner
#料理不能追加 #移出料理时只把count设为0,奖励不清空
Showing
1 changed file
with
12 additions
and
9 deletions
Show diff stats
src/actions/DinerAction.lua
| ... | ... | @@ -11,6 +11,10 @@ function _M.addSellRpc( agent, data ) |
| 11 | 11 | local msg = MsgPack.unpack(data) |
| 12 | 12 | for _,sellData in pairs(msg) do |
| 13 | 13 | local slot = sellData.slot |
| 14 | + local sells = json.decode(role.dinerData:getProperty("sells")) | |
| 15 | + if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then | |
| 16 | + return 0 | |
| 17 | + end | |
| 14 | 18 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then |
| 15 | 19 | return 1 |
| 16 | 20 | end |
| ... | ... | @@ -65,19 +69,17 @@ function _M.addSellRpc( agent, data ) |
| 65 | 69 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) |
| 66 | 70 | end |
| 67 | 71 | |
| 68 | - local sells = json.decode(role.dinerData:getProperty("sells")) | |
| 72 | + sells = json.decode(role.dinerData:getProperty("sells")) | |
| 69 | 73 | if not sells[slot] then |
| 70 | 74 | sells[slot] = { |
| 71 | - dish = dish, | |
| 72 | - level = dishLevel, | |
| 73 | 75 | reward = "", |
| 74 | - count = 0, | |
| 75 | 76 | } |
| 76 | 77 | end |
| 77 | - local sell = sells[slot] | |
| 78 | - sell.count = sell.count + count | |
| 79 | - sell.time = skynet.timex() - calSell.deltaTime | |
| 80 | - sell.hot = role.dinerData:getProperty("hot"):getv(sell.dish, 0) | |
| 78 | + sells[slot].dish = dish | |
| 79 | + sells[slot].level = dishLevel | |
| 80 | + sells[slot].count = count | |
| 81 | + sells[slot].time = skynet.timex() - calSell.deltaTime | |
| 82 | + sells[slot].hot = role.dinerData:getProperty("hot"):getv(sells[slot].dish, 0) | |
| 81 | 83 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
| 82 | 84 | end |
| 83 | 85 | SendPacket(actionCodes.Diner_addSellRpc, "") |
| ... | ... | @@ -120,7 +122,8 @@ function _M.removeSellRpc( agent, data ) |
| 120 | 122 | role:addItem({itemId = k,count = sum}) |
| 121 | 123 | reward[k] = sum |
| 122 | 124 | end |
| 123 | - sells[slot] = nil | |
| 125 | + | |
| 126 | + sells[slot].count = 0 | |
| 124 | 127 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
| 125 | 128 | SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) |
| 126 | 129 | return true | ... | ... |