Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions spec/System/TestImportReimport_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 11 additions & 3 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading