Commit 4288160b8d8e8a5a16c2d5803d3864655944c833
1 parent
55289e78
add Diner_getGreenhouseRpc
Showing
4 changed files
with
40 additions
and
8 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/DinerAction.lua
... | ... | @@ -451,5 +451,35 @@ function _M.refreshTaskRpc( agent, data ) |
451 | 451 | return true |
452 | 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 | 485 | return _M |
456 | 486 | \ No newline at end of file | ... | ... |
src/models/Diner.lua
... | ... | @@ -5,14 +5,15 @@ function Diner:ctor(properties) |
5 | 5 | end |
6 | 6 | |
7 | 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 | 12 | dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 |
13 | 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 | 19 | function Diner:refreshDailyData(notify) |
... | ... | @@ -263,7 +264,7 @@ function Diner:getMaxDishs() |
263 | 264 | end |
264 | 265 | |
265 | 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 | 268 | local data = self:getProperties(properties) |
268 | 269 | return data |
269 | 270 | end | ... | ... |