From 2c8d1dfe5d519324c207279cc81a3b4e47448a6b Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Fri, 9 Aug 2019 10:15:32 +0800 Subject: [PATCH] 奖励逻辑 --- src/actions/RoleAction.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 33c90c2..4bfc5d0 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -359,11 +359,11 @@ function _M.openTimeBoxRpc(agent, data) if boxL[slot].gem or boxL[slot].time <= skynet.timex() then return end local itemData = csvdb["itemCsv"][boxL[slot].id] local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] - local costCount = randomData[gemId .. "_gem_num"] - if not costCount then return end + local num = randomData[gemId .. "_gem_num"] + if not num then return end - if not role:checkItemEnough({[gemId] = costCount}) then return end - role:costItems({[gemId] = costCount}) + if not role:checkItemEnough({[gemId] = 1}) then return end + role:costItems({[gemId] = 1}) boxL[slot].gem = gemId elseif oper == 3 then -- 领取 local quick = msg.quick @@ -381,15 +381,18 @@ function _M.openTimeBoxRpc(agent, data) reward = randomData.gift:toNumMap() -- 固定奖励 -- 随机奖励 local randomGift = randomData.random_gift + local randomNum = randomData.random_num if boxL[slot].gem then + randomNum = randomData[boxL[slot].gem .. "_gem_num"] randomGift = randomData[boxL[slot].gem .. "_gem_gift"] end - if randomData.random_num > 0 and randomGift and randomGift ~= "" then + + if randomNum > 0 and randomGift and randomGift ~= "" then local pool = {} for _, temp in ipairs(randomGift:toArray()) do table.insert(pool, temp:toArray(true, "=")) end - local needCount = math.min(#pool, randomData.random_num) + local needCount = math.min(#pool, randomNum) for j = 1, needCount do local idx = math.randWeight(pool, 3) reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2] -- libgit2 0.21.2