From 1ab9458f4c0df3b659357a88a3e7fda0e63d25dc Mon Sep 17 00:00:00 2001 From: gaofengduan <782277855@qq.com> Date: Wed, 22 May 2019 17:39:50 +0800 Subject: [PATCH] add δΈ‹θœζ“δ½œ --- src/ProtocolCode.lua | 1 + src/actions/DinerAction.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 0 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 51142ff..e44bd88 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -63,6 +63,7 @@ actionCodes = { Diner_levelUpRpc = 303, Diner_talentUpRpc = 304, Diner_skillUpRpc = 305, + Diner_removeSellRpc = 306, } rpcResponseBegin = 10000 diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 4d2fd0f..6325939 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -72,6 +72,48 @@ function _M.addSellRpc( agent, data ) return true end +function _M.removeSellRpc( agent, data ) + local role = agent.role + local msg = MsgPack.unpack(data) + + local slot = msg.slot + if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then + return 1 + end + slot = tostring(slot) + local sells = json.decode(role.dinerData:getProperty("sells")) + local sell = sells[slot] + if not sell then + return 2 + end + + local dish = sell.dish + local dishSet = csvdb["diner_dishCsv"][dish] + if not dishSet then + return 3 + end + local dishLevel = role.dinerData:getProperty("dishTree"):getv(dish, 0) + if dishLevel == 0 then + return 4 + end + local dishData = dishSet[dishLevel] + if not dishData then + return 5 + end + + local reward = {} + local cost = dishData.material:toNumMap() + for k, n in pairs(cost) do + local sum = n*sell.count + role:addItem({itemId = k,count = sum}) + reward[k] = sum + end + sells[slot] = nil + role.dinerData:updateProperty({field = "sells", value = json.encode(sells)}) + SendPacket(actionCodes.Diner_removeSellRpc, MsgPack.pack({reward = reward})) + return true +end + function _M.getSellRewardRpc( agent, data ) end -- libgit2 0.21.2