From 76f0493d766bf8acd86487ab1fed723ed2bfe167 Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Tue, 18 May 2021 20:54:19 +0800 Subject: [PATCH] feat: 铭文仓库溢出奖励时,通过邮件补发溢出部分 1.主动拾荒结算时 邮件id=20,奖励内容超过一封邮件上限时,拆成新的邮件发放 --- src/actions/AdvAction.lua | 5 +++++ src/actions/EmailAction.lua | 2 ++ src/actions/RoleAction.lua | 4 +++- src/adv/Adv.lua | 2 ++ src/models/RolePlugin.lua | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/actions/AdvAction.lua b/src/actions/AdvAction.lua index 07fe98a..ebfccb9 100644 --- a/src/actions/AdvAction.lua +++ b/src/actions/AdvAction.lua @@ -897,6 +897,11 @@ function _M.wheelSurfRpc(agent, data) local costs = {[ItemId.OldCoin] = cost[ctype]} if not next(costs) then return 6 end + local tmpcount = 1 + if ctype == 2 then + tmpcount = 10 + end + if role:checkRuneFully(tmpcount) then return 6 end if not role:checkItemEnough(costs) then return 5 end role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) diff --git a/src/actions/EmailAction.lua b/src/actions/EmailAction.lua index bfc4130..935deae 100644 --- a/src/actions/EmailAction.lua +++ b/src/actions/EmailAction.lua @@ -144,6 +144,8 @@ function _M.drawAttachRpc(agent, data) if attachments == "" then return end local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) + if role:checkRuneFullyByReward(reward) then return 1 end + email:setProperty("status", 2, true) email:log(role, 2) SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index b340309..85b7f94 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -677,7 +677,7 @@ function _M.openTimeBoxRpc(agent, data) local costId = msg.costId local costs = (msg.costs or ""):toNumMap() if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end - + local costIdData = csvdb["itemCsv"][costId] local count = 0 for itemId, num in pairs(costs) do @@ -686,6 +686,8 @@ function _M.openTimeBoxRpc(agent, data) count = count + num end + if role:checkRuneFully(count) then return 10 end --开箱子,如果铭文仓库已经满了则不让开箱 + if role:getItemCount(costId) < count then return 8 end if not role:checkItemEnough(costs) then return 9 end diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index 39892c8..0ff3ebb 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -881,6 +881,8 @@ function Adv:over(success, rewardRatio, overType) reward[itemId] = math.ceil(count * rewardRatio / 100) end end + + self.owner:checkRuneCount(reward) reward = self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}}) local backAdvCount diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 2857ede..76c58b1 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -2823,6 +2823,72 @@ function RolePlugin.bind(Role) self:mylog("hero_action", {desc = desc, int1 = heroType}) end + function Role:getRuneBatCount() + local count = 0 + for _, rune in pairs(self.runeBag) do + if next(rune) then + count = count + 1 + end + end + return count or 0 + end + + -- 铭文仓库是否满仓 + function Role:checkRuneFully(count) + count = count or 0 + local page = globalCsv.store_type[ItemType.Rune] + local limit = self:getProperty("bagLimit")[page] + return self:getRuneBatCount() + count >= limit + end + + function Role:checkRuneFullyByReward(reward) + local count = self:getRuneBatCount() + local page = globalCsv.store_type[ItemType.Rune] + local limit = self:getProperty("bagLimit")[page] + if count >= limit then + return true + end + for itemId, n in pairs(reward) do + local itemData = csvdb["itemCsv"][itemId] + if itemData and itemData.type == ItemType.Rune then + count = count + n + if count > limit then return true end + end + end + return false + end + + -- 把溢出的铭文奖励通过邮件发送 + function Role:checkRuneCount(reward) + local firstMore = false + local count = self:getRuneBatCount() + local page = globalCsv.store_type[ItemType.Rune] + local limit = self:getProperty("bagLimit")[page] + if count >= limit then + firstMore = true + end + + local tmpreward = {} + for itemId, n in pairs(reward) do + local itemData = csvdb["itemCsv"][itemId] + if itemData and itemData.type == ItemType.Rune then + count = count + n + if count > limit then + if not firstMore then + firstMore = true + reward[itemId] = n - (count - limit) + tmpreward[itemId] = count - limit + else + reward[itemId] = nil + tmpreward[itemId] = n + end + end + end + end + if next(tmpreward) then + self:sendMail(20, nil, tmpreward) + end + end end return RolePlugin \ No newline at end of file -- libgit2 0.21.2