Commit e03f9e59f5a2cda0c66d3ba10deef70e83a40e9c

Authored by zhangqijia
1 parent 6afa6078

fix: 修复挂机得到双倍宝藏奖励的bug

1.修复挂机得到双倍宝藏奖励的bug;
2.检查资源值足够才能获得宝藏。
Showing 2 changed files with 28 additions and 10 deletions   Show diff stats
src/actions/HangAction.lua
... ... @@ -132,7 +132,7 @@ local function checkReward(role, isTreasure, carbonId)
132 132 for id, val in pairs(treasureList) do
133 133 local award = val.award:toNumMap()
134 134 for k,v in pairs(award) do
135   - items[k] = (award[k] or 0) + v
  135 + items[k] = (items[k] or 0) + v
136 136 end
137 137 end
138 138 end
... ... @@ -519,7 +519,7 @@ function _M.quickRpc(agent , data)
519 519 for id, val in pairs(treasureList) do
520 520 local award = val.award:toNumMap()
521 521 for k,v in pairs(award) do
522   - reward[k] = (award[k] or 0) + v
  522 + reward[k] = (reward[k] or 0) + v
523 523 end
524 524 end
525 525 end
... ...
src/models/Daily.lua
... ... @@ -242,6 +242,7 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
242 242 print("curInfo is nil")
243 243 return treasure
244 244 end
  245 + local treasureBase = self:getProperty("treasureBase")
245 246  
246 247 --开始挖宝关卡ID=挂机关卡ID
247 248 if chapterId == curInfo.chapter_id then
... ... @@ -253,8 +254,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
253 254 if curInfo.cool_time > 1 then
254 255 --宝藏冷却时间
255 256 if not curInfo["expire_time"] then
256   - treasure = treasureList[curInfo.id]
257   - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay
  257 + if treasureBase >= curInfo["treasure_value"] then
  258 + treasureBase = treasureBase - curInfo["treasure_value"]
  259 +
  260 + treasure = treasureList[curInfo.id]
  261 + curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay
  262 + end
258 263 else
259 264 --已经领取宝藏 检索宝藏冷却时间
260 265 if skynet.timex() >= curInfo["expire_time"] then
... ... @@ -262,8 +267,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
262 267 end
263 268 end
264 269 else
265   - treasure = treasureList[curInfo.id]
266   - treasureList[curInfo.id] = nil
  270 + if treasureBase >= curInfo["treasure_value"] then
  271 + treasureBase = treasureBase - curInfo["treasure_value"]
  272 +
  273 + treasure = treasureList[curInfo.id]
  274 + treasureList[curInfo.id] = nil
  275 + end
267 276 end
268 277 end
269 278 end
... ... @@ -274,8 +283,13 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
274 283 if curInfo.cool_time > 1 then
275 284 --宝藏冷却时间
276 285 if not curInfo["expire_time"] then
277   - treasure = treasureList[curInfo.id]
278   - curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay
  286 + if treasureBase >= curInfo["treasure_value"] then
  287 + treasureBase = treasureBase - curInfo["treasure_value"]
  288 +
  289 + treasure = treasureList[curInfo.id]
  290 + curInfo["expire_time"] = skynet.timex() + curInfo.cool_time * oneDay
  291 + end
  292 +
279 293 else
280 294 --已经领取宝藏 检索宝藏冷却时间
281 295 if skynet.timex() >= curInfo["expire_time"] then
... ... @@ -283,8 +297,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
283 297 end
284 298 end
285 299 else
286   - treasure = treasureList[curInfo.id]
287   - treasureList[curInfo.id] = nil
  300 + if treasureBase >= curInfo["treasure_value"] then
  301 + treasureBase = treasureBase - curInfo["treasure_value"]
  302 +
  303 + treasure = treasureList[curInfo.id]
  304 + treasureList[curInfo.id] = nil
  305 + end
288 306 end
289 307 else
290 308 curInfo["end_time"] = nil
... ...