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
90 changes: 90 additions & 0 deletions spec/System/TestImport_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,94 @@ Implicits: 0]])
end)
end

local function characterWithImbuedSupport(name)
local character = copyTable(sampleData, true)
for _, item in ipairs(character.equipment) do
if item.inventoryId == "BodyArmour" then
local gem = item.socketedItems[1]
gem.builtInSupport = "Supported by Level 1 " .. name
return character, gem
end
end
error("Sample character has no body armour")
end

local function bodyArmourGroup()
for index, group in ipairs(build.skillsTab.socketGroupList) do
if group.slot == "Body Armour" then
return group, index
end
end
error("Imported character has no body armour skill group")
end

for _, example in ipairs({
{ "Added Fire Damage", "Added Fire Damage", true },
{ "Added Fire Damage Support", "Added Fire Damage", true },
{ "Barrage Support", "Barrage Support", true },
{ "[SupportVolatility|Volatility]", "Volatility", true },
{ "Unknown Example", "Unknown Example", false },
}) do
it("imports and reloads an imbued support: " .. example[1], function()
local character = characterWithImbuedSupport(example[1])
build.importTab:ImportItemsAndSkills(character, true, true)
local function checkGroup()
local group = bodyArmourGroup()
assert.equals(example[2], group.imbuedSupport)
build.skillsTab:SetDisplayGroup(group)
assert.equals(example[3], build.skillsTab.imbuedSupportBySlot[group.slot] ~= nil)
end
checkGroup()
loadBuildFromXML(build:SaveDB("code"))
checkGroup()
end)
end

it("repairs saved imbued support markup and applies the support", function()
local character = characterWithImbuedSupport("[SupportVolatility|Volatility]")
build.importTab:ImportItemsAndSkills(character, true, true)
local xml = build:SaveDB("code")
xml = xml:gsub('imbuedSupport="[^"]+"', 'imbuedSupport="[SupportVolatility|Volatility]"', 1)
loadBuildFromXML(xml)
local group, groupIndex = bodyArmourGroup()
assert.equals("Volatility", group.imbuedSupport)
build.mainSocketGroup = groupIndex
build.buildFlag = true
runCallback("OnFrame")
local found
for _, support in ipairs(build.calcsTab.mainEnv.player.mainSkill.supportList) do
if support.grantedEffect.id == "SupportVolatility" then
found = support
break
end
end
assert.is_not_nil(found)
assert.equals(1, found.level)
end)

it("updates imbued support when reimporting an existing skill group", function()
local character, socketedGem = characterWithImbuedSupport("Added Fire Damage")
build.importTab:ImportItemsAndSkills(character, true, true)
local group = bodyArmourGroup()
build.skillsTab:SetDisplayGroup(group)
socketedGem.builtInSupport = "Supported by Level 1 [UnknownSupport|Unknown Example]"
build.importTab:ImportItemsAndSkills(character, false, false)
assert.equals("Unknown Example", group.imbuedSupport)
assert.equals("Unknown Example", build.skillsTab.controls.imbuedSupport.buf)
assert.is_nil(build.skillsTab.imbuedSupportBySlot[group.slot])
build.skillsTab:SetDisplayGroup(nil)
socketedGem.builtInSupport = "Supported by Level 1 [SupportVolatility|Volatility]"
build.importTab:ImportItemsAndSkills(character, false, false)
assert.equals("Volatility", group.imbuedSupport)
assert.equals("SupportVolatility", build.skillsTab.imbuedSupportBySlot[group.slot].id)
build.skillsTab:SetDisplayGroup(group)
assert.equals("Volatility", build.skillsTab.controls.imbuedSupport.buf)

group.slot, group.imbuedSupport = nil, nil
build.skillsTab:SetDisplayGroup(nil)
build.importTab:ImportItemsAndSkills(character, false, false)
assert.is_nil(group.slot)
assert.is_nil(group.imbuedSupport)
end)

