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,6 +11,10 @@ function _M.addSellRpc( agent, data ) | ||
11 | local msg = MsgPack.unpack(data) | 11 | local msg = MsgPack.unpack(data) |
12 | for _,sellData in pairs(msg) do | 12 | for _,sellData in pairs(msg) do |
13 | local slot = sellData.slot | 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 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then | 18 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then |
15 | return 1 | 19 | return 1 |
16 | end | 20 | end |
@@ -65,19 +69,17 @@ function _M.addSellRpc( agent, data ) | @@ -65,19 +69,17 @@ function _M.addSellRpc( agent, data ) | ||
65 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) | 69 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) |
66 | end | 70 | end |
67 | 71 | ||
68 | - local sells = json.decode(role.dinerData:getProperty("sells")) | 72 | + sells = json.decode(role.dinerData:getProperty("sells")) |
69 | if not sells[slot] then | 73 | if not sells[slot] then |
70 | sells[slot] = { | 74 | sells[slot] = { |
71 | - dish = dish, | ||
72 | - level = dishLevel, | ||
73 | reward = "", | 75 | reward = "", |
74 | - count = 0, | ||
75 | } | 76 | } |
76 | end | 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 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) | 83 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
82 | end | 84 | end |
83 | SendPacket(actionCodes.Diner_addSellRpc, "") | 85 | SendPacket(actionCodes.Diner_addSellRpc, "") |
@@ -120,7 +122,8 @@ function _M.removeSellRpc( agent, data ) | @@ -120,7 +122,8 @@ function _M.removeSellRpc( agent, data ) | ||
120 | role:addItem({itemId = k,count = sum}) | 122 | role:addItem({itemId = k,count = sum}) |
121 | reward[k] = sum | 123 | reward[k] = sum |
122 | end | 124 | end |
123 | - sells[slot] = nil | 125 | + |
126 | + sells[slot].count = 0 | ||
124 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) | 127 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
125 | SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) | 128 | SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) |
126 | return true | 129 | return true |