diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index a612b66..7984b66 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -424,3 +424,14 @@ SystemBnousType = { ChangeBaseCount = 16, -- 每日奖励关卡挑战卡基础数量增加 ChangeBuyCount = 17, -- 每日奖励关卡挑战卡可购买次数增加, } + +-- 开箱物品类型 +ItemOccupy = { + EquipBase = 1, --装备 + Rune = 2, --铭文 + Diner = 3, --食材 + CommonPaster = 4, --贴纸 + Spark = 5, --火花 + Other = 6, + CanUsed = 7, --可使用 +} \ No newline at end of file diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 7f86098..35afa44 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -686,13 +686,17 @@ function _M.openTimeBoxRpc(agent, data) local count, runeCount = 0, 0 for itemId, num in pairs(costs) do local itemIdData = csvdb["itemCsv"][itemId] - if not itemIdData or not csvdb["item_randomCsv"][itemId] or costIdData.quality ~= itemIdData.quality then return 7 end + local itemRandomData = csvdb["item_randomCsv"][itemId] + if not itemIdData or not itemRandomData or costIdData.quality ~= itemIdData.quality then return 7 end - if itemIdData.type == ItemType.Rune then runeCount = runeCount + num end + local itemRandomOccupy = role:getItemRandomOccupy(itemRandomData) + if next(itemRandomOccupy) then + runeCount = runeCount + (itemRandomOccupy[ItemOccupy.Rune] or 0) * num + end count = count + num end - if role:checkRuneFully(runeCount) then return 10 end --开箱子,如果铭文仓库已经满了则不让开箱 + if role:checkRuneFully(runeCount) 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/models/RolePlugin.lua b/src/models/RolePlugin.lua index 7b969d2..44a1e85 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -2934,11 +2934,13 @@ function RolePlugin.bind(Role) self:mylog("hero_action", {desc = desc, int1 = heroType}) end - function Role:getRuneBatCount() + function Role:getRuneBagCount() local count = 0 for _, rune in pairs(self.runeBag) do if next(rune) then - count = count + 1 + if rune:getProperty("refer") == 0 then + count = count + 1 + end end end return count or 0 @@ -2947,13 +2949,28 @@ function RolePlugin.bind(Role) -- 铭文仓库是否满仓 function Role:checkRuneFully(count) count = count or 0 + if count == 0 then return false end + local page = globalCsv.store_type[ItemType.Rune] local limit = self:getProperty("bagLimit")[page] - return self:getRuneBatCount() + count > limit + return self:getRuneBagCount() + count > limit + end + + local function checkHasRuneByReward(reward) + reward = reward or {} + for itemId, _ in pairs(reward) do + local itemData = csvdb["itemCsv"][itemId] + if itemData and itemData.type == ItemType.Rune then + return true + end + end + return false end function Role:checkRuneFullyByReward(reward) - local count = self:getRuneBatCount() + if not checkHasRuneByReward(reward) then return false end + + local count = self:getRuneBagCount() local page = globalCsv.store_type[ItemType.Rune] local limit = self:getProperty("bagLimit")[page] if count >= limit then @@ -3001,6 +3018,16 @@ function RolePlugin.bind(Role) end end + function Role:getItemRandomOccupy(itemRandomData) + local itemRandomOccupy = {} + if itemRandomData then + for typ, n in pairs(itemRandomData.ware:toNumMap() or {}) do + itemRandomOccupy[typ] = n + end + end + return itemRandomOccupy + end + end -- libgit2 0.21.2