From 9489e76155dc1b576af2758b361125db9015d3b3 Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Fri, 10 Sep 2021 14:05:52 +0800 Subject: [PATCH] feat: 探索加速、拾荒体力、奖励副本购买次数去除上限 --- src/GlobalVar.lua | 2 +- src/actions/AdvAction.lua | 7 ++++--- src/actions/HangAction.lua | 42 ++++++++++++++++++++---------------------- src/models/RolePlugin.lua | 5 +++++ src/shared/functions.lua | 25 +++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 723849f..b999f14 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -433,7 +433,7 @@ SystemBnousType = { UpSpeedNum = 15, -- 加速次数上限增加 15=1探索加速or 2齿轮加速or 3餐厅加速=增加次数 ChangeBaseCount = 16, -- 每日奖励关卡挑战卡基础数量增加 ChangeBuyCount = 17, -- 每日奖励关卡挑战卡可购买次数增加, - ExtraProp = 18, -- 每次探索加速额外获得道具 + ExtraProps= 18, -- 每次探索加速额外获得道具 AccountLevel = 19, -- 账号等级提升角色等级上限 } diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 72ad50b..591b876 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -506,14 +506,15 @@ function _M.buyAdvCountRpc(agent , data) local msg = MsgPack.unpack(data) local count = msg.count --购买次数 - local isEl = msg.isEl -- 是否是无尽模式 + local isEl = msg.isEl -- 是否是无尽模式 国服没有 local cost if isEl then if math.illegalNum(count, 1, globalCsv.adv_endless_daily_buy_count - role.dailyData:getProperty("advElBC")) then return end cost = {[ItemId.Jade] = count * globalCsv.adv_endless_daily_buy_cost} else - if math.illegalNum(count, 1, globalCsv.adv_daily_buy_count - role.dailyData:getProperty("advBC")) then return end - cost = {[ItemId.Jade] = count * globalCsv.adv_daily_buy_cost} + --if math.illegalNum(count, 1, globalCsv.adv_daily_buy_count - role.dailyData:getProperty("advBC")) then return end + local advCount = (role.dailyData:getProperty("advBC") + count ) * globalCsv.adv_daily_buy_num + cost = {[ItemId.Jade] = table.findMinKeyByItem(globalCsv.adv_buy_cost, advCount)} end diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index b3ed243..fe9e795 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -477,24 +477,11 @@ function _M.quickRpc(agent , data) local expCarbonData = hangInfo.expData or {} local curCount = role.dailyData:getProperty("hangQC") + 1 - local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") + local curT = curCount * (globalCsv.idle_quickproduce_time / 3600) + local costCount = table.findMinKeyByItem(globalCsv.idle_quickproduce_cost, curT) - -- 增加今日探索加速次数 - local maxIdx = #costs - local maxCount = maxIdx + role:getBnousUpSpeedNum(UpSpeedType.ExplorationUpSpeed) - if curCount > maxCount then return end - - if curCount > maxIdx then - for idx = maxIdx+1, curCount do - costs[idx] = costs[maxIdx] - end - end - - if not costs[curCount] then return end - if costs[curCount] > 0 then - if not role:checkItemEnough({[ItemId.Jade] = costs[curCount]}) then return end - role:costItems({[ItemId.Jade] = costs[curCount]}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) - end + if not role:checkItemEnough({[ItemId.Jade] = costCount}) then return end + role:costItems({[ItemId.Jade] = costCount}, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) role.dailyData:updateProperty({field = "hangQC", value = curCount}) @@ -540,6 +527,14 @@ function _M.quickRpc(agent , data) reward[k] = (reward[k] or 0) + v end + --每次探索加速额外获得道具 + local extraProps = role:getBnousExtraProps() + if next(extraProps) then + for k, v in pairs(extraProps) do + reward[k] = (reward[k] or 0) + v + end + end + local change reward, change = role:award(reward, {log = {desc = "quickHang", int1 = hangInfo.carbonId}}) if reward[ItemId.Gold] then @@ -584,13 +579,16 @@ function _M.buyBonusCountRpc(agent, data) local bonusC = role.dailyData:getProperty("bonusC") local extraCnt = role.storeData:getBonusExtraFightCount() bonusC[btype] = bonusC[btype] or {c = 0, b = 0} - local lastCount = (globalCsv.bonus_daily_buy_count + role:getBnousChangeBuyCount()) * coef + extraCnt - bonusC[btype]["b"] - if math.illegalNum(count, 1, lastCount) then return 1 end + --local lastCount = (globalCsv.bonus_daily_buy_count + role:getBnousChangeBuyCount()) * coef + extraCnt - bonusC[btype]["b"] + --if math.illegalNum(count, 1, lastCount) then return 1 end + + local costCount = bonusC[btype]["b"] + count + local cost = table.findMinKeyByItem(globalCsv.bonus_buy_cost, costCount) - if not role:checkItemEnough({[ItemId.Jade] = globalCsv.bonus_buy_cost * count}) then return 2 end + if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 2 end - role:costItems({[ItemId.Jade] = globalCsv.bonus_buy_cost * count}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) - bonusC[btype]["b"] = bonusC[btype]["b"] + count + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "buyBonusCount", int1 = btype, int2 = count}}) + bonusC[btype]["b"] = costCount bonusC[btype]["c"] = bonusC[btype]["c"] - count role.dailyData:updateProperty({field = "bonusC", value = bonusC}) diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 935ae35..6b181e9 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -3036,6 +3036,11 @@ function RolePlugin.bind(Role) return levelBnous[SystemBnousType.AccountLevel] or 0 end + function Role:getBnousExtraProps() + local levelBnous = self:getLevelBnous() + return levelBnous[SystemBnousType.ExtraProps] or {} + end + function Role:getLevelBnous() local levelBnous = {} local curLevel = self:getProperty("level") diff --git a/src/shared/functions.lua b/src/shared/functions.lua index 800a7e6..9799ddd 100644 --- a/src/shared/functions.lua +++ b/src/shared/functions.lua @@ -865,6 +865,31 @@ function table.array2Table(arr) return ret end +function table.findMinKeyByItem(t, item) + if not t[item] then + local tk = {} + for k, v in pairs(t) do + table.insert(tk, k) + end + if next(tk) then + local max = table.maxkey(tk) + if item > max then return t[max] end + + table.insert(tk, item) + table.sort(tk) + local index = 0 + for i, k in ipairs(tk) do + if k == item then + index = i - 1 + break + end + end + return t[tk[index]] + end + else + return t[item] + end +end function table.rewardMerge(dest, src) for k, v in pairs(src) do -- libgit2 0.21.2