Skip to content

Commit e1f8297

Browse files
LocalIdentityLocalIdentity
andauthored
Fix jewels socketed in gloves not importing correctly (#2296)
The Jewel is in the second socket of the item so the previous code would try to add the jewel to Gloves Jewel Socket 2 instead of socket 1 We now remove non jewel types from the index list incase GGG adds other jewel + rune combos in the future Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent 59b5e23 commit e1f8297

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

spec/System/TestImportReimport_spec.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,39 @@ Fireball 20/0 1
187187
assert.is_false(groupsByGem.Fireball.enabled)
188188
end)
189189

190+
it("imports item socketed jewels using jewel socket order instead of raw socket index", function()
191+
build.importTab.controls.charImportItemsClearItems.state = true
192+
build.importTab.controls.charImportItemsClearSkills.state = true
193+
194+
local gloves = makeImportItem("Linen Wraps", "Gloves", "test-import-gloves")
195+
gloves.sockets = {
196+
{ type = "rune" },
197+
{ type = "jewel" },
198+
}
199+
gloves.socketedItems = {
200+
{ baseType = "Greater Rune of Nobility" },
201+
{
202+
id = "test-import-jewel",
203+
frameType = 2,
204+
name = "Vivid Ornament",
205+
typeLine = "Sapphire",
206+
baseType = "Sapphire",
207+
inventoryId = "PassiveJewels",
208+
ilvl = DEFAULT_ITEM_LEVEL,
209+
properties = {},
210+
socket = 1,
211+
},
212+
}
213+
214+
build.importTab:ImportItemsAndSkills(buildImportPayload({ gloves }, {}))
215+
runCallback("OnFrame")
216+
217+
local socketedJewel = build.itemsTab.items[build.itemsTab.slots["Gloves Jewel Socket 1"].selItemId]
218+
assert.is_not_nil(socketedJewel)
219+
assert.are.equal("test-import-jewel", socketedJewel.uniqueID)
220+
assert.are.equal(0, build.itemsTab.slots["Gloves Jewel Socket 2"].selItemId)
221+
end)
222+
190223
it("preserves skill part selection when reimporting items and skills", function()
191224
assertReimportPreservesSkillSubstate("Twig Focus", "Offhand", "Dark Effigy", "skillPart", 2)
192225
end)

src/Classes/ImportTab.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
12871287

12881288
item.runes = { }
12891289
if itemData.socketedItems then
1290-
self:ImportSocketedItems(item, itemData.socketedItems, slotName)
1290+
self:ImportSocketedItems(item, itemData.socketedItems, slotName, itemData.sockets)
12911291
end
12921292
if itemData.requirements and (not itemData.socketedItems or not itemData.socketedItems[1]) then
12931293
-- Requirements cannot be trusted if there are socketed gems, as they may override the item's natural requirements
@@ -1438,11 +1438,19 @@ function ImportTabClass:ImportItem(itemData, slotName)
14381438
end
14391439
end
14401440

1441-
function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
1441+
function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName, sockets)
14421442
-- Build socket group list
14431443
for _, socketedItem in ipairs(socketedItems) do
14441444
if isValueInTable({ "Diamond", "Emerald", "Ruby", "Sapphire" }, socketedItem.baseType) then
1445-
self:ImportItem(socketedItem, slotName .. " Jewel Socket "..socketedItem.socket + 1)
1445+
local jewelSocketIndex = socketedItem.socket + 1
1446+
if sockets then
1447+
for index = 1, socketedItem.socket + 1 do
1448+
if sockets[index] and sockets[index].type ~= "jewel" then
1449+
jewelSocketIndex = jewelSocketIndex - 1
1450+
end
1451+
end
1452+
end
1453+
self:ImportItem(socketedItem, slotName .. " Jewel Socket "..jewelSocketIndex)
14461454
else
14471455
t_insert(item.runes, socketedItem.baseType)
14481456
end

0 commit comments

Comments
 (0)