From 53b4b8bde8149727336d6dcf5cebfd2c5f64e085 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Mon, 7 Sep 2020 20:06:04 +0800 Subject: [PATCH] 自动挂机下一关 --- src/actions/GmAction.lua | 2 +- src/actions/HangAction.lua | 6 ++++-- src/actions/RoleAction.lua | 2 +- src/csvdata | 2 +- src/models/RolePlugin.lua | 22 ++++++++++++++++++++++ src/models/Store.lua | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index d4af882..7b706e8 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -472,7 +472,7 @@ function _M.test(role, pms) local id = tonum(pms.pm1, 0) --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) - role.storeData:onBuyPaySignCard(100) + print(role:getNextCarbonId(id)) return "成功" end diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index af9591a..1811452 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -270,8 +270,10 @@ function _M.endBattleRpc(agent, data) end end end - if hangInfo.carbonId < carbonId then - hangInfo.carbonId = carbonId + local nextCarbonId = role:getNextCarbonId(carbonId) + -- 设置挂机关卡 + if hangInfo.carbonId < nextCarbonId then + hangInfo.carbonId = nextCarbonId end role:updateProperty({field = "hangInfo", value = hangInfo}) diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 2c8bdcb..29877ba 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -173,7 +173,7 @@ function _M.loginRpc( agent, data ) response.role = role:data() response.result = "SUCCESS" response.serverTime = now - response.openTime = getServerOpenTs() + --response.openTime = getServerOpenTs() local modules = {} diff --git a/src/csvdata b/src/csvdata index 3f22e14..83f6f08 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 3f22e14af514a3c558f7f04c0e3a99102a4268fc +Subproject commit 83f6f0899e2213de748df05480e7292f87a86eb6 diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index ad529b2..f166389 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1547,6 +1547,28 @@ function RolePlugin.bind(Role) return reward, (newVal >= maxCount and newVal - maxCount or newVal) end + -- 获取下一个挂机关卡id + function Role:getNextCarbonId(curId) + local diff = math.floor(curId / 10000) + local chapterId = math.floor((curId / 100) % 100) + local subId = curId % 100 + local nextId = curId + 1 + local function makeCarbonId(diff, chapterId, subId) + return diff * 10000 + chapterId * 100 + subId + end + if not csvdb["idle_battleCsv"][nextId] then + nextId = makeCarbonId(diff, chapterId + 1, 1) + if not csvdb["idle_battleCsv"][nextId] then + nextId = makeCarbonId(diff + 1, 1, 1) + if not csvdb["idle_battleCsv"][nextId] then + nextId = 0 + end + end + end + + return nextId + end + end return RolePlugin \ No newline at end of file diff --git a/src/models/Store.lua b/src/models/Store.lua index 02ed6e9..e912457 100644 --- a/src/models/Store.lua +++ b/src/models/Store.lua @@ -366,7 +366,7 @@ function Store:onBuyPaySignCard(dur) return end actGoodsFlag[goodsIndex] = 1 - self.owner:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) + self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) -- 发钱 local change local reward, curData = self.owner.activity:getPaySignReward() -- libgit2 0.21.2