From 764e5296fc6825282b892094ada6dac0bbfe72e3 Mon Sep 17 00:00:00 2001 From: zhouhaihai <781184096@qq.com> Date: Tue, 11 Feb 2020 16:39:25 +0800 Subject: [PATCH] 冒险抽奖保底 --- src/ProtocolCode.lua | 1 + src/actions/AdvAction.lua | 31 +++++++++++++++++++++++++++++++ src/csvdata | 2 +- src/models/Role.lua | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 9b21996..4386ba0 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -59,6 +59,7 @@ actionCodes = { Adv_chooseArtifactRpc = 165, Adv_wearArtifactRpc = 166, Adv_upArtifactRpc = 167, + Adv_repayWheelSurfRpc = 168, Hero_loadInfos = 201, Hero_updateProperty = 202, diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 6449408..d6f0a33 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -544,6 +544,9 @@ function _M.wheelSurfRpc(agent, data) if not role:checkItemEnough(costs) then return end role:costItems(costs) role:addAdvLvExp(costs[ItemId.OldCoin] or 0) + local advDrawB = role:getProperty("advDrawB") + advDrawB[ptype] = (advDrawB[ptype] or 0) + count + role:updateProperty({field = "advDrawB", value = advDrawB}) -- 随机池子 local pool = drawData.weight:randWeight() local reward = {} @@ -557,6 +560,34 @@ function _M.wheelSurfRpc(agent, data) SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward})) return true end +function _M.repayWheelSurfRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + + local ptype = msg.ptype + + if ptype == 2 and not role:isFuncOpen(FuncOpenType.AdvEndless) then + return + end + + local drawTypeData = csvdb["adv_wheelsurfCsv"][ptype] + if not drawTypeData then return end + local drawData = drawTypeData[role:getAdvWheelSurfLv(ptype)] + if not drawData then return end + + local advDrawB = role:getProperty("advDrawB") + if (advDrawB[ptype] or 0) < globalCsv.adv_draw_back_cond then + return + end + advDrawB[ptype] = advDrawB[ptype] - globalCsv.adv_draw_back_cond + role:updateProperty({field = "advDrawB", value = advDrawB}) + local gift = drawData["pool3"]:randWeight(true) + local reward = {[gift[1]] = gift[2]} + reward = role:award(reward) + + SendPacket(actionCodes.Adv_repayWheelSurfRpc, MsgPack.pack({reward = reward})) + return true +end function _M.finishAchievRpc(agent, data) local role = agent.role diff --git a/src/csvdata b/src/csvdata index 4bc2e8b..0f883be 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 4bc2e8bad2703202f82475c09e046b2d51a9fa2f +Subproject commit 0f883beaf731c166deb8b7169108c1014d504e64 diff --git a/src/models/Role.lua b/src/models/Role.lua index 71b9e3a..fa254fb 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -68,6 +68,7 @@ Role.schema = { advAFOpen = {"table", {}}, -- 解锁的神器 {[id] = 1} advAFGet = {"table", {}}, -- 当前拥有的神器 {[id] = 等级} advAFWear = {"table", {}}, -- 当前拥有的神器 {[slot] = id} + advDrawB = {"table", {}}, -- 冒险抽奖回馈 {[1] = 0, [2] = 100} -- 池子类型 = 点数 --挂机相关 hangPass = {"table", {}}, -- 挂机通过的最大关卡 @@ -248,6 +249,7 @@ function Role:data() advElM = self:getProperty("advElM"), advAFGet = self:getProperty("advAFGet"), advAFWear = self:getProperty("advAFWear"), + advDrawB = self:getProperty("advDrawB"), hangPass = self:getProperty("hangPass"), hangTeam = self:getProperty("hangTeam"), -- libgit2 0.21.2