From f5c07b1b12de128667c51fc5afd63819778b7e0f Mon Sep 17 00:00:00 2001 From: gaofengduan <782277855@qq.com> Date: Fri, 24 May 2019 17:19:17 +0800 Subject: [PATCH] fix diner --- .luacheckrc | 1 + src/actions/DinerAction.lua | 17 ++++++----------- src/csvdata | 2 +- src/models/Diner.lua | 14 ++++++++------ 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 4175901..ec98b41 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,5 +1,6 @@ std = "max" globals = { + "DinerTask", "SendPipelining", "AdvEventType", "class", diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index b959baf..22efc26 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -72,7 +72,6 @@ function _M.addSellRpc( agent, data ) level = dishLevel, reward = "", count = 0, - famous = 0, } end local sell = sells[slot] @@ -130,20 +129,15 @@ end function _M.getSellRewardRpc( agent, data ) local role = agent.role - local reward = {} local dirty = false + local reward = "" local sells = json.decode(role.dinerData:getProperty("sells")) - for slot,sell in pairs(sells) do + for slot, sell in pairs(sells) do role.dinerData:updateSell(slot) - local rewards = sell.reward:toNumMap() for k,v in pairs(rewards) do - if reward[k] then - reward[k] = reward[k] + v - else - reward[k] = v - end + reward = reward:incrv(k, v) end sells[slot].reward = "" @@ -153,14 +147,15 @@ function _M.getSellRewardRpc( agent, data ) end end end - for k, v in pairs(reward) do + + 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.dishData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) end - role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) SendPacket(actionCodes.Diner_getSellRewardRpc, MsgPack.pack({reward = reward})) return true end diff --git a/src/csvdata b/src/csvdata index a877f94..d52d26e 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit a877f94b084a3571e2f3d57e4997fd00c0a51eaf +Subproject commit d52d26ecb27c5bc5e532d033544cae9917434ea5 diff --git a/src/models/Diner.lua b/src/models/Diner.lua index 47c216c..d3e27e4 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -60,7 +60,7 @@ function Diner:refreshDailyData(notify) end end end - self:updateProperty({field = "order", value = json.encode(orders)), notNotify = not notify}) + self:updateProperty({field = "order", value = json.encode(orders), notNotify = not notify}) end function Diner:updateProperty(params) @@ -105,24 +105,25 @@ function Diner:checkDinerTask(type, count, param1, param2, notNotify) end end if dirty then - self:updateProperty({field = "order", value = json.encode(orders)), notNotify = notNotify}) + self:updateProperty({field = "order", value = json.encode(orders), notNotify = notNotify}) end return dirty end function Diner:calSellReward(sell, delta, dishData) + echoLog("calSellReward delta ",delta) local reward = sell.reward or "" local popular = 0 if delta <= 0 then return reward, popular end - for type, value in pairs(dishData.item_normal:toNumMap()) do - reward = reward:incrv(type, value * delta) + for key, value in pairs(dishData.item_normal:toNumMap()) do + reward = reward:incrv(key, value * delta) end popular = popular + dishData.famous_normal * delta if sell.hot > 0 then - for type, value in pairs(dishData.item_popular:toNumMap()) do - reward = reward:incrv(type, value * delta) + for key, value in pairs(dishData.item_popular:toNumMap()) do + reward = reward:incrv(key, value * delta) end popular = popular + dishData.famous_popular * delta end @@ -148,6 +149,7 @@ function Diner:calSellReward(sell, delta, dishData) popular = math.floor(popular * (100 + buildData.famous_up) / 100) end end + echoLog("calSellReward reward ",reward,popular) return reward, popular end -- libgit2 0.21.2