Commit d1c2290ff2aa105f8008ef2db77f69a1e722bb6a
1 parent
a35233c6
加速
Showing
3 changed files
with
55 additions
and
0 deletions
Show diff stats
src/GlobalVar.lua
@@ -45,6 +45,7 @@ ItemType = { | @@ -45,6 +45,7 @@ ItemType = { | ||
45 | TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具) | 45 | TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具) |
46 | AdvItem = 14, -- 冒险道具 | 46 | AdvItem = 14, -- 冒险道具 |
47 | FuncOpen = 15, -- 管理功能开放 | 47 | FuncOpen = 15, -- 管理功能开放 |
48 | + SpeedBox = 16, -- 加速箱子 | ||
48 | } | 49 | } |
49 | 50 | ||
50 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID | 51 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID |
src/ProtocolCode.lua
@@ -40,6 +40,7 @@ actionCodes = { | @@ -40,6 +40,7 @@ actionCodes = { | ||
40 | Role_changeSettingRpc = 125, | 40 | Role_changeSettingRpc = 125, |
41 | Role_drawCodeRpc = 126, | 41 | Role_drawCodeRpc = 126, |
42 | Role_changeHeadRpc = 127, | 42 | Role_changeHeadRpc = 127, |
43 | + Role_openSpeedUpBoxRpc = 128, | ||
43 | 44 | ||
44 | Adv_startAdvRpc = 151, | 45 | Adv_startAdvRpc = 151, |
45 | Adv_startHangRpc = 152, | 46 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
@@ -513,6 +513,59 @@ function _M.openTimeBoxRpc(agent, data) | @@ -513,6 +513,59 @@ function _M.openTimeBoxRpc(agent, data) | ||
513 | return true | 513 | return true |
514 | end | 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 | function _M.storyBookRewardRpc(agent, data) | 569 | function _M.storyBookRewardRpc(agent, data) |
517 | local role = agent.role | 570 | local role = agent.role |
518 | local msg = MsgPack.unpack(data) | 571 | local msg = MsgPack.unpack(data) |