Commit 538e9773445d285746f5905b4443809d90a8e3fe
1 parent
007af97e
上宝石
Showing
1 changed file
with
2 additions
and
23 deletions
Show diff stats
src/actions/RoleAction.lua
| @@ -457,16 +457,7 @@ function _M.openTimeBoxRpc(agent, data) | @@ -457,16 +457,7 @@ function _M.openTimeBoxRpc(agent, data) | ||
| 457 | if boxL[slot] then return end | 457 | if boxL[slot] then return end |
| 458 | role:costItems({[itemId] = 1}) | 458 | role:costItems({[itemId] = 1}) |
| 459 | boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} | 459 | boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} |
| 460 | - | ||
| 461 | - -- 上宝石 | ||
| 462 | - local gemId = msg.gem or 0 | ||
| 463 | - -- local num = randomData[gemId .. "_gem_num"] | ||
| 464 | - -- if num then | ||
| 465 | - -- if not role:checkItemEnough({[gemId] = 1}) then return end | ||
| 466 | - -- role:costItems({[gemId] = 1}) | ||
| 467 | - -- end | ||
| 468 | - | ||
| 469 | - boxL[slot].gem = gemId | 460 | + |
| 470 | elseif oper == 2 then -- 领取 | 461 | elseif oper == 2 then -- 领取 |
| 471 | local quick = msg.quick | 462 | local quick = msg.quick |
| 472 | if not boxL[slot] then return end | 463 | if not boxL[slot] then return end |
| @@ -482,27 +473,15 @@ function _M.openTimeBoxRpc(agent, data) | @@ -482,27 +473,15 @@ function _M.openTimeBoxRpc(agent, data) | ||
| 482 | local randomData = csvdb["item_randomCsv"][itemData.id] | 473 | local randomData = csvdb["item_randomCsv"][itemData.id] |
| 483 | reward = randomData.gift:toNumMap() -- 固定奖励 | 474 | reward = randomData.gift:toNumMap() -- 固定奖励 |
| 484 | -- 随机奖励 | 475 | -- 随机奖励 |
| 485 | - local gemId = boxL[slot].gem | ||
| 486 | local reward = {} | 476 | local reward = {} |
| 487 | for i = 1, 10 do | 477 | for i = 1, 10 do |
| 488 | local num = randomData["num" .. i] | 478 | local num = randomData["num" .. i] |
| 489 | local gift = randomData["gift" .. i] | 479 | local gift = randomData["gift" .. i] |
| 490 | if num and gift and num > 0 and gift ~= "" then | 480 | if num and gift and num > 0 and gift ~= "" then |
| 491 | local pool = {} | 481 | local pool = {} |
| 492 | - local selectGift = {} | ||
| 493 | for _, temp in ipairs(gift:toArray()) do | 482 | for _, temp in ipairs(gift:toArray()) do |
| 494 | local set = temp:toArray(true, "=") | 483 | local set = temp:toArray(true, "=") |
| 495 | - if gemId == set[1] then | ||
| 496 | - table.insert(selectGift, set) | ||
| 497 | - else | ||
| 498 | - table.insert(pool, set) | ||
| 499 | - end | ||
| 500 | - end | ||
| 501 | - | ||
| 502 | - if gemId ~= 0 and next(selectGift) then | ||
| 503 | - num = num - 1 | ||
| 504 | - local idx = math.randWeight(selectGift, 3) | ||
| 505 | - reward[selectGift[idx][1]] = (reward[selectGift[idx][1]] or 0) + selectGift[idx][2] | 484 | + table.insert(pool, set) |
| 506 | end | 485 | end |
| 507 | 486 | ||
| 508 | local needCount = math.min(#pool, num) | 487 | local needCount = math.min(#pool, num) |