From 1be743f30686a82821b5e448160fb8362489338b Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Tue, 8 Dec 2020 21:05:20 +0800 Subject: [PATCH] 扭蛋机调试 --- src/actions/ActivityAction.lua | 33 ++++++++++++++++----------------- src/models/Activity.lua | 7 ++++++- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index b5f96ba..0bf4eea 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -313,47 +313,46 @@ function _M.gachakonRpc(agent, data) local actCfg = csvdb["activity_capsuleToysCsv"][actid] if not actCfg then return 3 end - for k, v in pairs(cost) do - cost[k] = v * count - end - - if not role:checkItemEnough(cost) then return 4 end - local gachakonInfo = role.activity:getActData("Gachakon") or {} - local tmpCfg = clone(actCfg) local award = {} local remain = 0 - local reset = false for i = 1, count do - local flag = 0 + local tmpCfg = clone(actCfg) + remain = 0 + print("-----------------, ", i) for id, cfg in pairs(tmpCfg) do local num = gachakonInfo[id] or 0 - cfg.amount = cfg.amount >= num and cfg.amount - num or 0 - cfg.weight = cfg.weight * cfg.amount + num = cfg.amount >= num and cfg.amount - num or 0 + cfg.weight = cfg.weight * num if cfg.weight > 0 then - flag = 1 + remain = remain + num end + print("num ".. num, id, cfg.weight, cfg.amount) end - if flag == 0 then - reset = true + if remain == 0 then break end local id = math.randWeight(tmpCfg, "weight") + if not id then return 4 end gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 local curAward = tmpCfg[id].award:toNumMap() for k, v in pairs(curAward) do award[k] = (award[k] or 0) + v end - remain = remain + 1 end - if count > remain then return 5 end + for k, v in pairs(cost) do + cost[k] = v * count + end + + if not role:checkItemEnough(cost) then return 5 end role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) - if reset then + if remain <= count then gachakonInfo = {} + print("hahaha") end role.activity:updateActData("Gachakon", gachakonInfo) diff --git a/src/models/Activity.lua b/src/models/Activity.lua index fbfb1c9..923b498 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -71,6 +71,11 @@ function Activity:data() act12 = self:getProperty("act12"), act13 = self:getProperty("act13"), act14 = self:getProperty("act14"), + + act17 = self:getProperty("act17"), + act18 = self:getProperty("act18"), + act19 = self:getProperty("act19"), + act20 = self:getProperty("act20"), } end @@ -607,7 +612,7 @@ function Activity:recycleActItem(actId) if not actCfg then return end local gift = {} local costs = {} - for _, arr in ipairs(role:getItemCount(actCfg.recycle):toTableArray(true)) do + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do local fromId, toId, toNum = arr[1], arr[2], arr[3] local itemCount = role:getItemCount(fromId) if itemCount > 0 then -- libgit2 0.21.2