Commit 78065fee355a7b599e64f03138e6ea505dbc2699
1 parent
7597d623
fix: 额外宝藏 不可以绑定的关卡(逻辑与每日宝藏不一样)
1. 未过期(未挖,在挖,未领) 2. 正在挂机
Showing
2 changed files
with
65 additions
and
18 deletions
Show diff stats
src/actions/GmAction.lua
| ... | ... | @@ -1224,4 +1224,11 @@ function _M.treasure_map(role, pms) |
| 1224 | 1224 | return treasureMapCount |
| 1225 | 1225 | end |
| 1226 | 1226 | |
| 1227 | +table.insert(helpDes, {"清空", "treasure_clear"}) | |
| 1228 | +function _M.treasure_clear(role, pms) | |
| 1229 | + role.dailyData:updateProperty({field = "treasureExtraCount", value = 0}) | |
| 1230 | + role.dailyData:updateProperty({field = "treasureListExtra", value = {}}) | |
| 1231 | + return "成功" | |
| 1232 | +end | |
| 1233 | + | |
| 1227 | 1234 | return _M |
| 1228 | 1235 | \ No newline at end of file | ... | ... |
src/models/DailyPlugin.lua
| ... | ... | @@ -22,20 +22,21 @@ function DailyPlugin.bind(Daily) |
| 22 | 22 | --CD |
| 23 | 23 | function Daily:checkTreasureExpired(treasureAttr, treasureList) |
| 24 | 24 | local curInfo = treasureList[treasureAttr.id] |
| 25 | + local now = skynet.timex() | |
| 25 | 26 | if curInfo then |
| 26 | 27 | -- check finish |
| 27 | 28 | if curInfo["expire_time"] then |
| 28 | 29 | if curInfo.cool_time > 1 then |
| 29 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 30 | + if now >= curInfo["expire_time"] then | |
| 30 | 31 | treasureList[treasureAttr.id] = nil |
| 31 | 32 | curInfo = clone(treasureAttr) |
| 32 | - elseif skynet.timex() >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却 | |
| 33 | + elseif now >= curInfo["expire_time"] - curInfo.cool_time * oneDay then --未冷却 | |
| 33 | 34 | curInfo = nil |
| 34 | 35 | else |
| 35 | 36 | curInfo = clone(treasureAttr) |
| 36 | 37 | end |
| 37 | 38 | else |
| 38 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 39 | + if now >= curInfo["expire_time"] then | |
| 39 | 40 | treasureList[treasureAttr.id] = nil |
| 40 | 41 | end |
| 41 | 42 | curInfo = clone(treasureAttr) |
| ... | ... | @@ -48,19 +49,24 @@ function DailyPlugin.bind(Daily) |
| 48 | 49 | return curInfo |
| 49 | 50 | end |
| 50 | 51 | |
| 51 | - --绑定通关关卡 | |
| 52 | + --绑定通关关卡 每日宝藏 | |
| 52 | 53 | function Daily:checkChapters(treasureList, treasureListOther) |
| 53 | 54 | local chapters = {} |
| 54 | 55 | local tmp_chapters = {} |
| 55 | 56 | |
| 57 | + --不可以绑定的关卡 | |
| 58 | + --1. 正在挖宝,未挖到 | |
| 59 | + --2. 已经挖到宝藏,但未领取 | |
| 60 | + --3. 正在挂机 | |
| 61 | + local now = skynet.timex() | |
| 56 | 62 | for _, curInfo in pairs(treasureList or {}) do |
| 57 | - if curInfo["expire_time"] or not curInfo["end_time"] then | |
| 63 | + if (not curInfo["expire_time"] and curInfo["end_time"]) then | |
| 58 | 64 | tmp_chapters[curInfo.chapter_id] = curInfo |
| 59 | 65 | end |
| 60 | 66 | end |
| 61 | 67 | |
| 62 | 68 | for _, curInfo in pairs(treasureListOther or {}) do |
| 63 | - if curInfo["expire_time"] or not curInfo["end_time"] then | |
| 69 | + if (not curInfo["expire_time"] and curInfo["end_time"]) then | |
| 64 | 70 | tmp_chapters[curInfo.chapter_id] = curInfo |
| 65 | 71 | end |
| 66 | 72 | end |
| ... | ... | @@ -69,10 +75,43 @@ function DailyPlugin.bind(Daily) |
| 69 | 75 | for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do |
| 70 | 76 | if chapter_id ~= hangInfo.carbonId then |
| 71 | 77 | if self.owner:checkHangPass(chapter_id) then |
| 72 | - if next(tmp_chapters) and not tmp_chapters[chapter_id] then | |
| 73 | - chapters[chapter_id] = val | |
| 74 | - else | |
| 75 | - chapters[chapter_id] = val | |
| 78 | + if not tmp_chapters[chapter_id] then | |
| 79 | + chapters[chapter_id] = {treasure_weight=val.treasure_weight} | |
| 80 | + end | |
| 81 | + end | |
| 82 | + end | |
| 83 | + | |
| 84 | + end | |
| 85 | + return chapters | |
| 86 | + end | |
| 87 | + | |
| 88 | + --额外宝藏 | |
| 89 | + function Daily:checkChaptersExtra(treasureList, treasureListOther) | |
| 90 | + local chapters = {} | |
| 91 | + local tmp_chapters = {} | |
| 92 | + | |
| 93 | + --不可以绑定的关卡 | |
| 94 | + --1. 未过期(未挖,在挖,未领) | |
| 95 | + --2. 正在挂机 | |
| 96 | + local now = skynet.timex() | |
| 97 | + for _, curInfo in pairs(treasureList or {}) do | |
| 98 | + if not curInfo["expire_time"] then | |
| 99 | + tmp_chapters[curInfo.chapter_id] = curInfo | |
| 100 | + end | |
| 101 | + end | |
| 102 | + | |
| 103 | + for _, curInfo in pairs(treasureListOther or {}) do | |
| 104 | + if not curInfo["expire_time"] then | |
| 105 | + tmp_chapters[curInfo.chapter_id] = curInfo | |
| 106 | + end | |
| 107 | + end | |
| 108 | + | |
| 109 | + local hangInfo = self.owner:getProperty("hangInfo") or {} | |
| 110 | + for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do | |
| 111 | + if chapter_id ~= hangInfo.carbonId then | |
| 112 | + if self.owner:checkHangPass(chapter_id) then | |
| 113 | + if not tmp_chapters[chapter_id] then | |
| 114 | + chapters[chapter_id] = {treasure_weight=val.treasure_weight} | |
| 76 | 115 | end |
| 77 | 116 | end |
| 78 | 117 | end |
| ... | ... | @@ -130,7 +169,7 @@ function DailyPlugin.bind(Daily) |
| 130 | 169 | |
| 131 | 170 | --只抓一个 额外宝藏 |
| 132 | 171 | function Daily:getOneTreasureExtra(treasureList, tmpTreasure, treasureBase, treasureListOther) |
| 133 | - local chapters = self:checkChapters(treasureList, treasureListOther) | |
| 172 | + local chapters = self:checkChaptersExtra(treasureList, treasureListOther) | |
| 134 | 173 | if not chapters or not next(chapters) then return end |
| 135 | 174 | |
| 136 | 175 | --扣除在挖宝列表里未过期宝藏的资源值 |
| ... | ... | @@ -177,14 +216,15 @@ function DailyPlugin.bind(Daily) |
| 177 | 216 | function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId, treasureBase) |
| 178 | 217 | if not curInfo then return nil end |
| 179 | 218 | |
| 219 | + local now = skynet.timex() | |
| 180 | 220 | local treasure = nil |
| 181 | 221 | --开始挖宝关卡ID=挂机关卡ID |
| 182 | 222 | if chapterId == curInfo.chapter_id then |
| 183 | 223 | --开始挖宝 |
| 184 | 224 | if not curInfo["end_time"] then |
| 185 | - curInfo["end_time"] = skynet.timex() + curInfo.working_time | |
| 225 | + curInfo["end_time"] = now + curInfo.working_time | |
| 186 | 226 | else |
| 187 | - if skynet.timex() >= curInfo["end_time"] then | |
| 227 | + if now >= curInfo["end_time"] then | |
| 188 | 228 | if curInfo.cool_time > 1 then |
| 189 | 229 | --宝藏冷却时间 |
| 190 | 230 | if not curInfo["expire_time"] then |
| ... | ... | @@ -192,11 +232,11 @@ function DailyPlugin.bind(Daily) |
| 192 | 232 | treasureBase = treasureBase - curInfo["treasure_value"] |
| 193 | 233 | |
| 194 | 234 | treasure = treasureList[curInfo.id] |
| 195 | - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay | |
| 235 | + curInfo["expire_time"] = now + curInfo.cool_time * oneDay | |
| 196 | 236 | end |
| 197 | 237 | else |
| 198 | 238 | --已经领取宝藏 检索宝藏冷却时间 |
| 199 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 239 | + if now >= curInfo["expire_time"] then | |
| 200 | 240 | treasureList[curInfo.id] = nil |
| 201 | 241 | end |
| 202 | 242 | end |
| ... | ... | @@ -213,7 +253,7 @@ function DailyPlugin.bind(Daily) |
| 213 | 253 | else |
| 214 | 254 | --已经开始挖宝 |
| 215 | 255 | if curInfo["end_time"] then |
| 216 | - if skynet.timex() >= curInfo["end_time"] then | |
| 256 | + if now >= curInfo["end_time"] then | |
| 217 | 257 | if curInfo.cool_time > 1 then |
| 218 | 258 | --宝藏冷却时间 |
| 219 | 259 | if not curInfo["expire_time"] then |
| ... | ... | @@ -221,12 +261,12 @@ function DailyPlugin.bind(Daily) |
| 221 | 261 | treasureBase = treasureBase - curInfo["treasure_value"] |
| 222 | 262 | |
| 223 | 263 | treasure = treasureList[curInfo.id] |
| 224 | - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay | |
| 264 | + curInfo["expire_time"] = now + curInfo.cool_time * oneDay | |
| 225 | 265 | end |
| 226 | 266 | |
| 227 | 267 | else |
| 228 | 268 | --已经领取宝藏 检索宝藏冷却时间 |
| 229 | - if skynet.timex() >= curInfo["expire_time"] then | |
| 269 | + if now >= curInfo["expire_time"] then | |
| 230 | 270 | treasureList[curInfo.id] = nil |
| 231 | 271 | end |
| 232 | 272 | end | ... | ... |