diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index c2e2a59..a250a2a 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -67,6 +67,7 @@ actionCodes = { Diner_lockTaskRpc = 307, Diner_updateTaskRpc = 308, Diner_refreshTaskRpc = 309, + Diner_expediteSellRpc = 310, } rpcResponseBegin = 10000 diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index f784abc..cff8628 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -100,6 +100,7 @@ function _M.removeSellRpc( agent, data ) if not sell then return 2 end + role.dinerData:updateSell(slot) local dish = sell.dish local dishSet = csvdb["diner_dishCsv"][dish] @@ -164,6 +165,45 @@ function _M.getSellRewardRpc( agent, data ) return true end +function _M.expediteSellRpc( agent, data ) + local role = agent.role + local dirty = false + local reward = "" + 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 rewards = result.reward:toNumMap() + for k,v in pairs(result.reward:toNumMap()) do + reward = reward:incrv(k,v) + end + + 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 + end + + 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 + SendPacket(actionCodes.Diner_expediteSellRpc, MsgPack.pack({reward = reward})) + return true +end + function _M.levelUpRpc( agent, data ) local role = agent.role local msg = MsgPack.unpack(data) diff --git a/src/csvdata b/src/csvdata index 322f4a5..d5fa8b0 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 322f4a5db56d1e952f0edee648d346a79449de37 +Subproject commit d5fa8b0f1b76687832b6c74ba250e493947b1e1a diff --git a/src/models/Diner.lua b/src/models/Diner.lua index 3d4affa..f799daf 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -179,9 +179,9 @@ function Diner:updateSell(slot, calOnly) end deltaCount = math.min(deltaCount, sell.count) local lastCount = sell.count - deltaCount + local reward, popular = self:calSellReward(sell, deltaCount, dishData) if not calOnly and deltaCount > 0 then - local reward, popular = self:calSellReward(sell, deltaCount, dishData) sells[slot].time = skynet.timex() - deltaTime sells[slot].count = lastCount sells[slot].level = self:getProperty("dishTree"):getv(sell.dish, 1) @@ -195,6 +195,8 @@ function Diner:updateSell(slot, calOnly) deltaCount = deltaCount, deltaTime = deltaTime, lastCount = lastCount, + reward = reward, + popular = popular, } end -- libgit2 0.21.2