Commit 2c8d1dfe5d519324c207279cc81a3b4e47448a6b
1 parent
bd535b08
奖励逻辑
Showing
1 changed file
with
9 additions
and
6 deletions
Show diff stats
src/actions/RoleAction.lua
@@ -359,11 +359,11 @@ function _M.openTimeBoxRpc(agent, data) | @@ -359,11 +359,11 @@ function _M.openTimeBoxRpc(agent, data) | ||
359 | if boxL[slot].gem or boxL[slot].time <= skynet.timex() then return end | 359 | if boxL[slot].gem or boxL[slot].time <= skynet.timex() then return end |
360 | local itemData = csvdb["itemCsv"][boxL[slot].id] | 360 | local itemData = csvdb["itemCsv"][boxL[slot].id] |
361 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | 361 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] |
362 | - local costCount = randomData[gemId .. "_gem_num"] | ||
363 | - if not costCount then return end | 362 | + local num = randomData[gemId .. "_gem_num"] |
363 | + if not num then return end | ||
364 | 364 | ||
365 | - if not role:checkItemEnough({[gemId] = costCount}) then return end | ||
366 | - role:costItems({[gemId] = costCount}) | 365 | + if not role:checkItemEnough({[gemId] = 1}) then return end |
366 | + role:costItems({[gemId] = 1}) | ||
367 | boxL[slot].gem = gemId | 367 | boxL[slot].gem = gemId |
368 | elseif oper == 3 then -- 领取 | 368 | elseif oper == 3 then -- 领取 |
369 | local quick = msg.quick | 369 | local quick = msg.quick |
@@ -381,15 +381,18 @@ function _M.openTimeBoxRpc(agent, data) | @@ -381,15 +381,18 @@ function _M.openTimeBoxRpc(agent, data) | ||
381 | reward = randomData.gift:toNumMap() -- 固定奖励 | 381 | reward = randomData.gift:toNumMap() -- 固定奖励 |
382 | -- 随机奖励 | 382 | -- 随机奖励 |
383 | local randomGift = randomData.random_gift | 383 | local randomGift = randomData.random_gift |
384 | + local randomNum = randomData.random_num | ||
384 | if boxL[slot].gem then | 385 | if boxL[slot].gem then |
386 | + randomNum = randomData[boxL[slot].gem .. "_gem_num"] | ||
385 | randomGift = randomData[boxL[slot].gem .. "_gem_gift"] | 387 | randomGift = randomData[boxL[slot].gem .. "_gem_gift"] |
386 | end | 388 | end |
387 | - if randomData.random_num > 0 and randomGift and randomGift ~= "" then | 389 | + |
390 | + if randomNum > 0 and randomGift and randomGift ~= "" then | ||
388 | local pool = {} | 391 | local pool = {} |
389 | for _, temp in ipairs(randomGift:toArray()) do | 392 | for _, temp in ipairs(randomGift:toArray()) do |
390 | table.insert(pool, temp:toArray(true, "=")) | 393 | table.insert(pool, temp:toArray(true, "=")) |
391 | end | 394 | end |
392 | - local needCount = math.min(#pool, randomData.random_num) | 395 | + local needCount = math.min(#pool, randomNum) |
393 | for j = 1, needCount do | 396 | for j = 1, needCount do |
394 | local idx = math.randWeight(pool, 3) | 397 | local idx = math.randWeight(pool, 3) |
395 | reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2] | 398 | reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2] |