From 4288160b8d8e8a5a16c2d5803d3864655944c833 Mon Sep 17 00:00:00 2001 From: gaofengduan <782277855@qq.com> Date: Thu, 30 May 2019 20:38:23 +0800 Subject: [PATCH] add Diner_getGreenhouseRpc --- src/ProtocolCode.lua | 1 + src/actions/DinerAction.lua | 30 ++++++++++++++++++++++++++++++ src/csvdata | 2 +- src/models/Diner.lua | 15 ++++++++------- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index a250a2a..cde77fc 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -68,6 +68,7 @@ actionCodes = { Diner_updateTaskRpc = 308, Diner_refreshTaskRpc = 309, Diner_expediteSellRpc = 310, + Diner_getGreenhouseRpc = 311, } rpcResponseBegin = 10000 diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index 5a93fc8..f1f2b7c 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -451,5 +451,35 @@ function _M.refreshTaskRpc( agent, data ) return true end +function _M.getGreenhouseRpc( agent, data ) + local role = agent.role + local msg = MsgPack.unpack(data) + + local buildType = 6 + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) + local buildingData = csvdb["diner_buildingCsv"][buildType][level] + if not buildingData then + return 1 + end + if buildingData.speed <= 0 then + return 2 + end + + local reward = "" + local now = skynet.timex() + local timePass = now - role.dinerData:getProperty("gTime") + role.dinerData:setProperty("gTime",now) + role.dinerData:notifyUpdateProperty("gTime",now) + local count = math.floor(timePass/buildingData.speed) + count = math.min(count,buildingData.storage) + for _=1,count do + reward = reward:incrv(string.randWeight(buildingData.gift_normal), 1) + end + for k, v in pairs(reward:toNumMap()) do + role:addItem({itemId = k,count = v}) + end + SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward})) + return true +end return _M \ No newline at end of file diff --git a/src/csvdata b/src/csvdata index b63481c..b3c136e 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit b63481c6e21c451137904457472445d96d802131 +Subproject commit b3c136ed3c1915513552fe327ec0e724a1acb35c diff --git a/src/models/Diner.lua b/src/models/Diner.lua index 81d5f03..1af7953 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -5,14 +5,15 @@ function Diner:ctor(properties) end Diner.schema = { - buildL = {"string", ""}, -- 家具等级 1=1 2=1 3=1 - order = {"string", "[]"}, -- 特殊订单 - sells = {"string", "[]"}, -- 贩卖位置 - hot = {"string", ""}, -- 今日热门 + buildL = {"string", ""}, -- 家具等级 1=1 2=1 3=1 + order = {"string", "[]"}, -- 特殊订单 + sells = {"string", "[]"}, -- 贩卖位置 + hot = {"string", ""}, -- 今日热门 dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 skillTree = {"string", ""}, -- 支援天赋 - popular = {"number",0}, -- 累计人气 - expedite = {"number",1} + popular = {"number",0}, -- 累计人气 + expedite = {"number",1}, --每日加速次数 + gTime = {"number",skynet.timex()}, --温室最后一次领取时间 } function Diner:refreshDailyData(notify) @@ -263,7 +264,7 @@ function Diner:getMaxDishs() end function Diner:data() - local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular","expedite"} + local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular","expedite","gTime"} local data = self:getProperties(properties) return data end -- libgit2 0.21.2