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,7 +132,7 @@ local function checkReward(role, isTreasure, carbonId)
132 for id, val in pairs(treasureList) do 132 for id, val in pairs(treasureList) do
133 local award = val.award:toNumMap() 133 local award = val.award:toNumMap()
134 for k,v in pairs(award) do 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 end 136 end
137 end 137 end
138 end 138 end
@@ -519,7 +519,7 @@ function _M.quickRpc(agent , data) @@ -519,7 +519,7 @@ function _M.quickRpc(agent , data)
519 for id, val in pairs(treasureList) do 519 for id, val in pairs(treasureList) do
520 local award = val.award:toNumMap() 520 local award = val.award:toNumMap()
521 for k,v in pairs(award) do 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 end 523 end
524 end 524 end
525 end 525 end
src/models/Daily.lua
@@ -242,6 +242,7 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) @@ -242,6 +242,7 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
242 print("curInfo is nil") 242 print("curInfo is nil")
243 return treasure 243 return treasure
244 end 244 end
  245 + local treasureBase = self:getProperty("treasureBase")
245 246
246 --开始挖宝关卡ID=挂机关卡ID 247 --开始挖宝关卡ID=挂机关卡ID
247 if chapterId == curInfo.chapter_id then 248 if chapterId == curInfo.chapter_id then
@@ -253,8 +254,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) @@ -253,8 +254,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
253 if curInfo.cool_time > 1 then 254 if curInfo.cool_time > 1 then
254 --宝藏冷却时间 255 --宝藏冷却时间
255 if not curInfo["expire_time"] then 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 else 263 else
259 --已经领取宝藏 检索宝藏冷却时间 264 --已经领取宝藏 检索宝藏冷却时间
260 if skynet.timex() >= curInfo["expire_time"] then 265 if skynet.timex() >= curInfo["expire_time"] then
@@ -262,8 +267,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) @@ -262,8 +267,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
262 end 267 end
263 end 268 end
264 else 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 end 276 end
268 end 277 end
269 end 278 end
@@ -274,8 +283,13 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) @@ -274,8 +283,13 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
274 if curInfo.cool_time > 1 then 283 if curInfo.cool_time > 1 then
275 --宝藏冷却时间 284 --宝藏冷却时间
276 if not curInfo["expire_time"] then 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 else 293 else
280 --已经领取宝藏 检索宝藏冷却时间 294 --已经领取宝藏 检索宝藏冷却时间
281 if skynet.timex() >= curInfo["expire_time"] then 295 if skynet.timex() >= curInfo["expire_time"] then
@@ -283,8 +297,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId) @@ -283,8 +297,12 @@ function Daily:checkTreasureChapterId(curInfo, treasureList, chapterId)
283 end 297 end
284 end 298 end
285 else 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 end 306 end
289 else 307 else
290 curInfo["end_time"] = nil 308 curInfo["end_time"] = nil