Skip to content

Commit 1d5ee4e

Browse files
Blitz54LocalIdentity
andauthored
Add support for corrupting gems for +/- 1 level (PathOfBuildingCommunity#1743)
* Show where levels came from * Add corruption dropdown to skills tab, import corrupted, and fix Sacrificial Regalia * Fix import missing corruptLevel * Some cleanup and tooltip fixes * Fix corrupted check * Fix pasting corrupted socket group * Fix paste for companion and spectre * Set corruption dropdown with default gem level dropdown * Support gem sorting * Fix Oisins Oath letter * Fix error on old builds * Fix tooltip levels * Fix C flag parsing * Add test for corruption parsing of socket group, along with count * Fix bugs Gems were counting as corrupted no matter what Switching between default gem level options no longer makes all gems count as corrupted Clamps levels to min of 1 when having level 1 gem and -1 corruption * Fix tree / item skills showing corruption box Clamp min gem level to 1 * Fix global levels including quality and copying fractional fulDPS values --------- Co-authored-by: LocalIdentity <localidentity2@gmail.com>
1 parent e81e54e commit 1d5ee4e

16 files changed

Lines changed: 313 additions & 121 deletions

spec/System/TestSkills_spec.lua

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe("TestSkills", function()
66
teardown(function()
77
-- newBuild() takes care of resetting everything in setup()
88
end)
9-
9+
1010

1111
it("uses granted effect minion list when active skill minion list is missing", function()
1212
local srcInstance = { statSet = { }, skillPart = { }, nameSpec = "Spectre: Test" }
@@ -113,7 +113,7 @@ describe("TestSkills", function()
113113
it("Test cost efficiency with cost modifiers", function()
114114
-- Test interaction between cost efficiency and cost multipliers
115115
build.skillsTab:PasteSocketGroup("Ball Lightning 1/0 1\n")
116-
116+
117117
-- Add cost multiplier and efficiency
118118
build.configTab.input.customMods = "50% increased Mana Cost\n50% increased Mana Cost Efficiency"
119119
build.configTab:BuildModList()
@@ -123,6 +123,28 @@ describe("TestSkills", function()
123123
assert.True(math.abs(finalCost - 8.67) < 0.1) -- floor(9 * 1.5) / 1.5
124124
end)
125125

126+
it("Test socket group pasting with corruption levels and count", function()
127+
build.skillsTab:PasteSocketGroup("Wave of Frost 20/0 3 C+1\n Culmination I 1/0 1")
128+
assert.are.equals(3, build.skillsTab.socketGroupList[1].gemList[1].count)
129+
130+
runCallback("OnFrame")
131+
132+
assert.are.equals(3, build.skillsTab.socketGroupList[1].gemList[1].count)
133+
assert.are.equals(true, build.skillsTab.socketGroupList[1].gemList[1].corrupted)
134+
assert.are.equals(1, build.skillsTab.socketGroupList[1].gemList[1].corruptLevel)
135+
136+
newBuild()
137+
-- Support gem first this time, with negative corruption value.
138+
build.skillsTab:PasteSocketGroup("Culmination I 1/0 1\nWave of Frost 20/20 2 C-1")
139+
assert.are.equals(2, build.skillsTab.socketGroupList[1].gemList[2].count)
140+
141+
runCallback("OnFrame")
142+
143+
assert.are.equals(2, build.skillsTab.socketGroupList[1].gemList[2].count)
144+
assert.are.equals(true, build.skillsTab.socketGroupList[1].gemList[2].corrupted)
145+
assert.are.equals(-1, build.skillsTab.socketGroupList[1].gemList[2].corruptLevel)
146+
end)
147+
126148
it("Fractional skill count scales Full DPS", function()
127149
build.skillsTab:PasteSocketGroup("Ball Lightning 20/0 1")
128150
build.skillsTab.socketGroupList[1].includeInFullDPS = true
@@ -145,7 +167,7 @@ describe("TestSkills", function()
145167
it("Test mana cost efficiency with support gems", function()
146168
-- Test interaction between cost efficiency and cost multipliers
147169
build.skillsTab:PasteSocketGroup("Contagion 6/0 1\nMagnified Area I 1/0 1")
148-
170+
149171
-- Add efficiency
150172
build.configTab.input.customMods = "36% increased Mana Cost Efficiency"
151173
build.configTab:BuildModList()
@@ -575,7 +597,7 @@ describe("TestSkills", function()
575597
-- if one works they all do, surely
576598
assert.True(build.calcsTab.mainOutput.TotalDPS > baseFireball)
577599
end)
578-
600+
579601
it("Test Minion Pact damage requires a minion in your presence", function()
580602
build.itemsTab:CreateDisplayItemFromRaw([[
581603
New Item

src/Classes/GemSelectControl.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS)
6363
enableGlobal2 = true,
6464
gemId = gemData.id,
6565
nameSpec = gemData.name,
66-
skillId = gemData.grantedEffectId
66+
skillId = gemData.grantedEffectId,
67+
corrupted = self.skillsTab.defaultCorruptionState,
68+
corruptLevel = self.skillsTab.defaultCorruptionLevel,
6769
}
6870
end
6971

@@ -82,16 +84,16 @@ function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, useFullDPS)
8284
else
8385
gemList[self.index] = nil
8486
end
85-
87+
8688
self.skillsTab.displayGroup.displayGemList = displayGemList
87-
89+
8890
return output, gemInstance
8991
end
9092

9193
function GemSelectClass:PopulateGemList()
9294
wipeTable(self.gems)
9395
local showAll = self.skillsTab.showSupportGemTypes == "ALL"
94-
local showAwakened = self.skillsTab.showSupportGemTypes == "AWAKENED"
96+
local showLineage = self.skillsTab.showSupportGemTypes == "LINEAGE"
9597
local showNormal = self.skillsTab.showSupportGemTypes == "NORMAL"
9698
local matchLevel = self.skillsTab.defaultGemLevel == "characterLevel"
9799
local characterLevel = self.skillsTab.build and self.skillsTab.build.characterLevel or 1
@@ -110,8 +112,8 @@ function GemSelectClass:FilterSupport(gemId, gemData)
110112
local showSupportTypes = self.skillsTab.showSupportGemTypes
111113
return (not gemData.grantedEffect.support
112114
or showSupportTypes == "ALL"
113-
or (showSupportTypes == "NORMAL" and not gemData.grantedEffect.plusVersionOf)
114-
or (showSupportTypes == "AWAKENED" and gemData.grantedEffect.plusVersionOf))
115+
or (showSupportTypes == "NORMAL" and not gemData.grantedEffect.isLineage)
116+
or (showSupportTypes == "LINEAGE" and gemData.grantedEffect.isLineage))
115117
end
116118

117119
function GemSelectClass:BuildList(buf)
@@ -465,7 +467,9 @@ function GemSelectClass:Draw(viewPort, noTooltip)
465467
nameSpec = gemData.name,
466468
skillId = gemData.grantedEffectId,
467469
displayEffect = nil,
468-
gemData = gemData
470+
gemData = gemData,
471+
corruptLevel = self.skillsTab.defaultCorruptionLevel,
472+
corrupted = self.skillsTab.defaultCorruptionState == true,
469473
}
470474
self:AddGemTooltip(gemInstance)
471475
self.tooltip:AddSeparator(10)
@@ -569,7 +573,7 @@ function GemSelectClass:OnFocusLost()
569573
if self.noMatches then
570574
self:SetText("")
571575
end
572-
self:UpdateGem(true,true, true)
576+
self:UpdateGem(true, true, true)
573577
end
574578
end
575579

src/Classes/GemTooltip.lua

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,39 @@ local function addGrantedEffectInfo(tooltip, build, gemInstance, grantedEffect,
6767
tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FTier: ^7%d", gemInstance.gemData.Tier), "FONTIN SC")
6868
end
6969
if not levelRange and addReq and not grantedEffect.support then
70-
tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FLevel: ^7%d%s%s",
71-
gemInstance.level,
72-
((displayInstance.level > gemInstance.level) and " (" .. colorCodes.MAGIC .. "+" .. (displayInstance.level - gemInstance.level) .. "^7)") or ((displayInstance.level < gemInstance.level) and " (" .. colorCodes.WARNING .. "-" .. (gemInstance.level - displayInstance.level) .. "^7)") or "",
73-
(gemInstance.level >= gemInstance.gemData.naturalMaxLevel) and " (Max)" or ""
74-
), "FONTIN SC")
70+
local totalGlobalLevels = 0
71+
if displayInstance.gemPropertyInfo then
72+
for i, prop in ipairs(displayInstance.gemPropertyInfo) do
73+
if prop.value and prop.value.key == "level" and prop.value.value then
74+
totalGlobalLevels = totalGlobalLevels + prop.value.value
75+
end
76+
end
77+
end
78+
local totalLevel
79+
local corruptLevel = displayInstance.corruptLevel or 0
80+
totalLevel = m_max(displayInstance.level, (gemInstance.level + corruptLevel)) -- Needed for tooltip comparison for dropdown gems. Otherwise they only show level 20 when corrupted.
81+
if corruptLevel ~= 0 or
82+
totalGlobalLevels > 0 or
83+
(displayInstance.level - gemInstance.level - corruptLevel > 0)
84+
then
85+
tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FLevel: ^7" .. colorCodes.MAGIC .. totalLevel), "FONTIN SC")
86+
tooltip:AddLine(fontSizeBig, "^7" .. gemInstance.level .. " Levels from Gem" .. ((gemInstance.level >= gemInstance.gemData.naturalMaxLevel) and " (Max)" or ""), "FONTIN SC")
87+
else
88+
tooltip:AddLine(fontSizeBig, string.format("^x7F7F7FLevel: ^7" .. totalLevel .. ((gemInstance.level >= gemInstance.gemData.naturalMaxLevel) and " (Max)" or "")), "FONTIN SC")
89+
end
90+
if corruptLevel > 0 then
91+
tooltip:AddLine(fontSizeBig, colorCodes.MAGIC .. "+" .. corruptLevel .. " Level from Corruption", "FONTIN SC")
92+
elseif corruptLevel < 0 then
93+
tooltip:AddLine(fontSizeBig, colorCodes.MAGIC .. corruptLevel .. " Level from Corruption", "FONTIN SC")
94+
end
95+
if totalGlobalLevels > 0 then
96+
tooltip:AddLine(fontSizeBig, colorCodes.MAGIC .. "+" .. totalGlobalLevels .. " Levels from Global Modifiers", "FONTIN SC")
97+
if totalLevel - gemInstance.level - corruptLevel - totalGlobalLevels > 0 then
98+
tooltip:AddLine(fontSizeBig, colorCodes.MAGIC .. "+" .. totalLevel - gemInstance.level - corruptLevel - totalGlobalLevels .. " Levels from Supports", "FONTIN SC")
99+
end
100+
elseif totalLevel - gemInstance.level - corruptLevel > 0 then
101+
tooltip:AddLine(fontSizeBig, colorCodes.MAGIC .. "+" .. totalLevel - gemInstance.level - corruptLevel .. " Levels from Supports", "FONTIN SC")
102+
end
75103
end
76104

77105
if not levelRange and grantedEffect.support then
@@ -172,6 +200,10 @@ local function addGrantedEffectInfo(tooltip, build, gemInstance, grantedEffect,
172200
tooltip:AddLine(fontSizeBig, colorCodes.GEMDESCRIPTION .. line, "FONTIN ITALIC")
173201
end
174202
end
203+
if displayInstance.corrupted == true then
204+
tooltip:AddSeparator(10)
205+
tooltip:AddLine(fontSizeBig, colorCodes.NEGATIVE .. "Corrupted", "FONTIN SC")
206+
end
175207
end
176208

177209
local function addStatSetInfo(tooltip, build, gemInstance, grantedEffect, statSet, noLabel, index, levelRange)

src/Classes/ImportTab.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ function ImportTabClass:ImportItemsAndSkills(charData)
863863
if gemId then
864864
local gemInstance = { level = 20, quality = 0, enabled = true, enableGlobal1 = true, enableGlobal2 = true, count = 1, gemId = gemId }
865865
gemInstance.support = skillData.support
866+
gemInstance.corrupted = skillData.corrupted
866867

867868
local spectreList = data.spectres
868869
if typeLine:sub(1, 8) == "Spectre:" then
@@ -918,8 +919,10 @@ function ImportTabClass:ImportItemsAndSkills(charData)
918919
else
919920
gemInstance.level = tonumber(property.values[1][1]:match("%d+"))
920921
end
921-
if skillData.properties[_ + 2] and skillData.properties[_ + 2].values[1][1]:match("(%d+) Level[s]? from Corruption") then
922-
gemInstance.level = gemInstance.level + tonumber(skillData.properties[_ + 2].values[1][1]:match("(%d+) Level[s]? from Corruption"))
922+
if skillData.properties[_ + 2] and skillData.properties[_ + 2].values[1][1]:match("(-?%d+) Level[s]? from Corruption") then
923+
gemInstance.corruptLevel = tonumber(skillData.properties[_ + 2].values[1][1]:match("(-?%d+) Level[s]? from Corruption"))
924+
else
925+
gemInstance.corruptLevel = 0
923926
end
924927
elseif escapeGGGString(property.name) == "Quality" then
925928
gemInstance.quality = tonumber(property.values[1][1]:match("%d+"))

0 commit comments

Comments
 (0)