Commit 76f0493d766bf8acd86487ab1fed723ed2bfe167
1 parent
ebbed4db
feat: 铭文仓库溢出奖励时,通过邮件补发溢出部分
1.主动拾荒结算时 邮件id=20,奖励内容超过一封邮件上限时,拆成新的邮件发放 铭文获得时,仓库已满,无法操作 1.资助抽奖开始时 2.选择时钟箱拆解时 3.领取邮件时
Showing
5 changed files
with
78 additions
and
1 deletions
Show diff stats
src/actions/AdvAction.lua
| @@ -897,6 +897,11 @@ function _M.wheelSurfRpc(agent, data) | @@ -897,6 +897,11 @@ function _M.wheelSurfRpc(agent, data) | ||
| 897 | local costs = {[ItemId.OldCoin] = cost[ctype]} | 897 | local costs = {[ItemId.OldCoin] = cost[ctype]} |
| 898 | if not next(costs) then return 6 end | 898 | if not next(costs) then return 6 end |
| 899 | 899 | ||
| 900 | + local tmpcount = 1 | ||
| 901 | + if ctype == 2 then | ||
| 902 | + tmpcount = 10 | ||
| 903 | + end | ||
| 904 | + if role:checkRuneFully(tmpcount) then return 6 end | ||
| 900 | 905 | ||
| 901 | if not role:checkItemEnough(costs) then return 5 end | 906 | if not role:checkItemEnough(costs) then return 5 end |
| 902 | role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) | 907 | role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) |
src/actions/EmailAction.lua
| @@ -144,6 +144,8 @@ function _M.drawAttachRpc(agent, data) | @@ -144,6 +144,8 @@ function _M.drawAttachRpc(agent, data) | ||
| 144 | if attachments == "" then return end | 144 | if attachments == "" then return end |
| 145 | 145 | ||
| 146 | local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) | 146 | local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) |
| 147 | + if role:checkRuneFullyByReward(reward) then return 1 end | ||
| 148 | + | ||
| 147 | email:setProperty("status", 2, true) | 149 | email:setProperty("status", 2, true) |
| 148 | email:log(role, 2) | 150 | email:log(role, 2) |
| 149 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | 151 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) |
src/actions/RoleAction.lua
| @@ -677,7 +677,7 @@ function _M.openTimeBoxRpc(agent, data) | @@ -677,7 +677,7 @@ function _M.openTimeBoxRpc(agent, data) | ||
| 677 | local costId = msg.costId | 677 | local costId = msg.costId |
| 678 | local costs = (msg.costs or ""):toNumMap() | 678 | local costs = (msg.costs or ""):toNumMap() |
| 679 | if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end | 679 | if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end |
| 680 | - | 680 | + |
| 681 | local costIdData = csvdb["itemCsv"][costId] | 681 | local costIdData = csvdb["itemCsv"][costId] |
| 682 | local count = 0 | 682 | local count = 0 |
| 683 | for itemId, num in pairs(costs) do | 683 | for itemId, num in pairs(costs) do |
| @@ -686,6 +686,8 @@ function _M.openTimeBoxRpc(agent, data) | @@ -686,6 +686,8 @@ function _M.openTimeBoxRpc(agent, data) | ||
| 686 | count = count + num | 686 | count = count + num |
| 687 | end | 687 | end |
| 688 | 688 | ||
| 689 | + if role:checkRuneFully(count) then return 10 end --开箱子,如果铭文仓库已经满了则不让开箱 | ||
| 690 | + | ||
| 689 | if role:getItemCount(costId) < count then return 8 end | 691 | if role:getItemCount(costId) < count then return 8 end |
| 690 | if not role:checkItemEnough(costs) then return 9 end | 692 | if not role:checkItemEnough(costs) then return 9 end |
| 691 | 693 |
src/adv/Adv.lua
| @@ -881,6 +881,8 @@ function Adv:over(success, rewardRatio, overType) | @@ -881,6 +881,8 @@ function Adv:over(success, rewardRatio, overType) | ||
| 881 | reward[itemId] = math.ceil(count * rewardRatio / 100) | 881 | reward[itemId] = math.ceil(count * rewardRatio / 100) |
| 882 | end | 882 | end |
| 883 | end | 883 | end |
| 884 | + | ||
| 885 | + self.owner:checkRuneCount(reward) | ||
| 884 | reward = self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}}) | 886 | reward = self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}}) |
| 885 | 887 | ||
| 886 | local backAdvCount | 888 | local backAdvCount |
src/models/RolePlugin.lua
| @@ -2823,6 +2823,72 @@ function RolePlugin.bind(Role) | @@ -2823,6 +2823,72 @@ function RolePlugin.bind(Role) | ||
| 2823 | self:mylog("hero_action", {desc = desc, int1 = heroType}) | 2823 | self:mylog("hero_action", {desc = desc, int1 = heroType}) |
| 2824 | end | 2824 | end |
| 2825 | 2825 | ||
| 2826 | + function Role:getRuneBatCount() | ||
| 2827 | + local count = 0 | ||
| 2828 | + for _, rune in pairs(self.runeBag) do | ||
| 2829 | + if next(rune) then | ||
| 2830 | + count = count + 1 | ||
| 2831 | + end | ||
| 2832 | + end | ||
| 2833 | + return count or 0 | ||
| 2834 | + end | ||
| 2835 | + | ||
| 2836 | + -- 铭文仓库是否满仓 | ||
| 2837 | + function Role:checkRuneFully(count) | ||
| 2838 | + count = count or 0 | ||
| 2839 | + local page = globalCsv.store_type[ItemType.Rune] | ||
| 2840 | + local limit = self:getProperty("bagLimit")[page] | ||
| 2841 | + return self:getRuneBatCount() + count >= limit | ||
| 2842 | + end | ||
| 2843 | + | ||
| 2844 | + function Role:checkRuneFullyByReward(reward) | ||
| 2845 | + local count = self:getRuneBatCount() | ||
| 2846 | + local page = globalCsv.store_type[ItemType.Rune] | ||
| 2847 | + local limit = self:getProperty("bagLimit")[page] | ||
| 2848 | + if count >= limit then | ||
| 2849 | + return true | ||
| 2850 | + end | ||
| 2851 | + for itemId, n in pairs(reward) do | ||
| 2852 | + local itemData = csvdb["itemCsv"][itemId] | ||
| 2853 | + if itemData and itemData.type == ItemType.Rune then | ||
| 2854 | + count = count + n | ||
| 2855 | + if count > limit then return true end | ||
| 2856 | + end | ||
| 2857 | + end | ||
| 2858 | + return false | ||
| 2859 | + end | ||
| 2860 | + | ||
| 2861 | + -- 把溢出的铭文奖励通过邮件发送 | ||
| 2862 | + function Role:checkRuneCount(reward) | ||
| 2863 | + local firstMore = false | ||
| 2864 | + local count = self:getRuneBatCount() | ||
| 2865 | + local page = globalCsv.store_type[ItemType.Rune] | ||
| 2866 | + local limit = self:getProperty("bagLimit")[page] | ||
| 2867 | + if count >= limit then | ||
| 2868 | + firstMore = true | ||
| 2869 | + end | ||
| 2870 | + | ||
| 2871 | + local tmpreward = {} | ||
| 2872 | + for itemId, n in pairs(reward) do | ||
| 2873 | + local itemData = csvdb["itemCsv"][itemId] | ||
| 2874 | + if itemData and itemData.type == ItemType.Rune then | ||
| 2875 | + count = count + n | ||
| 2876 | + if count > limit then | ||
| 2877 | + if not firstMore then | ||
| 2878 | + firstMore = true | ||
| 2879 | + reward[itemId] = n - (count - limit) | ||
| 2880 | + tmpreward[itemId] = count - limit | ||
| 2881 | + else | ||
| 2882 | + reward[itemId] = nil | ||
| 2883 | + tmpreward[itemId] = n | ||
| 2884 | + end | ||
| 2885 | + end | ||
| 2886 | + end | ||
| 2887 | + end | ||
| 2888 | + if next(tmpreward) then | ||
| 2889 | + self:sendMail(20, nil, tmpreward) | ||
| 2890 | + end | ||
| 2891 | + end | ||
| 2826 | end | 2892 | end |
| 2827 | 2893 | ||
| 2828 | return RolePlugin | 2894 | return RolePlugin |
| 2829 | \ No newline at end of file | 2895 | \ No newline at end of file |