Skip to content

Commit 58cdc97

Browse files
mcagnionclaude
andcommitted
feat(gem-reports): adapt to upstream imbued API and alt-quality removal
Phase 2/3 of port. Removes all qualityId / alternateGemQualityPrefixMap references (upstream PathOfBuildingCommunity#9758 removed alt quality). Adapts imbued upgrade simulation to upstream PathOfBuildingCommunity#9670 API: socketGroup.imbuedSupport + skillsTab.imbuedSupportBySlot[slotName] instead of gemInstance.imbuedSupport. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1102863 commit 58cdc97

6 files changed

Lines changed: 91 additions & 71 deletions

File tree

src/Classes/CompareTab.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,6 @@ function CompareTabClass:ComparePowerBuilder(compareEntry, powerStat, categories
26852685
nameSpec = cGem.nameSpec,
26862686
level = cGem.level,
26872687
quality = cGem.quality,
2688-
qualityId = cGem.qualityId,
26892688
enabled = cGem.enabled,
26902689
grantedEffect = cGem.grantedEffect,
26912690
gemData = cGem.gemData,

src/Classes/SkillsTab.lua

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ local function buildGemFilterList(skillsTab)
117117
return list
118118
end
119119

120+
-- Resolve a reportRow's targetImbuedSupport (stored as a grantedEffectId) into the pair
121+
-- { name, grantedEffect } that the upstream imbued API expects.
122+
local function resolveImbuedSupportInfo(dataGems, grantedEffectId)
123+
if not grantedEffectId then
124+
return nil
125+
end
126+
local grantedEffect = data.skills[grantedEffectId]
127+
local gemId = grantedEffect and data.gemForSkill[grantedEffect]
128+
local gemData = gemId and dataGems[gemId]
129+
if not (gemData and gemData.grantedEffect) then
130+
return nil
131+
end
132+
return { name = gemData.name, grantedEffect = gemData.grantedEffect }
133+
end
134+
120135
local SkillsTabClass = newClass("SkillsTab", "UndoHandler", "ControlHost", "Control", function(self, build)
121136
self.UndoHandler()
122137
self.ControlHost()
@@ -660,7 +675,6 @@ local function getGemTradePriceKey(reportRow, league)
660675
return table.concat({
661676
league or reportRow.tradeLeague or "",
662677
reportRow.tradeGemNameSpec or reportRow.name or "",
663-
reportRow.tradeQualityId or "Default",
664678
tostring(reportRow.targetLevel or ""),
665679
tostring(reportRow.targetQuality or ""),
666680
tostring(reportRow.targetImbuedSupport or ""),
@@ -1168,9 +1182,6 @@ function SkillsTabClass:BuildGemTradePriceQuery(reportRow, queryContext)
11681182
if not reportRow.tradeGemNameSpec or reportRow.tradeGemNameSpec == "" then
11691183
return nil, "Missing gem name."
11701184
end
1171-
if reportRow.tradeQualityId and reportRow.tradeQualityId ~= "Default" then
1172-
return nil, "Alt quality pricing is not supported yet."
1173-
end
11741185

11751186
local queryTable = {
11761187
query = {
@@ -1831,7 +1842,6 @@ function SkillsTabClass:AddGemQualitySummaryToTooltip(tooltip, gemInstance, qual
18311842
return 0
18321843
end
18331844
local gemData = gemInstance.gemData
1834-
local qualityType = gemInstance.qualityId or "Default"
18351845
local qualityValue = m_max(0, qualityAmount or gemInstance.quality or 0)
18361846
if qualityValue <= 0 then
18371847
return 0
@@ -1841,7 +1851,7 @@ function SkillsTabClass:AddGemQualitySummaryToTooltip(tooltip, gemInstance, qual
18411851
local function addQualityLines(qualityList, grantedEffect)
18421852
tooltip:AddLine(18, colorCodes.GEM .. grantedEffect.name)
18431853
tooltip:AddLine(16, colorCodes.NORMAL .. "At +" .. tostring(qualityValue) .. "% Quality:")
1844-
for _, qual in pairs(qualityList) do
1854+
for _, qual in ipairs(qualityList) do
18451855
local stats = { }
18461856
stats[qual[1]] = qual[2] * qualityValue
18471857
local descriptions = self.build.data.describeStats(stats, grantedEffect.statDescriptionScope)
@@ -1861,15 +1871,15 @@ function SkillsTabClass:AddGemQualitySummaryToTooltip(tooltip, gemInstance, qual
18611871
end
18621872

18631873
local addedSection = false
1864-
if gemData.grantedEffect and gemData.grantedEffect.qualityStats and gemData.grantedEffect.qualityStats[qualityType] then
1865-
addQualityLines(gemData.grantedEffect.qualityStats[qualityType], gemData.grantedEffect)
1874+
if gemData.grantedEffect and gemData.grantedEffect.qualityStats and gemData.grantedEffect.qualityStats[1] then
1875+
addQualityLines(gemData.grantedEffect.qualityStats, gemData.grantedEffect)
18661876
addedSection = true
18671877
end
1868-
if gemData.secondaryGrantedEffect and gemData.secondaryGrantedEffect.qualityStats and gemData.secondaryGrantedEffect.qualityStats[qualityType] then
1878+
if gemData.secondaryGrantedEffect and gemData.secondaryGrantedEffect.qualityStats and gemData.secondaryGrantedEffect.qualityStats[1] then
18691879
if addedSection then
18701880
tooltip:AddSeparator(10)
18711881
end
1872-
addQualityLines(gemData.secondaryGrantedEffect.qualityStats[qualityType], gemData.secondaryGrantedEffect)
1882+
addQualityLines(gemData.secondaryGrantedEffect.qualityStats, gemData.secondaryGrantedEffect)
18731883
end
18741884
return lineCount
18751885
end
@@ -1959,7 +1969,7 @@ function SkillsTabClass:AddGemUpgradeReportPreviewGemTooltip(tooltip, gemInstanc
19591969
return true
19601970
end
19611971

1962-
function SkillsTabClass:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemData, level, quality, qualityId, imbuedSupport)
1972+
function SkillsTabClass:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemData, level, quality)
19631973
if not gemData then
19641974
return false
19651975
end
@@ -1970,8 +1980,6 @@ function SkillsTabClass:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemDat
19701980
nameSpec = gemData.name,
19711981
level = level or gemData.naturalMaxLevel or 1,
19721982
quality = quality or 0,
1973-
qualityId = qualityId or "Default",
1974-
imbuedSupport = imbuedSupport,
19751983
enabled = true,
19761984
count = 1,
19771985
}
@@ -2028,8 +2036,7 @@ function SkillsTabClass:AddGemUpgradeReportCandidateGemTooltip(tooltip, reportRo
20282036
local previewGem = copyTable(gemInstance, true)
20292037
previewGem.level = reportRow.targetLevel or previewGem.level
20302038
previewGem.quality = reportRow.targetQuality or previewGem.quality
2031-
previewGem.qualityId = reportRow.tradeQualityId or previewGem.qualityId or "Default"
2032-
previewGem.imbuedSupport = reportRow.targetImbuedSupport or previewGem.imbuedSupport
2039+
-- Imbued preview is rendered by AddGemUpgradeReportSupportTooltip below; the gem tooltip itself stays static.
20332040
previewGem.displayEffect = nil
20342041
local startLineIndex = #tooltip.lines + 1
20352042
if not self:AddGemUpgradeReportPreviewGemTooltip(tooltip, previewGem) then
@@ -2050,7 +2057,7 @@ function SkillsTabClass:AddGemUpgradeReportSupportTooltip(tooltip, supportGrante
20502057
if not gemData then
20512058
return false
20522059
end
2053-
return self:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemData, 1, 0, "Default")
2060+
return self:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemData, 1, 0)
20542061
end
20552062

20562063
function SkillsTabClass:AddGemUpgradeReportMethodTooltip(tooltip, reportRow)
@@ -2110,16 +2117,27 @@ function SkillsTabClass:AddGemUpgradeReportDeltaTooltip(tooltip, reportRow)
21102117

21112118
local currentLevel = gemInstance.level
21122119
local currentQuality = gemInstance.quality
2113-
local currentImbuedSupport = gemInstance.imbuedSupport
2120+
local slotName = socketGroup.slot
2121+
local currentGroupImbuedSupport = socketGroup.imbuedSupport
2122+
local currentSlotImbuedGrantedEffect = slotName and self.imbuedSupportBySlot and self.imbuedSupportBySlot[slotName] or nil
21142123
gemInstance.level = reportRow.targetLevel or gemInstance.level
21152124
gemInstance.quality = reportRow.targetQuality or gemInstance.quality
2116-
gemInstance.imbuedSupport = reportRow.targetImbuedSupport or gemInstance.imbuedSupport
2125+
local imbuedInfo = resolveImbuedSupportInfo(self.build.data.gems, reportRow.targetImbuedSupport)
2126+
if imbuedInfo then
2127+
socketGroup.imbuedSupport = imbuedInfo.name
2128+
if slotName and self.imbuedSupportBySlot then
2129+
self.imbuedSupportBySlot[slotName] = imbuedInfo.grantedEffect
2130+
end
2131+
end
21172132

21182133
local errMsg, upgradedOutput = PCall(calcFunc, nil, reportRow.useFullDPS)
21192134

21202135
gemInstance.level = currentLevel
21212136
gemInstance.quality = currentQuality
2122-
gemInstance.imbuedSupport = currentImbuedSupport
2137+
socketGroup.imbuedSupport = currentGroupImbuedSupport
2138+
if slotName and self.imbuedSupportBySlot then
2139+
self.imbuedSupportBySlot[slotName] = currentSlotImbuedGrantedEffect
2140+
end
21232141
self:ProcessSocketGroup(socketGroup)
21242142

21252143
if errMsg then
@@ -2209,7 +2227,7 @@ end
22092227
function SkillsTabClass:AddSupportReplacementCandidateTooltip(tooltip, reportRow)
22102228
tooltip:Clear()
22112229
local gemData = reportRow and reportRow.candidateGemId and self.build.data.gems[reportRow.candidateGemId]
2212-
return self:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemData, reportRow.candidateLevel, reportRow.candidateQuality, reportRow.candidateQualityId)
2230+
return self:AddGemUpgradeReportPreviewGemDataTooltip(tooltip, gemData, reportRow.candidateLevel, reportRow.candidateQuality)
22132231
end
22142232

22152233
function SkillsTabClass:AddSupportReplacementDeltaTooltip(tooltip, reportRow)
@@ -2238,8 +2256,6 @@ function SkillsTabClass:AddSupportReplacementDeltaTooltip(tooltip, reportRow)
22382256
local currentGrantedEffect = gemInstance.grantedEffect
22392257
local currentLevel = gemInstance.level
22402258
local currentQuality = gemInstance.quality
2241-
local currentQualityId = gemInstance.qualityId
2242-
local currentImbuedSupport = gemInstance.imbuedSupport
22432259
local currentCorrupted = gemInstance.corrupted
22442260

22452261
gemInstance.gemId = candidateGemData.id
@@ -2249,8 +2265,6 @@ function SkillsTabClass:AddSupportReplacementDeltaTooltip(tooltip, reportRow)
22492265
gemInstance.grantedEffect = candidateGemData.grantedEffect
22502266
gemInstance.level = reportRow.candidateLevel
22512267
gemInstance.quality = reportRow.candidateQuality
2252-
gemInstance.qualityId = reportRow.candidateQualityId or "Default"
2253-
gemInstance.imbuedSupport = nil
22542268
gemInstance.corrupted = (reportRow.candidateLevel or 0) > (candidateGemData.naturalMaxLevel or 0) or (reportRow.candidateQuality or 0) > 20
22552269
self:ProcessSocketGroup(socketGroup)
22562270

@@ -2263,8 +2277,6 @@ function SkillsTabClass:AddSupportReplacementDeltaTooltip(tooltip, reportRow)
22632277
gemInstance.grantedEffect = currentGrantedEffect
22642278
gemInstance.level = currentLevel
22652279
gemInstance.quality = currentQuality
2266-
gemInstance.qualityId = currentQualityId
2267-
gemInstance.imbuedSupport = currentImbuedSupport
22682280
gemInstance.corrupted = currentCorrupted
22692281
self:ProcessSocketGroup(socketGroup)
22702282

@@ -2304,16 +2316,27 @@ function SkillsTabClass:AddGemUpgradeReportTooltip(tooltip, reportRow)
23042316

23052317
local currentLevel = gemInstance.level
23062318
local currentQuality = gemInstance.quality
2307-
local currentImbuedSupport = gemInstance.imbuedSupport
2319+
local slotName = socketGroup.slot
2320+
local currentGroupImbuedSupport = socketGroup.imbuedSupport
2321+
local currentSlotImbuedGrantedEffect = slotName and self.imbuedSupportBySlot and self.imbuedSupportBySlot[slotName] or nil
23082322
gemInstance.level = reportRow.targetLevel or gemInstance.level
23092323
gemInstance.quality = reportRow.targetQuality or gemInstance.quality
2310-
gemInstance.imbuedSupport = reportRow.targetImbuedSupport or gemInstance.imbuedSupport
2324+
local imbuedInfo = resolveImbuedSupportInfo(self.build.data.gems, reportRow.targetImbuedSupport)
2325+
if imbuedInfo then
2326+
socketGroup.imbuedSupport = imbuedInfo.name
2327+
if slotName and self.imbuedSupportBySlot then
2328+
self.imbuedSupportBySlot[slotName] = imbuedInfo.grantedEffect
2329+
end
2330+
end
23112331

23122332
local errMsg, upgradedOutput = PCall(calcFunc, nil, reportRow.useFullDPS)
23132333

23142334
gemInstance.level = currentLevel
23152335
gemInstance.quality = currentQuality
2316-
gemInstance.imbuedSupport = currentImbuedSupport
2336+
socketGroup.imbuedSupport = currentGroupImbuedSupport
2337+
if slotName and self.imbuedSupportBySlot then
2338+
self.imbuedSupportBySlot[slotName] = currentSlotImbuedGrantedEffect
2339+
end
23172340
self:ProcessSocketGroup(socketGroup)
23182341

23192342
if errMsg then

src/Modules/GemReportCommon.lua

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ local co_yield = coroutine.yield
1414

1515
local common = { }
1616

17-
common.alternateGemQualityPrefixMap = {
18-
Default = "",
19-
Alternate1 = "Anomalous ",
20-
Alternate2 = "Divergent ",
21-
Alternate3 = "Phantasmal ",
22-
}
23-
2417
function common.advanceBuildState(buildState)
2518
if not buildState then
2619
return
@@ -136,17 +129,17 @@ function common.isReportableImbuedSupportGem(gemData)
136129
return gemData.grantedEffect.levels and gemData.grantedEffect.levels[1] ~= nil
137130
end
138131

139-
function common.slotHasOtherImbuedGem(skillsTab, slotName, sourceGroup, sourceGemIndex)
132+
-- Upstream stores imbued support per-slot on the socket group (socketGroup.imbuedSupport = name),
133+
-- with SkillsTab:imbuedSupportBySlot[slotName] mirroring the grantedEffect. A slot is
134+
-- considered "already imbued" if any socket group targeting the slot has it set.
135+
function common.slotHasOtherImbuedGem(skillsTab, slotName, sourceGroup)
140136
if not slotName then
141137
return false
142138
end
143139
for _, socketGroup in ipairs(skillsTab.socketGroupList) do
144-
if socketGroup.slot == slotName then
145-
for gemIndex, gemInstance in ipairs(socketGroup.gemList) do
146-
if not (socketGroup == sourceGroup and gemIndex == sourceGemIndex) and gemInstance.imbuedSupport and gemInstance.imbuedSupport ~= "" then
147-
return true
148-
end
149-
end
140+
if socketGroup ~= sourceGroup and socketGroup.slot == slotName
141+
and socketGroup.imbuedSupport and socketGroup.imbuedSupport ~= "" then
142+
return true
150143
end
151144
end
152145
return false

src/Modules/GemTradeReport.lua

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ local formatDelta = common.formatDelta
2222
local isReportableImbuedSupportGem = common.isReportableImbuedSupportGem
2323
local slotHasOtherImbuedGem = common.slotHasOtherImbuedGem
2424
local getGemActiveSkills = common.getGemActiveSkills
25-
local alternateGemQualityPrefixMap = common.alternateGemQualityPrefixMap
2625

2726
local gemTradeReport = { }
2827

@@ -78,7 +77,7 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
7877
-- Pre-filter imbued support gems once instead of scanning data.gems per active gem.
7978
local reportableImbuedSupports = common.filterReportableImbuedSupports(build.data.gems)
8079

81-
local function addTradeRow(gemType, gemCategory, upgradeLabel, name, groupLabel, currentValue, nextValue, curSort, nextSort, output, socketGroup, gemIndex, targetLevel, targetQuality, tradeGemNameSpec, tradeQualityId, tradeNaturalMaxLevel, targetImbuedSupport)
80+
local function addTradeRow(gemType, gemCategory, upgradeLabel, name, groupLabel, currentValue, nextValue, curSort, nextSort, output, socketGroup, gemIndex, targetLevel, targetQuality, tradeGemNameSpec, tradeNaturalMaxLevel, targetImbuedSupport)
8281
local upgradedValue = getStatValue(output, currentStat, build)
8382
local delta = upgradedValue - baseValue
8483
local score = lowerIsBetter and -delta or delta
@@ -113,7 +112,6 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
113112
targetLevel = targetLevel,
114113
targetQuality = targetQuality,
115114
tradeGemNameSpec = tradeGemNameSpec,
116-
tradeQualityId = tradeQualityId,
117115
tradeNaturalMaxLevel = tradeNaturalMaxLevel,
118116
targetImbuedSupport = targetImbuedSupport,
119117
useFullDPS = useFullDPS,
@@ -132,11 +130,13 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
132130
if gemInstance.gemData and grantedEffect and gemInstance.enabled and groupEnabled then
133131
local gemType = grantedEffect.support and "Support" or (grantedEffect.hasGlobalEffect and "Global" or "Active")
134132
local gemCategory = grantedEffect.support and "SUPPORT" or "ACTIVE"
135-
local gemName = (alternateGemQualityPrefixMap[gemInstance.qualityId or "Default"] or "") .. gemInstance.nameSpec
133+
local gemName = gemInstance.nameSpec
136134
local groupLabel = socketGroup.displayLabel or socketGroup.label or ("Socket Group " .. groupIndex)
137135
local currentLevel = gemInstance.level or 0
138136
local currentQuality = m_max(0, gemInstance.quality or 0)
139-
local currentImbuedSupport = gemInstance.imbuedSupport
137+
local currentGroupImbuedSupport = socketGroup.imbuedSupport
138+
local slotName = socketGroup.slot
139+
local currentSlotImbuedGrantedEffect = slotName and skillsTab.imbuedSupportBySlot and skillsTab.imbuedSupportBySlot[slotName] or nil
140140
local naturalMaxLevel = gemInstance.gemData.naturalMaxLevel or 0
141141
local maxLevel = naturalMaxLevel
142142
-- Exceptional line gems do not get the generic +1 corrupted level step.
@@ -187,7 +187,6 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
187187
targetLevel,
188188
targetQuality,
189189
getTradeGemNameSpec(gemInstance.gemData, gemInstance.nameSpec),
190-
gemInstance.qualityId or "Default",
191190
naturalMaxLevel,
192191
nil
193192
)
@@ -197,9 +196,10 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
197196
end
198197

199198
if gemCategory == "ACTIVE"
200-
and socketGroup.slot
199+
and slotName
201200
and currentLevel <= 20
202-
and not slotHasOtherImbuedGem(skillsTab, socketGroup.slot, socketGroup, gemIndex) then
201+
and not (currentGroupImbuedSupport and currentGroupImbuedSupport ~= "")
202+
and not slotHasOtherImbuedGem(skillsTab, slotName, socketGroup) then
203203
local activeSkills = getGemActiveSkills(socketGroup, gemInstance)
204204
if #activeSkills > 0 then
205205
local imbuedQualities = { }
@@ -225,7 +225,10 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
225225
if imbuedCalcCount % 10 == 0 and co_running() then
226226
co_yield()
227227
end
228-
gemInstance.imbuedSupport = supportGemData.grantedEffectId
228+
socketGroup.imbuedSupport = supportGemData.name
229+
if slotName and skillsTab.imbuedSupportBySlot then
230+
skillsTab.imbuedSupportBySlot[slotName] = supportGrantedEffect
231+
end
229232
local errMsg, output = PCall(calcFunc, nil, useFullDPS)
230233
if not errMsg and isLevelUsable(skillsTab, gemInstance, grantedEffect, 20, output) then
231234
addTradeRow(
@@ -244,7 +247,6 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
244247
20,
245248
targetQuality,
246249
getTradeGemNameSpec(gemInstance.gemData, gemInstance.nameSpec),
247-
gemInstance.qualityId or "Default",
248250
naturalMaxLevel,
249251
supportGemData.grantedEffectId
250252
)
@@ -257,7 +259,10 @@ function gemTradeReport.Build(skillsTab, currentStat, filters, buildState)
257259

258260
gemInstance.level = currentLevel
259261
gemInstance.quality = currentQuality
260-
gemInstance.imbuedSupport = currentImbuedSupport
262+
socketGroup.imbuedSupport = currentGroupImbuedSupport
263+
if slotName and skillsTab.imbuedSupportBySlot then
264+
skillsTab.imbuedSupportBySlot[slotName] = currentSlotImbuedGrantedEffect
265+
end
261266
end
262267
end
263268
advanceBuildState(buildState)

0 commit comments

Comments
 (0)