From d1c2290ff2aa105f8008ef2db77f69a1e722bb6a Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Wed, 25 Dec 2019 21:24:09 +0800 Subject: [PATCH] 加速 --- src/GlobalVar.lua | 1 + src/ProtocolCode.lua | 1 + src/actions/RoleAction.lua | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 0 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 2ed6ed9..55374e7 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -45,6 +45,7 @@ ItemType = { TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具) AdvItem = 14, -- 冒险道具 FuncOpen = 15, -- 管理功能开放 + SpeedBox = 16, -- 加速箱子 } --在这个里面的会记录的是功能开放 对应类型open 而不是 ID diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 64d5fe7..b7aba9c 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -40,6 +40,7 @@ actionCodes = { Role_changeSettingRpc = 125, Role_drawCodeRpc = 126, Role_changeHeadRpc = 127, + Role_openSpeedUpBoxRpc = 128, Adv_startAdvRpc = 151, Adv_startHangRpc = 152, diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 42169e9..007e7f4 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -513,6 +513,59 @@ function _M.openTimeBoxRpc(agent, data) return true end +function _M.openSpeedUpBoxRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + + local id = msg.id + local count = msg.count + local itemData = csvdb["itemCsv"][id] + if not itemData or itemData.type ~= ItemType.SpeedBox then return end + + if math.illegalNum(count, 1, role:getItemCount(id)) then return end + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) + local time = hour * 60 * 60 + + local reward = {} + if useType == 1 then -- 挂机齿轮 + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.carbonId then + return + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count + elseif useType == 2 then -- 挂机经验 + local hangInfo = role:getProperty("hangInfo") + if not hangInfo.carbonId then + return + end + local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] + reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count + elseif useType == 3 then -- 食材商人收入 + 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 + local gfood = role.dinerData:getProperty("gfood") + if not next(gfood) then return end + for k , v in pairs(gfood) do + local itemId = v.id + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 + reward[itemId] = math.floor(time / speed) * count + end + else + return + end + + role:costItems({[id] = count}) + reward = role:award(reward) + + SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack({reward = reward})) + return true +end + function _M.storyBookRewardRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) -- libgit2 0.21.2