Commit 2050d40dda776e6bab9309de51fb34bbc2d7bd8a

Authored by gaofengduan
1 parent 5a307eb6

add diner expediteSellRpc

src/ProtocolCode.lua
@@ -67,6 +67,7 @@ actionCodes = { @@ -67,6 +67,7 @@ actionCodes = {
67 Diner_lockTaskRpc = 307, 67 Diner_lockTaskRpc = 307,
68 Diner_updateTaskRpc = 308, 68 Diner_updateTaskRpc = 308,
69 Diner_refreshTaskRpc = 309, 69 Diner_refreshTaskRpc = 309,
  70 + Diner_expediteSellRpc = 310,
70 } 71 }
71 72
72 rpcResponseBegin = 10000 73 rpcResponseBegin = 10000
src/actions/DinerAction.lua
@@ -100,6 +100,7 @@ function _M.removeSellRpc( agent, data ) @@ -100,6 +100,7 @@ function _M.removeSellRpc( agent, data )
100 if not sell then 100 if not sell then
101 return 2 101 return 2
102 end 102 end
  103 + role.dinerData:updateSell(slot)
103 104
104 local dish = sell.dish 105 local dish = sell.dish
105 local dishSet = csvdb["diner_dishCsv"][dish] 106 local dishSet = csvdb["diner_dishCsv"][dish]
@@ -164,6 +165,45 @@ function _M.getSellRewardRpc( agent, data ) @@ -164,6 +165,45 @@ function _M.getSellRewardRpc( agent, data )
164 return true 165 return true
165 end 166 end
166 167
  168 +function _M.expediteSellRpc( agent, data )
  169 + local role = agent.role
  170 + local dirty = false
  171 + local reward = ""
  172 + local sells = json.decode(role.dinerData:getProperty("sells"))
  173 + for slot, _ in pairs(sells) do
  174 + role.dinerData:updateSell(slot)
  175 + end
  176 + sells = json.decode(role.dinerData:getProperty("sells"))
  177 + 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)
  184 + local rewards = result.reward:toNumMap()
  185 + for k,v in pairs(result.reward:toNumMap()) do
  186 + reward = reward:incrv(k,v)
  187 + end
  188 +
  189 + 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
  191 + dirty = true
  192 + end
  193 + end
  194 + end
  195 +
  196 + for k, v in pairs(reward:toNumMap()) do
  197 + role:addItem({itemId = k,count = v})
  198 + end
  199 +
  200 + if dirty then
  201 + role.dinerData:notifyUpdateProperty("order", role.dinerData:getProperty("order"))
  202 + end
  203 + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward}))
  204 + return true
  205 +end
  206 +
167 function _M.levelUpRpc( agent, data ) 207 function _M.levelUpRpc( agent, data )
168 local role = agent.role 208 local role = agent.role
169 local msg = MsgPack.unpack(data) 209 local msg = MsgPack.unpack(data)
1 -Subproject commit 322f4a5db56d1e952f0edee648d346a79449de37 1 +Subproject commit d5fa8b0f1b76687832b6c74ba250e493947b1e1a
src/models/Diner.lua
@@ -179,9 +179,9 @@ function Diner:updateSell(slot, calOnly) @@ -179,9 +179,9 @@ function Diner:updateSell(slot, calOnly)
179 end 179 end
180 deltaCount = math.min(deltaCount, sell.count) 180 deltaCount = math.min(deltaCount, sell.count)
181 local lastCount = sell.count - deltaCount 181 local lastCount = sell.count - deltaCount
  182 + local reward, popular = self:calSellReward(sell, deltaCount, dishData)
182 183
183 if not calOnly and deltaCount > 0 then 184 if not calOnly and deltaCount > 0 then
184 - local reward, popular = self:calSellReward(sell, deltaCount, dishData)  
185 sells[slot].time = skynet.timex() - deltaTime 185 sells[slot].time = skynet.timex() - deltaTime
186 sells[slot].count = lastCount 186 sells[slot].count = lastCount
187 sells[slot].level = self:getProperty("dishTree"):getv(sell.dish, 1) 187 sells[slot].level = self:getProperty("dishTree"):getv(sell.dish, 1)
@@ -195,6 +195,8 @@ function Diner:updateSell(slot, calOnly) @@ -195,6 +195,8 @@ function Diner:updateSell(slot, calOnly)
195 deltaCount = deltaCount, 195 deltaCount = deltaCount,
196 deltaTime = deltaTime, 196 deltaTime = deltaTime,
197 lastCount = lastCount, 197 lastCount = lastCount,
  198 + reward = reward,
  199 + popular = popular,
198 } 200 }
199 end 201 end
200 202