diff --git a/src/Classes/CompareTab.lua b/src/Classes/CompareTab.lua index 0e2869f0fb..24506313c6 100644 --- a/src/Classes/CompareTab.lua +++ b/src/Classes/CompareTab.lua @@ -2477,6 +2477,10 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories if self:ShouldShowRing3(compareEntry) then t_insert(baseSlots, 10, "Ring 3") end + + -- we only use jewel slots if both sides have them available + self:AddAbyssSockets(compareEntry, baseSlots, true) + for _, slotName in ipairs(baseSlots) do local cSlot = compareEntry.itemsTab and compareEntry.itemsTab.slots[slotName] local cItem = cSlot and compareEntry.itemsTab.items[cSlot.selItemId] @@ -2641,6 +2645,10 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories if self:ShouldShowRing3(compareEntry) then t_insert(baseSlots, 10, "Ring 3") end + + -- we only use jewel slots if both sides have them available + self:AddAbyssSockets(compareEntry, baseSlots, true) + for _, slotName in ipairs(baseSlots) do local cSlot = compareEntry.itemsTab and compareEntry.itemsTab.slots[slotName] local cItem = cSlot and compareEntry.itemsTab.items[cSlot.selItemId] @@ -2649,19 +2657,65 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories if cItem and cItem.raw and not (pItem and pItem.name == cItem.name) then local newItem = new("Item", cItem.raw) newItem:NormaliseQuality() + + -- if our comparison has abyssal jewels, but the primary build + -- doesn't, add those temporarily to the build to work around + -- calcfunc not being able to take in multiple items + local cmpJewels = {} + local oldEquipped = {} + if newItem.abyssalSocketCount > 0 then + for idx = 1, newItem.abyssalSocketCount do + local abyssSlotName = string.format("%s Abyssal Socket %d", slotName, idx) + local cmpJewelSlot = compareEntry.itemsTab.slots[abyssSlotName] + -- save old id and unequip existing + local primaryJewelSlot = self.primaryBuild.itemsTab.slots[abyssSlotName] + oldEquipped[abyssSlotName] = primaryJewelSlot.selItemId + primaryJewelSlot:SetSelItemId(0) + if cmpJewelSlot.selItemId > 0 then + local cmpJewel = compareEntry.itemsTab.items[cmpJewelSlot.selItemId] + -- due to a previous bug where jewel slots didn't + -- get cleared when becoming inactive, so the item + -- might not exist + if cmpJewel then + -- copy item + local itemCopy = new("Item", cmpJewel:BuildRaw()) + table.insert(cmpJewels, itemCopy) + self.primaryBuild.itemsTab:AddItem(itemCopy, false) + + -- equip copied + self.primaryBuild.itemsTab.slots[abyssSlotName]:SetSelItemId(itemCopy.id) + end + end + end + end + + local output = calcFunc({ repSlotName = slotName, repItem = newItem }, useFullDPS) local impact = self.primaryBuild.calcsTab:CalculatePowerStat(powerStat, output, calcBase) local impactStr, impactVal, combinedImpactStr, impactPercent, impactIsZero = formatImpact(impact) + -- restore abyss jewel state + if newItem.abyssalSocketCount > 0 then + for k, v in pairs(oldEquipped) do + self.primaryBuild.itemsTab.slots[k]:SetSelItemId(v) + end + for _, item in ipairs(cmpJewels) do + self.primaryBuild.itemsTab:DeleteItem(item) + end + end + if not impactIsZero then -- Get rarity color for item name local rarityColor = colorCodes[cItem.rarity] or colorCodes.NORMAL + + local abyssJewelText = #cmpJewels > 0 and + s_format(", %d Jewel%s", #cmpJewels, #cmpJewels > 1 and "s" or "") or "" t_insert(results, { category = "Item", categoryColor = rarityColor, nameColor = rarityColor, - name = (cItem.name or "Unknown") .. ", " .. slotName, + name = (cItem.name or "Unknown") .. ", " .. slotName .. abyssJewelText, itemObj = newItem, slotName = slotName, impact = impactVal, @@ -3545,11 +3599,34 @@ function CompareTabClass:ShouldShowRing3(compareEntry) return primaryHas or compareHas end +--- @param comparison table +--- @param destTable string[] +--- @param requireBothSides boolean +function CompareTabClass:AddAbyssSockets(comparison, destTable, requireBothSides) + local equipmentSlots = { "Weapon 1", "Weapon 2", "Weapon 1 Swap", "Weapon 2 Swap", "Helmet", "Body Armour", "Gloves", + "Boots", "Belt" } + for _, slot in ipairs(equipmentSlots) do + for number = 1, 6 do + local abyssalSocketName = string.format("%s Abyssal Socket %d", slot, number) + local mainHas = self.primaryBuild.itemsTab.slots[abyssalSocketName].shown() + local comparisonHas = comparison.itemsTab.slots[abyssalSocketName].shown() + if (requireBothSides and mainHas and comparisonHas) + or ((not requireBothSides) and (mainHas or comparisonHas)) then + table.insert(destTable, abyssalSocketName) + end + end + end +end + function CompareTabClass:DrawItems(vp, compareEntry, inputEvents) - local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" } + local baseSlots = { "Weapon 1", "Weapon 2", "Weapon 1 Swap", "Weapon 2 Swap", "Helmet", "Body Armour", "Gloves", + "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" } if self:ShouldShowRing3(compareEntry) then t_insert(baseSlots, 10, "Ring 3") end + + self:AddAbyssSockets(compareEntry, baseSlots, false) + local primaryEnv = self.primaryBuild.calcsTab and self.primaryBuild.calcsTab.mainEnv local primaryHasRing3 = primaryEnv and primaryEnv.modDB:Flag(nil, "AdditionalRingSlot") local lineHeight = 20 diff --git a/src/Classes/ItemSlotControl.lua b/src/Classes/ItemSlotControl.lua index c6cceeaeb4..d7b549f3a2 100644 --- a/src/Classes/ItemSlotControl.lua +++ b/src/Classes/ItemSlotControl.lua @@ -102,6 +102,11 @@ function ItemSlotClass:Populate() end for i, abyssalSocket in ipairs(self.abyssalSocketList) do abyssalSocket.inactive = i > abyssalSocketCount + if abyssalSocket.inactive then + -- this can be inconvenient, but otherwise it is possible to double + -- equip jewels by moving the jewel while the socket is inactive + abyssalSocket:SetSelItemId(0) + end end end