Commit 4d8bd32c55e9c8dca2cce26b1c6f24e4507ef604
1 parent
fa565e0c
倒计时开箱子
Showing
1 changed file
with
10 additions
and
13 deletions
Show diff stats
src/actions/RoleAction.lua
... | ... | @@ -363,7 +363,7 @@ end |
363 | 363 | function _M.openTimeBoxRpc(agent, data) |
364 | 364 | local role = agent.role |
365 | 365 | local msg = MsgPack.unpack(data) |
366 | - local oper = msg.oper -- 操作 1 - 3 | |
366 | + local oper = msg.oper -- 操作 1 - 2 | |
367 | 367 | local slot = msg.slot -- 位置 1 - 6 |
368 | 368 | if math.illegalNum(slot, 1, globalCsv.box_timeOpen_maxNum) then return end |
369 | 369 | |
... | ... | @@ -374,25 +374,22 @@ function _M.openTimeBoxRpc(agent, data) |
374 | 374 | if role:getItemCount(itemId) < 1 then return end |
375 | 375 | local itemData = csvdb["itemCsv"][itemId] |
376 | 376 | local randomData = csvdb["item_randomCsv"][itemId] |
377 | - if not randomData or randomData.openTime <= 0 then return end | |
377 | + if not itemData or not randomData or randomData.openTime <= 0 then return end | |
378 | 378 | |
379 | 379 | if boxL[slot] then return end |
380 | 380 | role:costItems({[itemId] = 1}) |
381 | 381 | boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} |
382 | 382 | |
383 | - elseif oper == 2 then -- 上宝石 | |
383 | + -- 上宝石 | |
384 | 384 | local gemId = msg.gem or 0 |
385 | - if not boxL[slot] then return end | |
386 | - if boxL[slot].gem or boxL[slot].time <= skynet.timex() then return end | |
387 | - local itemData = csvdb["itemCsv"][boxL[slot].id] | |
388 | - local randomData = csvdb["item_randomCsv"][itemId] | |
389 | 385 | local num = randomData[gemId .. "_gem_num"] |
390 | - if not num then return end | |
386 | + if num then | |
387 | + if not role:checkItemEnough({[gemId] = 1}) then return end | |
388 | + role:costItems({[gemId] = 1}) | |
389 | + end | |
391 | 390 | |
392 | - if not role:checkItemEnough({[gemId] = 1}) then return end | |
393 | - role:costItems({[gemId] = 1}) | |
394 | 391 | boxL[slot].gem = gemId |
395 | - elseif oper == 3 then -- 领取 | |
392 | + elseif oper == 2 then -- 领取 | |
396 | 393 | local quick = msg.quick |
397 | 394 | if not boxL[slot] then return end |
398 | 395 | if boxL[slot].time > skynet.timex() then -- 没开完 |
... | ... | @@ -404,12 +401,12 @@ function _M.openTimeBoxRpc(agent, data) |
404 | 401 | end |
405 | 402 | |
406 | 403 | local itemData = csvdb["itemCsv"][boxL[slot].id] |
407 | - local randomData = csvdb["item_randomCsv"][itemId] | |
404 | + local randomData = csvdb["item_randomCsv"][itemData.id] | |
408 | 405 | reward = randomData.gift:toNumMap() -- 固定奖励 |
409 | 406 | -- 随机奖励 |
410 | 407 | local randomGift = randomData.random_gift |
411 | 408 | local randomNum = randomData.random_num |
412 | - if boxL[slot].gem then | |
409 | + if boxL[slot].gem ~= 0 then | |
413 | 410 | randomNum = randomData[boxL[slot].gem .. "_gem_num"] |
414 | 411 | randomGift = randomData[boxL[slot].gem .. "_gem_gift"] |
415 | 412 | end | ... | ... |