Commit 78065fee355a7b599e64f03138e6ea505dbc2699

Authored by zhangqijia
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,4 +1224,11 @@ function _M.treasure_map(role, pms)
1224 return treasureMapCount 1224 return treasureMapCount
1225 end 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 return _M 1234 return _M
1228 \ No newline at end of file 1235 \ No newline at end of file
src/models/DailyPlugin.lua
@@ -22,20 +22,21 @@ function DailyPlugin.bind(Daily) @@ -22,20 +22,21 @@ function DailyPlugin.bind(Daily)
22 --CD 22 --CD
23 function Daily:checkTreasureExpired(treasureAttr, treasureList) 23 function Daily:checkTreasureExpired(treasureAttr, treasureList)
24 local curInfo = treasureList[treasureAttr.id] 24 local curInfo = treasureList[treasureAttr.id]
  25 + local now = skynet.timex()
25 if curInfo then 26 if curInfo then
26 -- check finish 27 -- check finish
27 if curInfo["expire_time"] then 28 if curInfo["expire_time"] then
28 if curInfo.cool_time > 1 then 29 if curInfo.cool_time > 1 then
29 - if skynet.timex() >= curInfo["expire_time"] then 30 + if now >= curInfo["expire_time"] then
30 treasureList[treasureAttr.id] = nil 31 treasureList[treasureAttr.id] = nil
31 curInfo = clone(treasureAttr) 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 curInfo = nil 34 curInfo = nil
34 else 35 else
35 curInfo = clone(treasureAttr) 36 curInfo = clone(treasureAttr)
36 end 37 end
37 else 38 else
38 - if skynet.timex() >= curInfo["expire_time"] then 39 + if now >= curInfo["expire_time"] then
39 treasureList[treasureAttr.id] = nil 40 treasureList[treasureAttr.id] = nil
40 end 41 end
41 curInfo = clone(treasureAttr) 42 curInfo = clone(treasureAttr)
@@ -48,19 +49,24 @@ function DailyPlugin.bind(Daily) @@ -48,19 +49,24 @@ function DailyPlugin.bind(Daily)
48 return curInfo 49 return curInfo
49 end 50 end
50 51
51 - --绑定通关关卡 52 + --绑定通关关卡 每日宝藏
52 function Daily:checkChapters(treasureList, treasureListOther) 53 function Daily:checkChapters(treasureList, treasureListOther)
53 local chapters = {} 54 local chapters = {}
54 local tmp_chapters = {} 55 local tmp_chapters = {}
55 56
  57 + --不可以绑定的关卡
  58 + --1. 正在挖宝,未挖到
  59 + --2. 已经挖到宝藏,但未领取
  60 + --3. 正在挂机
  61 + local now = skynet.timex()
56 for _, curInfo in pairs(treasureList or {}) do 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 tmp_chapters[curInfo.chapter_id] = curInfo 64 tmp_chapters[curInfo.chapter_id] = curInfo
59 end 65 end
60 end 66 end
61 67
62 for _, curInfo in pairs(treasureListOther or {}) do 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 tmp_chapters[curInfo.chapter_id] = curInfo 70 tmp_chapters[curInfo.chapter_id] = curInfo
65 end 71 end
66 end 72 end
@@ -69,10 +75,43 @@ function DailyPlugin.bind(Daily) @@ -69,10 +75,43 @@ function DailyPlugin.bind(Daily)
69 for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do 75 for chapter_id, val in pairs(csvdb["idle_battleCsv"]) do
70 if chapter_id ~= hangInfo.carbonId then 76 if chapter_id ~= hangInfo.carbonId then
71 if self.owner:checkHangPass(chapter_id) then 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 end 115 end
77 end 116 end
78 end 117 end
@@ -130,7 +169,7 @@ function DailyPlugin.bind(Daily) @@ -130,7 +169,7 @@ function DailyPlugin.bind(Daily)
130 169
131 --只抓一个 额外宝藏 170 --只抓一个 额外宝藏
132 function Daily:getOneTreasureExtra(treasureList, tmpTreasure, treasureBase, treasureListOther) 171 function Daily:getOneTreasureExtra(treasureList, tmpTreasure, treasureBase, treasureListOther)
133 - local chapters = self:checkChapters(treasureList, treasureListOther) 172 + local chapters = self:checkChaptersExtra(treasureList, treasureListOther)
134 if not chapters or not next(chapters) then return end 173 if not chapters or not next(chapters) then return end
135 174
136 --扣除在挖宝列表里未过期宝藏的资源值 175 --扣除在挖宝列表里未过期宝藏的资源值
@@ -177,14 +216,15 @@ function DailyPlugin.bind(Daily) @@ -177,14 +216,15 @@ function DailyPlugin.bind(Daily)
177 function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId, treasureBase) 216 function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId, treasureBase)
178 if not curInfo then return nil end 217 if not curInfo then return nil end
179 218
  219 + local now = skynet.timex()
