Skip to content

Commit c6483fa

Browse files
vaisestLocalIdentity
andauthored
Add abyss sockets to comparison tab (#9854)
* Add abyss sockets to comparison tab items subtab * Also add abyssal sockets to power report * Fix comparison abyss socket ordering * Unequip jewels from inactive abyss sockets * Account for abyss sockets in comparison power report * Add weapon swap to comparison items tab * Fix abyss sockets removing when running compare We were not using the item id to use when resetting causing jewels to not equip after running the compare to another build with an abyss jewel --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent f3fd019 commit c6483fa

2 files changed

Lines changed: 84 additions & 2 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,6 +2477,10 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
24772477
if self:ShouldShowRing3(compareEntry) then
24782478
t_insert(baseSlots, 10, "Ring 3")
24792479
end
2480+
2481+
-- we only use jewel slots if both sides have them available
2482+
self:AddAbyssSockets(compareEntry, baseSlots, true)
2483+
24802484
for _, slotName in ipairs(baseSlots) do
24812485
local cSlot = compareEntry.itemsTab and compareEntry.itemsTab.slots[slotName]
24822486
local cItem = cSlot and compareEntry.itemsTab.items[cSlot.selItemId]
@@ -2641,6 +2645,10 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26412645
if self:ShouldShowRing3(compareEntry) then
26422646
t_insert(baseSlots, 10, "Ring 3")
26432647
end
2648+
2649+
-- we only use jewel slots if both sides have them available
2650+
self:AddAbyssSockets(compareEntry, baseSlots, true)
2651+
26442652
for _, slotName in ipairs(baseSlots) do
26452653
local cSlot = compareEntry.itemsTab and compareEntry.itemsTab.slots[slotName]
26462654
local cItem = cSlot and compareEntry.itemsTab.items[cSlot.selItemId]
@@ -2649,19 +2657,65 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26492657
if cItem and cItem.raw and not (pItem and pItem.name == cItem.name) then
26502658
local newItem = new("Item", cItem.raw)
26512659
newItem:NormaliseQuality()
2660+
2661+
-- if our comparison has abyssal jewels, but the primary build
2662+
-- doesn't, add those temporarily to the build to work around
2663+
-- calcfunc not being able to take in multiple items
2664+
local cmpJewels = {}
2665+
local oldEquipped = {}
2666+
if newItem.abyssalSocketCount > 0 then
2667+
for idx = 1, newItem.abyssalSocketCount do
2668+
local abyssSlotName = string.format("%s Abyssal Socket %d", slotName, idx)
2669+
local cmpJewelSlot = compareEntry.itemsTab.slots[abyssSlotName]
2670+
-- save old id and unequip existing
2671+
local primaryJewelSlot = self.primaryBuild.itemsTab.slots[abyssSlotName]
2672+
oldEquipped[abyssSlotName] = primaryJewelSlot.selItemId
2673+
primaryJewelSlot:SetSelItemId(0)
2674+
if cmpJewelSlot.selItemId > 0 then
2675+
local cmpJewel = compareEntry.itemsTab.items[cmpJewelSlot.selItemId]
2676+
-- due to a previous bug where jewel slots didn't
2677+
-- get cleared when becoming inactive, so the item
2678+
-- might not exist
2679+
if cmpJewel then
2680+
-- copy item
2681+
local itemCopy = new("Item", cmpJewel:BuildRaw())
2682+
table.insert(cmpJewels, itemCopy)
2683+
self.primaryBuild.itemsTab:AddItem(itemCopy, false)
2684+
2685+
-- equip copied
2686+
self.primaryBuild.itemsTab.slots[abyssSlotName]:SetSelItemId(itemCopy.id)
2687+
end
2688+
end
2689+
end
2690+
end
2691+
2692+
26522693
local output = calcFunc({ repSlotName = slotName, repItem = newItem }, useFullDPS)
26532694
local impact = self.primaryBuild.calcsTab:CalculatePowerStat(powerStat, output, calcBase)
26542695
local impactStr, impactVal, combinedImpactStr, impactPercent, impactIsZero = formatImpact(impact)
26552696

2697+
-- restore abyss jewel state
2698+
if newItem.abyssalSocketCount > 0 then
2699+
for k, v in pairs(oldEquipped) do
2700+
self.primaryBuild.itemsTab.slots[k]:SetSelItemId(v)
2701+
end
2702+
for _, item in ipairs(cmpJewels) do
2703+
self.primaryBuild.itemsTab:DeleteItem(item)
2704+
end
2705+
end
2706+
26562707
if not impactIsZero then
26572708
-- Get rarity color for item name
26582709
local rarityColor = colorCodes[cItem.rarity] or colorCodes.NORMAL
26592710

2711+
2712+
local abyssJewelText = #cmpJewels > 0 and
2713+
s_format(", %d Jewel%s", #cmpJewels, #cmpJewels > 1 and "s" or "") or ""
26602714
t_insert(results, {
26612715
category = "Item",
26622716
categoryColor = rarityColor,
26632717
nameColor = rarityColor,
2664-
name = (cItem.name or "Unknown") .. ", " .. slotName,
2718+
name = (cItem.name or "Unknown") .. ", " .. slotName .. abyssJewelText,
26652719
itemObj = newItem,
26662720
slotName = slotName,
26672721
impact = impactVal,
@@ -3545,11 +3599,34 @@ function CompareTabClass:ShouldShowRing3(compareEntry)
35453599
return primaryHas or compareHas
35463600
end
35473601

3602+
--- @param comparison table
3603+
--- @param destTable string[]
3604+
--- @param requireBothSides boolean
3605+
function CompareTabClass:AddAbyssSockets(comparison, destTable, requireBothSides)
3606+
local equipmentSlots = { "Weapon 1", "Weapon 2", "Weapon 1 Swap", "Weapon 2 Swap", "Helmet", "Body Armour", "Gloves",
3607+
"Boots", "Belt" }
3608+
for _, slot in ipairs(equipmentSlots) do
3609+
for number = 1, 6 do
3610+
local abyssalSocketName = string.format("%s Abyssal Socket %d", slot, number)
3611+
local mainHas = self.primaryBuild.itemsTab.slots[abyssalSocketName].shown()
3612+
local comparisonHas = comparison.itemsTab.slots[abyssalSocketName].shown()
3613+
if (requireBothSides and mainHas and comparisonHas)
3614+
or ((not requireBothSides) and (mainHas or comparisonHas)) then
3615+
table.insert(destTable, abyssalSocketName)
3616+
end
3617+
end
3618+
end
3619+
end
3620+
35483621
function CompareTabClass:DrawItems(vp, compareEntry, inputEvents)
3549-
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" }
3622+
local baseSlots = { "Weapon 1", "Weapon 2", "Weapon 1 Swap", "Weapon 2 Swap", "Helmet", "Body Armour", "Gloves",
3623+
"Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
35503624
if self:ShouldShowRing3(compareEntry) then
35513625
t_insert(baseSlots, 10, "Ring 3")
35523626
end
3627+
3628+
self:AddAbyssSockets(compareEntry, baseSlots, false)
3629+
35533630
local primaryEnv = self.primaryBuild.calcsTab and self.primaryBuild.calcsTab.mainEnv
35543631
local primaryHasRing3 = primaryEnv and primaryEnv.modDB:Flag(nil, "AdditionalRingSlot")
35553632
local lineHeight = 20

src/Classes/ItemSlotControl.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ function ItemSlotClass:Populate()
102102
end
103103
for i, abyssalSocket in ipairs(self.abyssalSocketList) do
104104
abyssalSocket.inactive = i > abyssalSocketCount
105+
if abyssalSocket.inactive then
106+
-- this can be inconvenient, but otherwise it is possible to double
107+
-- equip jewels by moving the jewel while the socket is inactive
108+
abyssalSocket:SetSelItemId(0)
109+
end
105110
end
106111
end
107112

0 commit comments

Comments
 (0)