Commit 020fc7ed8d153f77e9ed4d0b38883767e3cef473

Authored by gaofengduan
1 parent 2050d40d

fix diner expediteSellRpc

src/actions/DinerAction.lua
@@ -167,24 +167,31 @@ end @@ -167,24 +167,31 @@ end
167 167
168 function _M.expediteSellRpc( agent, data ) 168 function _M.expediteSellRpc( agent, data )
169 local role = agent.role 169 local role = agent.role
  170 + local count = role.dinerData:getProperty("expedite")
  171 + local max = #globalCsv.diner_sell_quick_cost
  172 + if count > max then
  173 + return 1
  174 + end
  175 + local cost = {[ItemId.Diamond] = globalCsv.diner_sell_quick_cost[count]}
  176 + if not role:checkItemEnough(cost) then
  177 + return 2
  178 + end
  179 + role:costItems(cost)
  180 +
170 local dirty = false 181 local dirty = false
171 - local reward = "" 182 + local reward,popular = "",0
172 local sells = json.decode(role.dinerData:getProperty("sells")) 183 local sells = json.decode(role.dinerData:getProperty("sells"))
173 for slot, _ in pairs(sells) do 184 for slot, _ in pairs(sells) do
174 role.dinerData:updateSell(slot) 185 role.dinerData:updateSell(slot)
175 end 186 end
176 sells = json.decode(role.dinerData:getProperty("sells")) 187 sells = json.decode(role.dinerData:getProperty("sells"))
177 for slot, sell in pairs(sells) do 188 for slot, sell in pairs(sells) do
178 - sells[slot].time = sell.time - 7200  
179 - end  
180 - role.dinerData:updateProperty({field = "sells", value = json.encode(sells)})  
181 - sells = json.decode(role.dinerData:getProperty("sells"))  
182 - for slot, sell in pairs(sells) do  
183 - local result = role.dinerData:updateSell(slot) 189 + local result = role.dinerData:expediteSell(slot)
184 local rewards = result.reward:toNumMap() 190 local rewards = result.reward:toNumMap()
185 for k,v in pairs(result.reward:toNumMap()) do 191 for k,v in pairs(result.reward:toNumMap()) do
186 reward = reward:incrv(k,v) 192 reward = reward:incrv(k,v)
187 end 193 end
  194 + popular = popular + result.popular
188 195
189 if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then 196 if rewards[ItemId.Gold] and rewards[ItemId.Gold] > 0 then
190 if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then 197 if role.dinerData:checkDinerTask(DinerTask.DishWithGold, rewards[ItemId.Gold], sell.dish, nil, true) then
@@ -193,6 +200,9 @@ function _M.expediteSellRpc( agent, data ) @@ -193,6 +200,9 @@ function _M.expediteSellRpc( agent, data )
193 end 200 end
194 end 201 end
195 202
  203 + role.dinerData:notifyUpdateProperty("sells", role.dinerData:getProperty("sells"))
  204 + role.dinerData:setProperty("expedite",count+1)
  205 + role.dinerData:notifyUpdateProperty("expedite", count+1)
196 for k, v in pairs(reward:toNumMap()) do 206 for k, v in pairs(reward:toNumMap()) do
197 role:addItem({itemId = k,count = v}) 207 role:addItem({itemId = k,count = v})
198 end 208 end
@@ -200,7 +210,7 @@ function _M.expediteSellRpc( agent, data ) @@ -200,7 +210,7 @@ function _M.expediteSellRpc( agent, data )
200 if dirty then 210 if dirty then
201 role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order")) 211 role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order"))
202 end 212 end
203 - SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward})) 213 + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward,popular = popular}))
204 return true 214 return true
205 end 215 end
206 216
1 -Subproject commit d5fa8b0f1b76687832b6c74ba250e493947b1e1a 1 +Subproject commit b63481c6e21c451137904457472445d96d802131
src/models/Diner.lua
@@ -12,6 +12,7 @@ Diner.schema = { @@ -12,6 +12,7 @@ Diner.schema = {
12 dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 12 dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋
13 skillTree = {"string", ""}, -- 支援天赋 13 skillTree = {"string", ""}, -- 支援天赋
14 popular = {"number",0}, -- 累计人气 14 popular = {"number",0}, -- 累计人气
  15 + expedite = {"number",1}
15 } 16 }
16 17
17 function Diner:refreshDailyData(notify) 18 function Diner:refreshDailyData(notify)
@@ -43,6 +44,9 @@ function Diner:refreshDailyData(notify) @@ -43,6 +44,9 @@ function Diner:refreshDailyData(notify)
43 self:updateProperty({field = "hot", value = hot, notNotify = not notify}) 44 self:updateProperty({field = "hot", value = hot, notNotify = not notify})
44 self:setProperty("hot", hot) 45 self:setProperty("hot", hot)
45 end 46 end
  47 + -- 每日加速次数
  48 + self:updateProperty({field = "expedite", value = 1, notNotify = not notify})
  49 + self:setProperty("expedite", 1)
46 50
47 -- 特殊订单 51 -- 特殊订单
48 local orders = json.decode(self:getProperty("order")) 52 local orders = json.decode(self:getProperty("order"))
@@ -200,6 +204,38 @@ function Diner:updateSell(slot, calOnly) @@ -200,6 +204,38 @@ function Diner:updateSell(slot, calOnly)
200 } 204 }
201 end 205 end
202 206
  207 +function Diner:expediteSell(slot)
  208 + local sells = json.decode(self:getProperty("sells"))
  209 + local sell = sells[slot]
  210 + if not sell or sell.count <= 0 then
  211 + return
  212 + end
  213 + local dishData = csvdb["diner_dishCsv"][sell.dish][sell.level]
  214 + local expediteCount = 0
  215 + local expediteTime = 7200
  216 + local sellTime = dishData.sell_time
  217 + if slot.hot then
  218 + sellTime = sellTime * dishData.popularity
  219 + end
  220 + expediteCount = math.floor(expediteTime / sellTime)
  221 + expediteCount = math.min(expediteCount, sell.count)
  222 + local lastCount = sell.count - expediteCount
  223 + local reward, popular = self:calSellReward(sell, expediteCount, dishData)
  224 +
  225 + if expediteCount > 0 then
  226 + sells[slot].count = lastCount
  227 + self:setProperty("sells", json.encode(sells))
  228 + self:incrProperty("popular",popular)
  229 + self:checkDinerTask(DinerTask.SellDish, expediteCount, sell.dish)
  230 + end
  231 + return {
  232 + expediteCount = expediteCount,
  233 + lastCount = lastCount,
  234 + reward = reward,
  235 + popular = popular,
  236 + }
  237 +end
  238 +
203 function Diner:getMaxSlots() 239 function Diner:getMaxSlots()
204 local slotCount = globalCsv.diner_sell_slots_init 240 local slotCount = globalCsv.diner_sell_slots_init
205 241
@@ -226,7 +262,7 @@ function Diner:getMaxDishs() @@ -226,7 +262,7 @@ function Diner:getMaxDishs()
226 end 262 end
227 263
228 function Diner:data() 264 function Diner:data()
229 - local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular"} 265 + local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular","expedite"}
230 local data = self:getProperties(properties) 266 local data = self:getProperties(properties)
231 return data 267 return data
232 end 268 end