From 020fc7ed8d153f77e9ed4d0b38883767e3cef473 Mon Sep 17 00:00:00 2001 From: gaofengduan <782277855@qq.com> Date: Thu, 30 May 2019 16:31:14 +0800 Subject: [PATCH] fix diner expediteSellRpc --- src/actions/DinerAction.lua | 26 ++++++++++++++++++-------- src/csvdata | 2 +- src/models/Diner.lua | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index cff8628..5a93fc8 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -167,24 +167,31 @@ end function _M.expediteSellRpc( agent, data ) local role = agent.role + local count = role.dinerData:getProperty("expedite") + local max = #globalCsv.diner_sell_quick_cost + if count > max then + return 1 + end + local cost = {[ItemId.Diamond] = globalCsv.diner_sell_quick_cost[count]} + if not role:checkItemEnough(cost) then + return 2 + end + role:costItems(cost) + local dirty = false - local reward = "" + local reward,popular = "",0 local sells = json.decode(role.dinerData:getProperty("sells")) 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 - sells[slot].time = sell.time - 7200 - end - role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) - sells = json.decode(role.dinerData:getProperty("sells")) - for slot, sell in pairs(sells) do - local result = role.dinerData:updateSell(slot) + local result = role.dinerData:expediteSell(slot) local rewards = result.reward:toNumMap() for k,v in pairs(result.reward:toNumMap()) do reward = reward:incrv(k,v) end + popular = popular + result.popular if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then @@ -193,6 +200,9 @@ function _M.expediteSellRpc( agent, data ) end end + role.dinerData:notifyUpdateProperty("sells", role.dinerData:getProperty("sells")) + role.dinerData:setProperty("expedite",count+1) + role.dinerData:notifyUpdateProperty("expedite", count+1) for k, v in pairs(reward:toNumMap()) do role:addItem({itemId = k,count = v}) end @@ -200,7 +210,7 @@ function _M.expediteSellRpc( agent, data ) if dirty then role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) end - SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward})) + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular})) return true end diff --git a/src/csvdata b/src/csvdata index d5fa8b0..b63481c 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit d5fa8b0f1b76687832b6c74ba250e493947b1e1a +Subproject commit b63481c6e21c451137904457472445d96d802131 diff --git a/src/models/Diner.lua b/src/models/Diner.lua index f799daf..f549ae0 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -12,6 +12,7 @@ Diner.schema = { dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 skillTree = {"string", ""}, -- 支援天赋 popular = {"number",0}, -- 累计人气 + expedite = {"number",1} } function Diner:refreshDailyData(notify) @@ -43,6 +44,9 @@ function Diner:refreshDailyData(notify) self:updateProperty({field = "hot", value = hot, notNotify = not notify}) self:setProperty("hot", hot) end + -- 每日加速次数 + self:updateProperty({field = "expedite", value = 1, notNotify = not notify}) + self:setProperty("expedite", 1) -- 特殊订单 local orders = json.decode(self:getProperty("order")) @@ -200,6 +204,38 @@ function Diner:updateSell(slot, calOnly) } end +function Diner:expediteSell(slot) + local sells = json.decode(self:getProperty("sells")) + local sell = sells[slot] + if not sell or sell.count <= 0 then + return + end + local dishData = csvdb["diner_dishCsv"][sell.dish][sell.level] + local expediteCount = 0 + local expediteTime = 7200 + local sellTime = dishData.sell_time + if slot.hot then + sellTime = sellTime * dishData.popularity + end + expediteCount = math.floor(expediteTime / sellTime) + expediteCount = math.min(expediteCount, sell.count) + local lastCount = sell.count - expediteCount + local reward, popular = self:calSellReward(sell, expediteCount, dishData) + + if expediteCount > 0 then + sells[slot].count = lastCount + self:setProperty("sells", json.encode(sells)) + self:incrProperty("popular",popular) + self:checkDinerTask(DinerTask.SellDish, expediteCount, sell.dish) + end + return { + expediteCount = expediteCount, + lastCount = lastCount, + reward = reward, + popular = popular, + } +end + function Diner:getMaxSlots() local slotCount = globalCsv.diner_sell_slots_init @@ -226,7 +262,7 @@ function Diner:getMaxDishs() end function Diner:data() - local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular"} + local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular","expedite"} local data = self:getProperties(properties) return data end -- libgit2 0.21.2