diff --git a/spec/System/TestImportReimport_spec.lua b/spec/System/TestImportReimport_spec.lua index cdcf6392a9..766d653773 100644 --- a/spec/System/TestImportReimport_spec.lua +++ b/spec/System/TestImportReimport_spec.lua @@ -187,6 +187,39 @@ Fireball 20/0 1 assert.is_false(groupsByGem.Fireball.enabled) end) + it("imports item socketed jewels using jewel socket order instead of raw socket index", function() + build.importTab.controls.charImportItemsClearItems.state = true + build.importTab.controls.charImportItemsClearSkills.state = true + + local gloves = makeImportItem("Linen Wraps", "Gloves", "test-import-gloves") + gloves.sockets = { + { type = "rune" }, + { type = "jewel" }, + } + gloves.socketedItems = { + { baseType = "Greater Rune of Nobility" }, + { + id = "test-import-jewel", + frameType = 2, + name = "Vivid Ornament", + typeLine = "Sapphire", + baseType = "Sapphire", + inventoryId = "PassiveJewels", + ilvl = DEFAULT_ITEM_LEVEL, + properties = {}, + socket = 1, + }, + } + + build.importTab:ImportItemsAndSkills(buildImportPayload({ gloves }, {})) + runCallback("OnFrame") + + local socketedJewel = build.itemsTab.items[build.itemsTab.slots["Gloves Jewel Socket 1"].selItemId] + assert.is_not_nil(socketedJewel) + assert.are.equal("test-import-jewel", socketedJewel.uniqueID) + assert.are.equal(0, build.itemsTab.slots["Gloves Jewel Socket 2"].selItemId) + end) + it("preserves skill part selection when reimporting items and skills", function() assertReimportPreservesSkillSubstate("Twig Focus", "Offhand", "Dark Effigy", "skillPart", 2) end) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index 0dcb9c59d9..b81e73ab6e 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -1286,7 +1286,7 @@ function ImportTabClass:ImportItem(itemData, slotName) item.runes = { } if itemData.socketedItems then - self:ImportSocketedItems(item, itemData.socketedItems, slotName) + self:ImportSocketedItems(item, itemData.socketedItems, slotName, itemData.sockets) end if itemData.requirements and (not itemData.socketedItems or not itemData.socketedItems[1]) then -- Requirements cannot be trusted if there are socketed gems, as they may override the item's natural requirements @@ -1437,11 +1437,19 @@ function ImportTabClass:ImportItem(itemData, slotName) end end -function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName) +function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName, sockets) -- Build socket group list for _, socketedItem in ipairs(socketedItems) do if isValueInTable({ "Diamond", "Emerald", "Ruby", "Sapphire" }, socketedItem.baseType) then - self:ImportItem(socketedItem, slotName .. " Jewel Socket "..socketedItem.socket + 1) + local jewelSocketIndex = socketedItem.socket + 1 + if sockets then + for index = 1, socketedItem.socket + 1 do + if sockets[index] and sockets[index].type ~= "jewel" then + jewelSocketIndex = jewelSocketIndex - 1 + end + end + end + self:ImportItem(socketedItem, slotName .. " Jewel Socket "..jewelSocketIndex) else t_insert(item.runes, socketedItem.baseType) end