Commit 3216156993407d0a68eac5e5a216a924b77746fe
1 parent
bc365ba7
fix diner
Showing
3 changed files
with
12 additions
and
10 deletions
Show diff stats
src/actions/DinerAction.lua
@@ -130,28 +130,30 @@ end | @@ -130,28 +130,30 @@ end | ||
130 | function _M.getSellRewardRpc( agent, data ) | 130 | function _M.getSellRewardRpc( agent, data ) |
131 | local role = agent.role | 131 | local role = agent.role |
132 | local dirty = false | 132 | local dirty = false |
133 | - | ||
134 | local reward = "" | 133 | local reward = "" |
135 | local sells = json.decode(role.dinerData:getProperty("sells")) | 134 | local sells = json.decode(role.dinerData:getProperty("sells")) |
136 | - for slot, sell in pairs(sells) do | 135 | + for slot, _ in pairs(sells) do |
137 | role.dinerData:updateSell(slot) | 136 | role.dinerData:updateSell(slot) |
137 | + end | ||
138 | + sells = json.decode(role.dinerData:getProperty("sells")) | ||
139 | + for slot, sell in pairs(sells) do | ||
138 | local rewards = sell.reward:toNumMap() | 140 | local rewards = sell.reward:toNumMap() |
139 | for k,v in pairs(rewards) do | 141 | for k,v in pairs(rewards) do |
140 | reward = reward:incrv(k, v) | 142 | reward = reward:incrv(k, v) |
141 | end | 143 | end |
142 | - sells[slot].reward = "" | ||
143 | 144 | ||
144 | if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then | 145 | if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then |
145 | if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then | 146 | if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then |
146 | dirty = true | 147 | dirty = true |
147 | end | 148 | end |
148 | end | 149 | end |
150 | + sells[slot].reward = "" | ||
149 | end | 151 | end |
150 | - | ||
151 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) | 152 | role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) |
152 | for k, v in pairs(reward:toNumMap()) do | 153 | for k, v in pairs(reward:toNumMap()) do |
153 | role:addItem({itemId = k,count = v}) | 154 | role:addItem({itemId = k,count = v}) |
154 | end | 155 | end |
156 | + | ||
155 | if dirty then | 157 | if dirty then |
156 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) | 158 | role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) |
157 | end | 159 | end |
src/models/Diner.lua
@@ -173,11 +173,11 @@ function Diner:updateSell(slot, calOnly) | @@ -173,11 +173,11 @@ function Diner:updateSell(slot, calOnly) | ||
173 | 173 | ||
174 | if not calOnly then | 174 | if not calOnly then |
175 | local reward, popular = self:calSellReward(sell, deltaCount, dishData) | 175 | local reward, popular = self:calSellReward(sell, deltaCount, dishData) |
176 | - sell.time = skynet.timex() - deltaTime | ||
177 | - sell.count = lastCount | ||
178 | - sell.level = self:getProperty("dishTree"):getv(sell.dish, 1) | ||
179 | - sell.hot = self:getProperty("hot"):getv(sell.dish, 0) | ||
180 | - sell.reward = reward | 176 | + sells[slot].time = skynet.timex() - deltaTime |
177 | + sells[slot].count = lastCount | ||
178 | + sells[slot].level = self:getProperty("dishTree"):getv(sell.dish, 1) | ||
179 | + sells[slot].hot = self:getProperty("hot"):getv(sell.dish, 0) | ||
180 | + sells[slot].reward = reward | ||
181 | self:setProperty("sells", json.encode(sells)) | 181 | self:setProperty("sells", json.encode(sells)) |
182 | self:incrProperty("popular",popular) | 182 | self:incrProperty("popular",popular) |
183 | 183 |