From b8b1c164bffb27002e0eef51a6a2b59591396c69 Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Mon, 7 Dec 2020 16:54:18 +0800 Subject: [PATCH] 扭蛋活动,万能碎片bug --- src/actions/ActivityAction.lua | 34 +++++++++++++++++++++++++++++++++- src/actions/EmailAction.lua | 2 +- src/actions/GmAction.lua | 2 +- src/actions/HeroAction.lua | 8 ++++---- src/actions/StoreAction.lua | 11 ++++++----- src/csvdata | 2 +- src/models/Activity.lua | 12 ++++++++---- 7 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/actions/ActivityAction.lua b/src/actions/ActivityAction.lua index c265ef1..2cbbf78 100644 --- a/src/actions/ActivityAction.lua +++ b/src/actions/ActivityAction.lua @@ -268,7 +268,7 @@ function _M.exchangeRpc(agent, data) local msg = MsgPack.unpack(data) local actid = msg.actid local id = msg.id - if not role.activity:isOpen("Exchange") then return 1 end + if not role.activity:isOpenById(actid) then return 1 end local exchangeCfg = csvdb["activity_exchangeCsv"][actid] if not exchangeCfg then return 2 end @@ -295,4 +295,36 @@ function _M.exchangeRpc(agent, data) return true end +function _M.gachakonRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local actid = msg.actid + if not role.activity:isOpenById(actid) then return 1 end + + local actCfg = csvdb["activity_capsuleToysCsv"][actid] + if not actCfg then return 2 end + + local gachakonInfo = role.activity:getActData("Gachakon") or {} + local tmpCfg = clone(actCfg) + local flag = 0 + 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 + if cfg.weight > 0 then + flag = 1 + end + end + if flag == 0 then return 3 end + + local id = math.randWeight(tmpCfg, "weight") + local reward, change = role:award(tmpCfg[id].award, {log = {desc = "actGachakon", int1 = actid, int2 = id}}) + + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 + role.activity:updateActData("Gachakon", gachakonInfo) + + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change))) + return true +end + return _M \ No newline at end of file diff --git a/src/actions/EmailAction.lua b/src/actions/EmailAction.lua index 2d037e2..7a14ca9 100644 --- a/src/actions/EmailAction.lua +++ b/src/actions/EmailAction.lua @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) local attachments = getEmailAttachments(email) if attachments == "" then return end - local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId}}) + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) email:setProperty("status", 2) email:log(role, 2) SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) diff --git a/src/actions/GmAction.lua b/src/actions/GmAction.lua index 85d655f..2a507d3 100644 --- a/src/actions/GmAction.lua +++ b/src/actions/GmAction.lua @@ -534,7 +534,7 @@ function _M.test(role, pms) --local hero = require ("actions.HeroAction") --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) - role:sendMail(13, nil, "1=2", {111}) + --role:sendMail(13, nil, "1=2", {111}) return "成功" end diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index 2a66d22..afab15d 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) local itemData = csvdb["itemCsv"][itemId] if not itemData or itemData.type ~= ItemType.HeroFCommon then return end local cost = globalCsv.unit_fragment_cost[itemData.quality] - if not cost or role:getItemCount(itemId) < cost then return end + if not cost or role:getItemCount(itemId) < cost then return 1 end local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] - if not randomData then return end + if not randomData then return 2 end local temp = randomData.gift1:randWeight(true) - if not temp or not next(temp) then return end + if not temp or not next(temp) then return 3 end role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) - local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}}) + local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) diff --git a/src/actions/StoreAction.lua b/src/actions/StoreAction.lua index 117020a..7a3824d 100644 --- a/src/actions/StoreAction.lua +++ b/src/actions/StoreAction.lua @@ -401,15 +401,16 @@ function _M.getTotalRechargeAwardRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local index = msg.index -- 领取的索引id + local totalTwd = role:getProperty("twdC") local totalRechargeRecord = role.storeData:getProperty("totalRR") local flag = string.char(string.getbit(totalRechargeRecord, index)) - if flag == "1" then - return 1 - end - totalRechargeRecord = string.setbit(totalRechargeRecord, index) - role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) + if flag == "1" then return 1 end local cfg = csvdb["Csv"][index] if not cfg then return 2 end + if cfg.condition > totalTwd then return 3 end + + totalRechargeRecord = string.setbit(totalRechargeRecord, index) + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) local reward, _ = role:award(cfg.reward, {log = {desc = "totalRecharge", int1 = index}}) SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack({reward = reward})) diff --git a/src/csvdata b/src/csvdata index 897a3e0..e3723ff 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 897a3e0e4afa8217614a9ecf199d54b0ca641bab +Subproject commit e3723ff3514f68c633926970e695d1c9ecea1cd4 diff --git a/src/models/Activity.lua b/src/models/Activity.lua index bc3afd1..29b838a 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -54,10 +54,10 @@ Activity.schema = { act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 - act20 = {"table", {}, true}, -- {id=兑换数量} - act21 = {"table", {}}, -- {id=抽取的数量} - act22 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} - act23 = {"table", {}}, -- {挂机信息} + act17 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} + act18 = {"table", {}, true}, -- {id=兑换数量} + act19 = {"table", {}}, -- {挂机信息} + act20 = {"table", {}}, -- {id=扭蛋抽出数量} } function Activity:data() @@ -148,6 +148,10 @@ function Activity:isOpen(activityType) return false end +function Activity:isOpneById(id) + return self._isOpen[id] +end + function Activity:getActData(actType) actType = checkActivityType(actType) return self:getProperty("act" .. actType) -- libgit2 0.21.2