180 local treasure = nil 220 local treasure = nil
181 --开始挖宝关卡ID=挂机关卡ID 221 --开始挖宝关卡ID=挂机关卡ID
182 if chapterId == curInfo.chapter_id then 222 if chapterId == curInfo.chapter_id then
183 --开始挖宝 223 --开始挖宝
184 if not curInfo["end_time"] then 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 else 226 else
187 - if skynet.timex() >= curInfo["end_time"] then 227 + if now >= curInfo["end_time"] then
188 if curInfo.cool_time > 1 then 228 if curInfo.cool_time > 1 then
189 --宝藏冷却时间 229 --宝藏冷却时间
190 if not curInfo["expire_time"] then 230 if not curInfo["expire_time"] then
@@ -192,11 +232,11 @@ function DailyPlugin.bind(Daily) @@ -192,11 +232,11 @@ function DailyPlugin.bind(Daily)
192 treasureBase = treasureBase - curInfo["treasure_value"] 232 treasureBase = treasureBase - curInfo["treasure_value"]
193 233
194 treasure = treasureList[curInfo.id] 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 end 236 end
197 else 237 else
198 --已经领取宝藏 检索宝藏冷却时间 238 --已经领取宝藏 检索宝藏冷却时间
199 - if skynet.timex() >= curInfo["expire_time"] then 239 + if now >= curInfo["expire_time"] then
200 treasureList[curInfo.id] = nil 240 treasureList[curInfo.id] = nil
201 end 241 end
202 end 242 end
@@ -213,7 +253,7 @@ function DailyPlugin.bind(Daily) @@ -213,7 +253,7 @@ function DailyPlugin.bind(Daily)
213 else 253 else
214 --已经开始挖宝 254 --已经开始挖宝
215 if curInfo["end_time"] then 255 if curInfo["end_time"] then
216 - if skynet.timex() >= curInfo["end_time"] then 256 + if now >= curInfo["end_time"] then
217 if curInfo.cool_time > 1 then 257 if curInfo.cool_time > 1 then
218 --宝藏冷却时间 258 --宝藏冷却时间
219 if not curInfo["expire_time"] then 259 if not curInfo["expire_time"] then
@@ -221,12 +261,12 @@ function DailyPlugin.bind(Daily) @@ -221,12 +261,12 @@ function DailyPlugin.bind(Daily)
221 treasureBase = treasureBase - curInfo["treasure_value"] 261 treasureBase = treasureBase - curInfo["treasure_value"]
222 262
223 treasure = treasureList[curInfo.id] 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 end 265 end
226 266
227 else 267 else
228 --已经领取宝藏 检索宝藏冷却时间 268 --已经领取宝藏 检索宝藏冷却时间
229 - if skynet.timex() >= curInfo["expire_time"] then 269 + if now >= curInfo["expire_time"] then
230 treasureList[curInfo.id] = nil 270 treasureList[curInfo.id] = nil
231 end 271 end
232 end 272 end