From 78065fee355a7b599e64f03138e6ea505dbc2699 Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Mon, 24 Jan 2022 15:28:48 +0800 Subject: [PATCH] fix: 额外宝藏 不可以绑定的关卡(逻辑与每日宝藏不一样) 1. 未过期(未挖,在挖,未领) 2. 正在挂机 --- src/actions/GmAction.lua | 7 +++++++ src/models/DailyPlugin.lua | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index d7efece..166f2c3 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -1224,4 +1224,11 @@ function _M.treasure_map(role, pms) return treasureMapCount end +table.insert(helpDes, {"清空", "treasure_clear"}) +function _M.treasure_clear(role, pms) + role.dailyData:updateProperty({field = "treasureExtraCount", value = 0}) + role.dailyData:updateProperty({field = "treasureListExtra", value = {}}) + return "成功" +end + return _M \ No newline at end of file diff --git a/src/models/DailyPlugin.lua b/src/models/DailyPlugin.lua index 9490024..1079a43 100644 --- a/src/models/DailyPlugin.lua +++ b/src/models/DailyPlugin.lua @@ -22,20 +22,21 @@ function DailyPlugin.bind(Daily) --CD function Daily:checkTreasureExpired(treasureAttr, treasureList) local curInfo = treasureList[treasureAttr.id] + local now = skynet.timex() if curInfo then -- check finish if curInfo["expire_time"] then if curInfo.cool_time > 1 then - if skynet.timex() >= curInfo["expire_time"] then + if now >= curInfo["expire_time"] then treasureList[treasureAttr.id] = nil curInfo = clone(treasureAttr) - elseif skynet.timex() >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却 + elseif now >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却 curInfo = nil else curInfo = clone(treasureAttr) end else - if skynet.timex() >= curInfo["expire_time"] then + if now >= curInfo["expire_time"] then treasureList[treasureAttr.id] = nil end curInfo = clone(treasureAttr) @@ -48,19 +49,24 @@ function DailyPlugin.bind(Daily) return curInfo end - --绑定通关关卡 + --绑定通关关卡 每日宝藏 function Daily:checkChapters(treasureList, treasureListOther) local chapters = {} local tmp_chapters = {} + --不可以绑定的关卡 + --1. 正在挖宝,未挖到 + --2. 已经挖到宝藏,但未领取 + --3. 正在挂机 + local now = skynet.timex() for _, curInfo in pairs(treasureList or {}) do - if curInfo["expire_time"] or not curInfo["end_time"] then + if (not curInfo["expire_time"] and curInfo["end_time"]) then tmp_chapters[curInfo.chapter_id] = curInfo end end for _, curInfo in pairs(treasureListOther or {}) do - if curInfo["expire_time"] or not curInfo["end_time"] then + if (not curInfo["expire_time"] and curInfo["end_time"]) then tmp_chapters[curInfo.chapter_id] = curInfo end end @@ -69,10 +75,43 @@ function DailyPlugin.bind(Daily) for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do if chapter_id ~= hangInfo.carbonId then if self.owner:checkHangPass(chapter_id) then - if next(tmp_chapters) and not tmp_chapters[chapter_id] then - chapters[chapter_id] = val - else - chapters[chapter_id] = val + if not tmp_chapters[chapter_id] then + chapters[chapter_id] = {treasure_weight=val.treasure_weight} + end + end + end + + end + return chapters + end + + --额外宝藏 + function Daily:checkChaptersExtra(treasureList, treasureListOther) + local chapters = {} + local tmp_chapters = {} + + --不可以绑定的关卡 + --1. 未过期(未挖,在挖,未领) + --2. 正在挂机 + local now = skynet.timex() + for _, curInfo in pairs(treasureList or {}) do + if not curInfo["expire_time"] then + tmp_chapters[curInfo.chapter_id] = curInfo + end + end + + for _, curInfo in pairs(treasureListOther or {}) do + if not curInfo["expire_time"] then + tmp_chapters[curInfo.chapter_id] = curInfo + end + end + + local hangInfo = self.owner:getProperty("hangInfo") or {} + for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do + if chapter_id ~= hangInfo.carbonId then + if self.owner:checkHangPass(chapter_id) then + if not tmp_chapters[chapter_id] then + chapters[chapter_id] = {treasure_weight=val.treasure_weight} end end end @@ -130,7 +169,7 @@ function DailyPlugin.bind(Daily) --只抓一个 额外宝藏 function Daily:getOneTreasureExtra(treasureList, tmpTreasure, treasureBase, treasureListOther) - local chapters = self:checkChapters(treasureList, treasureListOther) + local chapters = self:checkChaptersExtra(treasureList, treasureListOther) if not chapters or not next(chapters) then return end --扣除在挖宝列表里未过期宝藏的资源值 @@ -177,14 +216,15 @@ function DailyPlugin.bind(Daily) function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId, treasureBase) if not curInfo then return nil end + local now = skynet.timex() local treasure = nil --开始挖宝关卡ID=挂机关卡ID if chapterId == curInfo.chapter_id then --开始挖宝 if not curInfo["end_time"] then - curInfo["end_time"] = skynet.timex() + curInfo.working_time + curInfo["end_time"] = now + curInfo.working_time else - if skynet.timex() >= curInfo["end_time"] then + if now >= curInfo["end_time"] then if curInfo.cool_time > 1 then --宝藏冷却时间 if not curInfo["expire_time"] then @@ -192,11 +232,11 @@ function DailyPlugin.bind(Daily) treasureBase = treasureBase - curInfo["treasure_value"] treasure = treasureList[curInfo.id] - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay + curInfo["expire_time"] = now + curInfo.cool_time * oneDay end else --已经领取宝藏 检索宝藏冷却时间 - if skynet.timex() >= curInfo["expire_time"] then + if now >= curInfo["expire_time"] then treasureList[curInfo.id] = nil end end @@ -213,7 +253,7 @@ function DailyPlugin.bind(Daily) else --已经开始挖宝 if curInfo["end_time"] then - if skynet.timex() >= curInfo["end_time"] then + if now >= curInfo["end_time"] then if curInfo.cool_time > 1 then --宝藏冷却时间 if not curInfo["expire_time"] then @@ -221,12 +261,12 @@ function DailyPlugin.bind(Daily) treasureBase = treasureBase - curInfo["treasure_value"] treasure = treasureList[curInfo.id] - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay + curInfo["expire_time"] = now + curInfo.cool_time * oneDay end else --已经领取宝藏 检索宝藏冷却时间 - if skynet.timex() >= curInfo["expire_time"] then + if now >= curInfo["expire_time"] then treasureList[curInfo.id] = nil end end -- libgit2 0.21.2