Skip to content

Commit 457fb26

Browse files
committed
add support for Imbued gems in compared Skills tab
1 parent 7eab5fc commit 457fb26

1 file changed

Lines changed: 80 additions & 31 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 80 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,18 +3639,52 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
36393639
drawY = drawY + 24
36403640

36413641
-- Get socket groups from both builds
3642-
local pGroups = self.primaryBuild.skillsTab and self.primaryBuild.skillsTab.socketGroupList or {}
3643-
local cGroups = compareEntry.skillsTab and compareEntry.skillsTab.socketGroupList or {}
3642+
local pSkillsTab = self.primaryBuild.skillsTab
3643+
local cSkillsTab = compareEntry.skillsTab
3644+
local pGroups = pSkillsTab and pSkillsTab.socketGroupList or {}
3645+
local cGroups = cSkillsTab and cSkillsTab.socketGroupList or {}
3646+
3647+
-- Imbued supports live on socketGroup.imbuedSupport (a name string) rather than in gemList,
3648+
-- so synthesize a minimal gem-like entry that the rendering can treat like any other gem
3649+
local imbuedGemCache = {}
3650+
local function getImbuedGem(group, skillsTab)
3651+
if not group or not group.imbuedSupport then return nil end
3652+
if imbuedGemCache[group] then return imbuedGemCache[group] end
3653+
-- Prefer the grantedEffect cached on skillsTab; fall back to a direct data lookup
3654+
-- (mirrors SkillsTab:RebuildImbuedSupportBySlot) in case the tab hasn't been primed.
3655+
local grantedEffect = skillsTab and skillsTab.imbuedSupportBySlot and group.slot and skillsTab.imbuedSupportBySlot[group.slot]
3656+
if not grantedEffect then
3657+
local gemId = data.gemForBaseName and data.gemForBaseName[group.imbuedSupport:lower() .. " support"]
3658+
grantedEffect = gemId and data.gems[gemId] and data.gems[gemId].grantedEffect or nil
3659+
end
3660+
local entry = {
3661+
grantedEffect = grantedEffect,
3662+
nameSpec = group.imbuedSupport,
3663+
level = 1,
3664+
quality = 0,
3665+
color = grantedEffect and data.skillColorMap[grantedEffect.color] or nil,
3666+
isImbuedSupport = true,
3667+
}
3668+
imbuedGemCache[group] = entry
3669+
return entry
3670+
end
36443671

36453672
-- Helper: get the set of gem names in a socket group
3646-
local function getGemNameSet(group)
3673+
local function getGemNameSet(group, skillsTab)
36473674
local set = {}
36483675
for _, gem in ipairs(group.gemList or {}) do
36493676
local name = gem.grantedEffect and gem.grantedEffect.name or gem.nameSpec
36503677
if name then
36513678
set[name] = true
36523679
end
36533680
end
3681+
local imbuedGem = getImbuedGem(group, skillsTab)
3682+
if imbuedGem then
3683+
local name = imbuedGem.grantedEffect and imbuedGem.grantedEffect.name or imbuedGem.nameSpec
3684+
if name then
3685+
set[name] = true
3686+
end
3687+
end
36543688
return set
36553689
end
36563690

@@ -3674,11 +3708,11 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
36743708
-- Build gem name sets for all groups
36753709
local pSets = {}
36763710
for i, group in ipairs(pGroups) do
3677-
pSets[i] = getGemNameSet(group)
3711+
pSets[i] = getGemNameSet(group, pSkillsTab)
36783712
end
36793713
local cSets = {}
36803714
for i, group in ipairs(cGroups) do
3681-
cSets[i] = getGemNameSet(group)
3715+
cSets[i] = getGemNameSet(group, cSkillsTab)
36823716
end
36833717

36843718
-- Compute all pairwise similarity scores
@@ -3722,6 +3756,12 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
37223756

