Commit 4288160b8d8e8a5a16c2d5803d3864655944c833
1 parent
55289e78
add Diner_getGreenhouseRpc
Showing
4 changed files
with
40 additions
and
8 deletions
Show diff stats
src/ProtocolCode.lua
@@ -68,6 +68,7 @@ actionCodes = { | @@ -68,6 +68,7 @@ actionCodes = { | ||
68 | Diner_updateTaskRpc = 308, | 68 | Diner_updateTaskRpc = 308, |
69 | Diner_refreshTaskRpc = 309, | 69 | Diner_refreshTaskRpc = 309, |
70 | Diner_expediteSellRpc = 310, | 70 | Diner_expediteSellRpc = 310, |
71 | + Diner_getGreenhouseRpc = 311, | ||
71 | } | 72 | } |
72 | 73 | ||
73 | rpcResponseBegin = 10000 | 74 | rpcResponseBegin = 10000 |
src/actions/DinerAction.lua
@@ -451,5 +451,35 @@ function _M.refreshTaskRpc( agent, data ) | @@ -451,5 +451,35 @@ function _M.refreshTaskRpc( agent, data ) | ||
451 | return true | 451 | return true |
452 | end | 452 | end |
453 | 453 | ||
454 | +function _M.getGreenhouseRpc( agent, data ) | ||
455 | + local role = agent.role | ||
456 | + local msg = MsgPack.unpack(data) | ||
457 | + | ||
458 | + local buildType = 6 | ||
459 | + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) | ||
460 | + local buildingData = csvdb["diner_buildingCsv"][buildType][level] | ||
461 | + if not buildingData then | ||
462 | + return 1 | ||
463 | + end | ||
464 | + if buildingData.speed <= 0 then | ||
465 | + return 2 | ||
466 | + end | ||
467 | + | ||
468 | + local reward = "" | ||
469 | + local now = skynet.timex() | ||
470 | + local timePass = now - role.dinerData:getProperty("gTime") | ||
471 | + role.dinerData:setProperty("gTime",now) | ||
472 | + role.dinerData:notifyUpdateProperty("gTime",now) | ||
473 | + local count = math.floor(timePass/buildingData.speed) | ||
474 | + count = math.min(count,buildingData.storage) | ||
475 | + for _=1,count do | ||
476 | + reward = reward:incrv(string.randWeight(buildingData.gift_normal), 1) | ||
477 | + end | ||
478 | + for k, v in pairs(reward:toNumMap()) do | ||
479 | + role:addItem({itemId = k,count = v}) | ||
480 | + end | ||
481 | + SendPacket(actionCodes.Diner_getGreenhouseRpc, MsgPack.pack({reward = reward})) | ||
482 | + return true | ||
483 | +end | ||
454 | 484 | ||
455 | return _M | 485 | return _M |
456 | \ No newline at end of file | 486 | \ No newline at end of file |
src/models/Diner.lua
@@ -5,14 +5,15 @@ function Diner:ctor(properties) | @@ -5,14 +5,15 @@ function Diner:ctor(properties) | ||
5 | end | 5 | end |
6 | 6 | ||
7 | Diner.schema = { | 7 | Diner.schema = { |
8 | - buildL = {"string", ""}, -- 家具等级 1=1 2=1 3=1 | ||
9 | - order = {"string", "[]"}, -- 特殊订单 | ||
10 | - sells = {"string", "[]"}, -- 贩卖位置 | ||
11 | - hot = {"string", ""}, -- 今日热门 | 8 | + buildL = {"string", ""}, -- 家具等级 1=1 2=1 3=1 |
9 | + order = {"string", "[]"}, -- 特殊订单 | ||
10 | + sells = {"string", "[]"}, -- 贩卖位置 | ||
11 | + hot = {"string", ""}, -- 今日热门 | ||
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}, -- 累计人气 | ||
15 | - expedite = {"number",1} | 14 | + popular = {"number",0}, -- 累计人气 |
15 | + expedite = {"number",1}, --每日加速次数 | ||
16 | + gTime = {"number",skynet.timex()}, --温室最后一次领取时间 | ||
16 | } | 17 | } |
17 | 18 | ||
18 | function Diner:refreshDailyData(notify) | 19 | function Diner:refreshDailyData(notify) |
@@ -263,7 +264,7 @@ function Diner:getMaxDishs() | @@ -263,7 +264,7 @@ function Diner:getMaxDishs() | ||
263 | end | 264 | end |
264 | 265 | ||
265 | function Diner:data() | 266 | function Diner:data() |
266 | - local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular","expedite"} | 267 | + local properties = {"buildL", "order", "sells", "hot", "dishTree", "skillTree","popular","expedite","gTime"} |
267 | local data = self:getProperties(properties) | 268 | local data = self:getProperties(properties) |
268 | return data | 269 | return data |
269 | end | 270 | end |