end)
9 changes: 4 additions & 5 deletions src/Classes/CompareTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4061,12 +4061,11 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
local function getImbuedGem(group, skillsTab)
if not group or not group.imbuedSupport then return nil end
if imbuedGemCache[group] then return imbuedGemCache[group] end
-- Prefer the grantedEffect cached on skillsTab; fall back to a direct data lookup
-- (mirrors SkillsTab:RebuildImbuedSupportBySlot) in case the tab hasn't been primed.
-- Prefer the grantedEffect cached on skillsTab; resolve the name if the tab hasn't been primed.
local grantedEffect = skillsTab and skillsTab.imbuedSupportBySlot and group.slot and skillsTab.imbuedSupportBySlot[group.slot]
if not grantedEffect then
local gemId = data.gemForBaseName and data.gemForBaseName[group.imbuedSupport:lower() .. " support"]
grantedEffect = gemId and data.gems[gemId] and data.gems[gemId].grantedEffect or nil
if not grantedEffect and skillsTab then
local gem = skillsTab:FindImbuedSupport(group.imbuedSupport)
grantedEffect = gem and gem.grantedEffect
end
local entry = {
grantedEffect = grantedEffect,
Expand Down
10 changes: 8 additions & 2 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1857,8 +1857,9 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
local socketGroup = itemSocketGroupList[groupID]
t_insert(socketGroup.gemList, gemInstance)
if socketedItem.builtInSupport then
socketGroup.imbuedSupport = socketedItem.builtInSupport:gsub("Supported by Level 1 ", "")
self.build.skillsTab.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, true, slotName)
local name = escapeGGGString(socketedItem.builtInSupport):gsub("Supported by Level 1 ", "")
local gem = self.build.skillsTab:FindImbuedSupport(name)
socketGroup.imbuedSupport = gem and gem.name or name
end
end
end
Expand All @@ -1885,6 +1886,7 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
end
if repGroup then
-- Update the existing one
repGroup.imbuedSupport = repGroup.slot and itemSocketGroup.imbuedSupport or nil
for gemIndex, gem in pairs(repGroup.gemList) do
local itemGem = itemSocketGroup.gemList[gemIndex]
gem.level = itemGem.level
Expand All @@ -1894,7 +1896,11 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName)
t_insert(self.build.skillsTab.socketGroupList, itemSocketGroup)
end
self.build.skillsTab:ProcessSocketGroup(itemSocketGroup)
if repGroup and repGroup == self.build.skillsTab.displayGroup then
self.build.skillsTab:SetDisplayGroup(repGroup)
end
end
self.build.skillsTab:RebuildImbuedSupportBySlot()
end

-- Return the index of the group with the most gems
Expand Down
25 changes: 17 additions & 8 deletions src/Classes/SkillsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ function SkillsTabClass:LoadSkill(node, skillSetId)
socketGroup.mainActiveSkillCalcs = tonumber(node.attrib.mainActiveSkillCalcs) or 1
socketGroup.gemList = { }
if node.attrib.imbuedSupport and node.attrib.slot then
socketGroup.imbuedSupport = node.attrib.imbuedSupport
self.controls.imbuedSupport.gemChangeFunc(data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]], nil, nil, socketGroup.slot)
local name = escapeGGGString(node.attrib.imbuedSupport)
local gem = self:FindImbuedSupport(name)
socketGroup.imbuedSupport = gem and gem.name or name
end

for _, child in ipairs(node) do
Expand Down Expand Up @@ -1099,6 +1100,15 @@ function SkillsTabClass:UpdateGemSlots()
end
end

-- Resolve both saved gem names and import names, which may include "Support".
function SkillsTabClass:FindImbuedSupport(name)
local gemData = self.build.data
local lowerName = name:lower()
local gemId = gemData.gemForBaseName[lowerName .. " support"] or gemData.gemForBaseName[lowerName]
local gem = gemId and gemData.gems[gemId]
return gem and gem.grantedEffect and gem.grantedEffect.support and gem or nil
end

-- Find the skill gem matching the given specification
function SkillsTabClass:FindSkillGem(nameSpec)
-- Search for gem name using increasingly broad search patterns
Expand Down Expand Up @@ -1284,10 +1294,10 @@ function SkillsTabClass:SetDisplayGroup(socketGroup)
self.controls.includeInFullDPS.state = socketGroup.includeInFullDPS and socketGroup.enabled
self.controls.groupCount:SetText(socketGroup.groupCount or 1)
if socketGroup.imbuedSupport then
local gemId = data.gems[data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]]
self.controls.imbuedSupport.gemId = gemId
local gem = self:FindImbuedSupport(socketGroup.imbuedSupport)
self.controls.imbuedSupport.gemId = gem
self.controls.imbuedSupport:SetText(socketGroup.imbuedSupport)
self.controls.imbuedSupport.inactiveCol = data.skillColorMap[gemId.grantedEffect.color]
self.controls.imbuedSupport.inactiveCol = gem and data.skillColorMap[gem.grantedEffect.color] or "^8"
else
self.controls.imbuedSupport.gemId = nil
self.controls.imbuedSupport:SetText("")
Expand Down Expand Up @@ -1469,9 +1479,8 @@ function SkillsTabClass:RebuildImbuedSupportBySlot()
wipeTable(self.imbuedSupportBySlot)
for _, socketGroup in ipairs(self.socketGroupList) do
if socketGroup.slot and socketGroup.imbuedSupport then
local gemId = data.gemForBaseName[socketGroup.imbuedSupport:lower().." support"]
local gem = gemId and data.gems[gemId]
if gem and gem.grantedEffect then
local gem = self:FindImbuedSupport(socketGroup.imbuedSupport)
if gem then
self.imbuedSupportBySlot[socketGroup.slot] = gem.grantedEffect
end
end
Expand Down
Loading