37233757
-- Helper: check if gemA supports gemB (mirrors GemSelectControl:CheckSupporting)
37243758
local function checkSupporting(gemA, gemB)
3759+
-- Synthesized imbued-support entries lack gemData/supportEffect wiring, but by definition
3760+
-- they support any active (non-support) gem in the group.
3761+
if gemA.isImbuedSupport then
3762+
local bEffect = gemB.grantedEffect or (gemB.gemData and gemB.gemData.grantedEffect)
3763+
return bEffect and not bEffect.support or false
3764+
end
37253765
if not gemA.gemData or not gemB.gemData then return false end
37263766
return (gemA.gemData.grantedEffect and gemA.gemData.grantedEffect.support
37273767
and gemB.gemData.grantedEffect and not gemB.gemData.grantedEffect.support
@@ -3744,49 +3784,58 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
37443784
return gem.grantedEffect and gem.grantedEffect.name or gem.nameSpec
37453785
end
37463786

3787+
-- Helper: build an iterable gem list for a group that appends its imbued support (if any)
3788+
local function getGemsWithImbued(group, skillsTab)
3789+
if not group then return {} end
3790+
local gems = {}
3791+
for _, gem in ipairs(group.gemList or {}) do
3792+
t_insert(gems, gem)
3793+
end
3794+
local imbuedGem = getImbuedGem(group, skillsTab)
3795+
if imbuedGem then
3796+
t_insert(gems, imbuedGem)
3797+
end
3798+
return gems
3799+
end
3800+
37473801
local function buildAlignedGemLists(pGroup, cGroup, pSet, cSet)
37483802
local pDisplay = {}
37493803
local cDisplay = {}
37503804

3805+
local pGems = getGemsWithImbued(pGroup, pSkillsTab)
3806+
local cGems = getGemsWithImbued(cGroup, cSkillsTab)
3807+
37513808
-- Build name->gem lookup for compare side (common gems only)
37523809
local cGemByName = {}
3753-
if cGroup then
3754-
for _, gem in ipairs(cGroup.gemList or {}) do
3755-
local name = getGemName(gem)
3756-
if name and pSet[name] and not cGemByName[name] then
3757-
cGemByName[name] = gem
3758-
end
3810+
for _, gem in ipairs(cGems) do
3811+
local name = getGemName(gem)
3812+
if name and pSet[name] and not cGemByName[name] then
3813+
cGemByName[name] = gem
37593814
end
37603815
end
37613816

37623817
-- Common gems in primary build's order
37633818
local emittedCommon = {}
3764-
if pGroup then
3765-
for _, gem in ipairs(pGroup.gemList or {}) do
3766-
local name = getGemName(gem)
3767-
if name and cSet[name] and not emittedCommon[name] then
3768-
emittedCommon[name] = true
3769-
t_insert(pDisplay, { gem = gem, name = name, status = "common" })
3770-
t_insert(cDisplay, { gem = cGemByName[name], name = name, status = "common" })
3771-
end
3819+
for _, gem in ipairs(pGems) do
3820+
local name = getGemName(gem)
3821+
if name and cSet[name] and not emittedCommon[name] then
3822+
emittedCommon[name] = true
3823+
t_insert(pDisplay, { gem = gem, name = name, status = "common" })
3824+
t_insert(cDisplay, { gem = cGemByName[name], name = name, status = "common" })
37723825
end
37733826
end
37743827

37753828
-- Additional gems (unique to each side), preserving original order
3776-
if pGroup then
3777-
for _, gem in ipairs(pGroup.gemList or {}) do
3778-
local name = getGemName(gem)
3779-
if name and not cSet[name] then
3780-
t_insert(pDisplay, { gem = gem, name = name, status = "additional" })
3781-
end
3829+
for _, gem in ipairs(pGems) do
3830+
local name = getGemName(gem)
3831+
if name and not cSet[name] then
3832+
t_insert(pDisplay, { gem = gem, name = name, status = "additional" })
37823833
end
37833834
end
3784-
if cGroup then
3785-
for _, gem in ipairs(cGroup.gemList or {}) do
3786-
local name = getGemName(gem)
3787-
if name and not pSet[name] then
3788-
t_insert(cDisplay, { gem = gem, name = name, status = "additional" })
3789-
end
3835+
for _, gem in ipairs(cGems) do
3836+
local name = getGemName(gem)
3837+
if name and not pSet[name] then
3838+
t_insert(cDisplay, { gem = gem, name = name, status = "additional" })
37903839
end
37913840
end
37923841

0 commit comments

Comments
 (0)