From 2a5428655f723ce363ee74534eadf20878d1a3df Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Thu, 1 Apr 2021 11:40:01 +0800 Subject: [PATCH] 齿轮、经验 奖励投放逻辑调整 --- src/actions/HangAction.lua | 46 +++++++++++++++++++++++++++++----------------- src/actions/RoleAction.lua | 16 ++++++---------- src/actions/SeaportAction.lua | 8 ++++---- src/csvdata | 2 +- src/models/RolePlugin.lua | 8 ++++---- 5 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index a8d0917..4473841 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -22,7 +22,8 @@ local function checkReward(role) return false end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] - local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + --local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + local expCarbonData = hangInfo.expData or {} local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) @@ -42,9 +43,9 @@ local function checkReward(role) local items = role:getProperty("hangBag") coinCount = (coinCount + coinDoubleCount) * expCoef - items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) - items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * (expCarbonData.money or 0)) + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * (expCarbonData.exp or 0)) + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + (coinCount * expCarbonData.playerExp or 0)) local pool = {} for _, temp in pairs(carbonData.item:toArray()) do @@ -144,7 +145,7 @@ function _M.startRpc( agent, data ) local hangInfo = role:getProperty("hangInfo") local isNew = not hangInfo.carbonId hangInfo.carbonId = carbonId - hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId + --hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId local nowTime = skynet.timex() if isNew then hangInfo.coinTime = nowTime @@ -279,15 +280,25 @@ function _M.endBattleRpc(agent, data) local nextCarbonId = role:getNextCarbonId(carbonId) -- 设置挂机关卡 if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then - if not hangInfo.expCarbonId then - hangInfo.expCarbonId = carbonId - else - local oldCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] - local newCarbonData = csvdb["idle_battleCsv"][carbonId] - if oldCarbonData.money < newCarbonData.money then - hangInfo.expCarbonId = carbonId - end + local newCarbonData = csvdb["idle_battleCsv"][carbonId] + if newCarbonData then + local expData = hangInfo.expData or {} + expData.exp = (expData.exp or 0) + newCarbonData.exp + expData.money = (expData.money or 0) + newCarbonData.money + expData.playerExp = (expData.playerExp or 0) + newCarbonData.playerExp + hangInfo.expData = expData end + + --if not hangInfo.expCarbonId then + -- hangInfo.expCarbonId = carbonId + --else + -- local oldCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + -- local newCarbonData = csvdb["idle_battleCsv"][carbonId] + -- if oldCarbonData.money < newCarbonData.money then + -- hangInfo.expCarbonId = carbonId + -- end + --end + --local cfg = csvdb["idle_battleCsv"][nextCarbonId] --if cfg then -- hangInfo.bossTime = skynet.timex() + cfg.idle_time @@ -418,7 +429,8 @@ function _M.quickRpc(agent , data) local hangInfo = role:getProperty("hangInfo") if not hangInfo.carbonId then return end local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] - local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + --local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + local expCarbonData = hangInfo.expData or {} local curCount = role.dailyData:getProperty("hangQC") + 1 local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") @@ -435,9 +447,9 @@ function _M.quickRpc(agent , data) local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) - reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money) - reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) - reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * (expCarbonData.money or 0)) + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * (expCarbonData.exp or 0)) + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * (expCarbonData.playerExp or 0)) local pool = {} for _, temp in pairs(carbonData.item:toArray()) do diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 219cce2..875bf4e 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -756,18 +756,14 @@ function _M.openSpeedUpBoxRpc(agent, data) if useType == 1 then -- 挂机齿轮 local hangInfo = role:getProperty("hangInfo") - if not hangInfo.expCarbonId then - return 2 - end - local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] - reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count + local expData = hangInfo.expData or {} + --local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * (expData.money or 0) * count elseif useType == 2 then -- 挂机经验 local hangInfo = role:getProperty("hangInfo") - if not hangInfo.expCarbonId then - return 3 - end - local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] - reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count + local expData = hangInfo.expData or {} + --local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * (expData.exp or 0) * count elseif useType == 3 then -- 食材商人收入 local buildType = 6 local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) diff --git a/src/actions/SeaportAction.lua b/src/actions/SeaportAction.lua index 1d88295..1d5ab1e 100644 --- a/src/actions/SeaportAction.lua +++ b/src/actions/SeaportAction.lua @@ -203,8 +203,8 @@ function _M.taskRpc(agent, data) end local carbonCsv = csvdb["idle_battleCsv"] - local expCarbonId = role:getProperty("hangInfo").expCarbonId - if not carbonCsv[expCarbonId] then return 7 end + local expData = role:getProperty("hangInfo").expData or {} + --if not carbonCsv[expCarbonId] then return 7 end local totalCoef = 0 for _, heroId in ipairs(collect.team:toArray(true,"=")) do @@ -222,8 +222,8 @@ function _M.taskRpc(agent, data) bigSuccess = true end - local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear) - local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear) + local money = math.ceil((expData.money or 0) / 5 * data.time * data.money_clear) + local exp = math.ceil((expData.exp or 0) / 5 * data.time * data.exp_clear) local itemReward = data.item_clear_special:toNumMap() itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp diff --git a/src/csvdata b/src/csvdata index 9a02ff3..00e1022 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 9a02ff3040615ea6f1eae4ed857b20ab35ea39f1 +Subproject commit 00e1022c3cd5edb6487933d1c839a7d186c0ecc4 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 967509b..13e2838 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1409,7 +1409,7 @@ function RolePlugin.bind(Role) end local carbonCsv = csvdb["idle_battleCsv"] - local expCarbonId = self:getProperty("hangInfo").expCarbonId + local expData = self:getProperty("hangInfo").expData or {} local taskCsv = csvdb["seaport_taskCsv"] local endTime = openTime0 + 86400 * 2 local reward = {} @@ -1422,7 +1422,7 @@ function RolePlugin.bind(Role) local teams = collect[slot].team local time = collect[slot].time if time + data.time <= endTime then - if not carbonCsv[expCarbonId] then break end + --if not carbonCsv[expCarbonId] then break end local totalCoef = 0 for _, heroId in ipairs(teams:toArray(true,"=")) do @@ -1439,8 +1439,8 @@ function RolePlugin.bind(Role) bigSuccess = true end - local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear) - local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear) + local money = math.ceil((expData.money or 0) / 5 * data.time * data.money_clear) + local exp = math.ceil((expData.exp or 0) / 5 * data.time * data.exp_clear) local itemReward = data.item_clear_special:toNumMap() itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp -- libgit2 0.21.2