Commit e0ba98e450af25fefaafb5428018f1f22fbfc48e
Merge branch 'develop' of 120.26.43.151:wasteland/server into develop
Showing
1 changed file
with
15 additions
and
5 deletions
Show diff stats
src/actions/RoleAction.lua
@@ -481,16 +481,26 @@ function _M.openTimeBoxRpc(agent, data) | @@ -481,16 +481,26 @@ function _M.openTimeBoxRpc(agent, data) | ||
481 | -- 随机奖励 | 481 | -- 随机奖励 |
482 | local randomGift = randomData.random_gift | 482 | local randomGift = randomData.random_gift |
483 | local randomNum = randomData.random_num | 483 | local randomNum = randomData.random_num |
484 | - if boxL[slot].gem ~= 0 then | ||
485 | - randomNum = randomData[boxL[slot].gem .. "_gem_num"] | ||
486 | - randomGift = randomData[boxL[slot].gem .. "_gem_gift"] | ||
487 | - end | 484 | + local gemId = boxL[slot].gem |
488 | 485 | ||
489 | if randomNum > 0 and randomGift and randomGift ~= "" then | 486 | if randomNum > 0 and randomGift and randomGift ~= "" then |
487 | + local selectGift = {} | ||
490 | local pool = {} | 488 | local pool = {} |
491 | for _, temp in ipairs(randomGift:toArray()) do | 489 | for _, temp in ipairs(randomGift:toArray()) do |
492 | - table.insert(pool, temp:toArray(true, "=")) | 490 | + local set = temp:toArray(true, "=") |
491 | + if gemId == set[1] then | ||
492 | + table.insert(selectGift, set) | ||
493 | + else | ||
494 | + table.insert(pool, set) | ||
495 | + end | ||
496 | + end | ||
497 | + | ||
498 | + if gemId ~= 0 and next(selectGift) then | ||
499 | + randomNum = randomNum - 1 | ||
500 | + local idx = math.randWeight(pool, 3) | ||
501 | + reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2] | ||
493 | end | 502 | end |
503 | + | ||
494 | local needCount = math.min(#pool, randomNum) | 504 | local needCount = math.min(#pool, randomNum) |
495 | for j = 1, needCount do | 505 | for j = 1, needCount do |
496 | local idx = math.randWeight(pool, 3) | 506 | local idx = math.randWeight(pool, 3) |