Commit d1c2290ff2aa105f8008ef2db77f69a1e722bb6a
1 parent
a35233c6
加速
Showing
3 changed files
with
55 additions
and
0 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
src/actions/RoleAction.lua
| ... | ... | @@ -513,6 +513,59 @@ function _M.openTimeBoxRpc(agent, data) |
| 513 | 513 | return true |
| 514 | 514 | end |
| 515 | 515 | |
| 516 | +function _M.openSpeedUpBoxRpc(agent, data) | |
| 517 | + local role = agent.role | |
| 518 | + local msg = MsgPack.unpack(data) | |
| 519 | + | |
| 520 | + local id = msg.id | |
| 521 | + local count = msg.count | |
| 522 | + local itemData = csvdb["itemCsv"][id] | |
| 523 | + if not itemData or itemData.type ~= ItemType.SpeedBox then return end | |
| 524 | + | |
| 525 | + if math.illegalNum(count, 1, role:getItemCount(id)) then return end | |
| 526 | + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) | |
| 527 | + local time = hour * 60 * 60 | |
| 528 | + | |
| 529 | + local reward = {} | |
| 530 | + if useType == 1 then -- 挂机齿轮 | |
| 531 | + local hangInfo = role:getProperty("hangInfo") | |
| 532 | + if not hangInfo.carbonId then | |
| 533 | + return | |
| 534 | + end | |
| 535 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | |
| 536 | + reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count | |
| 537 | + elseif useType == 2 then -- 挂机经验 | |
| 538 | + local hangInfo = role:getProperty("hangInfo") | |
| 539 | + if not hangInfo.carbonId then | |
| 540 | + return | |
| 541 | + end | |
| 542 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | |
| 543 | + reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count | |
| 544 | + elseif useType == 3 then -- 食材商人收入 | |
| 545 | + local buildType = 6 | |
| 546 | + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) | |
| 547 | + local buildingData = csvdb["diner_buildingCsv"][buildType][level] | |
| 548 | + if not buildingData then | |
| 549 | + return 1 | |
| 550 | + end | |
| 551 | + local gfood = role.dinerData:getProperty("gfood") | |
| 552 | + if not next(gfood) then return end | |
| 553 | + for k , v in pairs(gfood) do | |
| 554 | + local itemId = v.id | |
| 555 | + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | |
| 556 | + reward[itemId] = math.floor(time / speed) * count | |
| 557 | + end | |
| 558 | + else | |
| 559 | + return | |
| 560 | + end | |
| 561 | + | |
| 562 | + role:costItems({[id] = count}) | |
| 563 | + reward = role:award(reward) | |
| 564 | + | |
| 565 | + SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack({reward = reward})) | |
| 566 | + return true | |
| 567 | +end | |
| 568 | + | |
| 516 | 569 | function _M.storyBookRewardRpc(agent, data) |
| 517 | 570 | local role = agent.role |
| 518 | 571 | local msg = MsgPack.unpack(data) | ... | ... |