From 3216156993407d0a68eac5e5a216a924b77746fe Mon Sep 17 00:00:00 2001 From: gaofengduan <782277855@qq.com> Date: Mon, 27 May 2019 11:28:38 +0800 Subject: [PATCH] fix diner --- src/actions/DinerAction.lua | 10 ++++++---- src/csvdata | 2 +- src/models/Diner.lua | 10 +++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index e604108..67a690e 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -130,28 +130,30 @@ end function _M.getSellRewardRpc( agent, data ) local role = agent.role local dirty = false - local reward = "" local sells = json.decode(role.dinerData:getProperty("sells")) - for slot, sell in pairs(sells) do + for slot, _ in pairs(sells) do role.dinerData:updateSell(slot) + end + sells = json.decode(role.dinerData:getProperty("sells")) + for slot, sell in pairs(sells) do local rewards = sell.reward:toNumMap() for k,v in pairs(rewards) do reward = reward:incrv(k, v) end - sells[slot].reward = "" 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 + sells[slot].reward = "" end - role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) for k, v in pairs(reward:toNumMap()) do role:addItem({itemId = k,count = v}) end + if dirty then role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) end diff --git a/src/csvdata b/src/csvdata index d52d26e..01cf508 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit d52d26ecb27c5bc5e532d033544cae9917434ea5 +Subproject commit 01cf508187c65894bed310be2d903087b86f0255 diff --git a/src/models/Diner.lua b/src/models/Diner.lua index b0ef9f3..dfcb2be 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -173,11 +173,11 @@ function Diner:updateSell(slot, calOnly) if not calOnly then local reward, popular = self:calSellReward(sell, deltaCount, dishData) - sell.time = skynet.timex() - deltaTime - sell.count = lastCount - sell.level = self:getProperty("dishTree"):getv(sell.dish, 1) - sell.hot = self:getProperty("hot"):getv(sell.dish, 0) - sell.reward = reward + sells[slot].time = skynet.timex() - deltaTime + sells[slot].count = lastCount + sells[slot].level = self:getProperty("dishTree"):getv(sell.dish, 1) + sells[slot].hot = self:getProperty("hot"):getv(sell.dish, 0) + sells[slot].reward = reward self:setProperty("sells", json.encode(sells)) self:incrProperty("popular",popular) -- libgit2 0.21.2