Skip to content

Commit 307a0ee

Browse files
author
LocalIdentity
committed
Fix Tame beast resistance display
It was still using the regular resist values in the tooltip of the beast selection UI and for the sort
1 parent 1aa3e7f commit 307a0ee

4 files changed

Lines changed: 74 additions & 20 deletions

File tree

spec/System/TestSkills_spec.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,46 @@ describe("TestSkills", function()
102102
assert.matches("Explosion radius", qualityDescriptions[1])
103103
end)
104104

105+
it("uses companion resistances in the beast library controls", function()
106+
local minionId = "Metadata/Monsters/LeagueAbyss/Lightless/Cocoon3Spectre"
107+
local testData = {
108+
skills = build.data.skills,
109+
minions = {
110+
A = copyTable(build.data.minions[minionId]),
111+
B = copyTable(build.data.minions[minionId]),
112+
},
113+
}
114+
testData.minions.B.name = "B"
115+
testData.minions.B.fireResist = 0
116+
testData.minions.B.companionFireResist = 60
117+
118+
local tooltip = {
119+
lines = { },
120+
CheckForUpdate = function()
121+
return true
122+
end,
123+
AddLine = function(self, _, text)
124+
table.insert(self.lines, text)
125+
end,
126+
AddSeparator = function()
127+
end,
128+
}
129+
local spectreList = new("MinionListControl", nil, { 0, 0, 100, 100 }, testData, { "A" }, nil, "Spectres")
130+
local beastList = new("MinionListControl", nil, { 0, 0, 100, 100 }, testData, { "A" }, nil, "Beasts", true)
131+
132+
spectreList:AddValueTooltip(tooltip, 1, "A")
133+
assert.matches("Resistances:.*75", table.concat(tooltip.lines, "\n"))
134+
tooltip.lines = { }
135+
beastList:AddValueTooltip(tooltip, 1, "A")
136+
assert.matches("Resistances:.*50", table.concat(tooltip.lines, "\n"))
137+
138+
local sourceList = { "A", "B" }
139+
local sourceControl = new("MinionSearchListControl", nil, { 0, 0, 100, 100 }, testData, sourceList, beastList, "Beasts", true)
140+
sourceControl.controls.sortModeDropDown.selIndex = 9
141+
sourceControl:sortSourceList()
142+
assert.are.equals("B", sourceControl.list[1])
143+
end)
144+
105145

106146
it("uses granted effect minion list when active skill minion list is missing", function()
107147
local srcInstance = { statSet = { }, skillPart = { }, nameSpec = "Spectre: Test" }

src/Classes/MinionListControl.lua

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ local t_remove = table.remove
99
local s_format = string.format
1010
local m_max = math.max
1111

12-
local MinionListClass = newClass("MinionListControl", "ListControl", function(self, anchor, rect, data, list, dest, label)
12+
local MinionListClass = newClass("MinionListControl", "ListControl", function(self, anchor, rect, data, list, dest, label, showCompanionStats)
1313
self.ListControl(anchor, rect, 16, "VERTICAL", not dest, list)
1414
self.data = data
1515
self.dest = dest
16+
self.showCompanionStats = showCompanionStats
1617
if dest then
1718
self.dragTargetList = { dest }
1819
self.label = label or "^7Available Spectres:"
@@ -49,6 +50,10 @@ end
4950
function MinionListClass:AddValueTooltip(tooltip, index, minionId)
5051
if tooltip:CheckForUpdate(minionId) then
5152
local minion = self.data.minions[minionId]
53+
local fireResist = self.showCompanionStats and minion.companionFireResist or minion.fireResist
54+
local coldResist = self.showCompanionStats and minion.companionColdResist or minion.coldResist
55+
local lightningResist = self.showCompanionStats and minion.companionLightningResist or minion.lightningResist
56+
local chaosResist = self.showCompanionStats and minion.companionChaosResist or minion.chaosResist
5257
tooltip.center = true
5358
tooltip:AddLine(20, "^7"..minion.name, "FONTIN SC")
5459
tooltip.center = false
@@ -67,10 +72,10 @@ function MinionListClass:AddValueTooltip(tooltip, index, minionId)
6772
tooltip:AddLine(14, s_format("^7Evasion Multiplier: x%.2f", 1 + minion.evasion))
6873
end
6974
tooltip:AddLine(14, s_format("^7Resistances: %s%d ^7/ %s%d ^7/ %s%d ^7/ %s%d",
70-
colorCodes.FIRE, minion.fireResist,
71-
colorCodes.COLD, minion.coldResist,
72-
colorCodes.LIGHTNING, minion.lightningResist,
73-
colorCodes.CHAOS, minion.chaosResist
75+
colorCodes.FIRE, fireResist,
76+
colorCodes.COLD, coldResist,
77+
colorCodes.LIGHTNING, lightningResist,
78+
colorCodes.CHAOS, chaosResist
7479
))
7580
tooltip:AddLine(14, s_format("^7Base Damage: x%.2f", minion.damage))
7681
tooltip:AddLine(14, s_format("^7Base Attack Speed: %.2f", 1 / minion.attackTime))
@@ -189,4 +194,4 @@ function SpawnListClass:AddValueTooltip(tooltip, index, value)
189194
tooltip:AddLine(18, "^7World area not found: " .. tostring(value))
190195
end
191196
end
192-
end
197+
end

src/Classes/MinionSearchListControl.lua

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ local t_insert = table.insert
88
local t_remove = table.remove
99
local s_format = string.format
1010

11-
local MinionSearchListClass = newClass("MinionSearchListControl", "MinionListControl", function(self, anchor, rect, data, list, dest, label)
12-
self.MinionListControl(anchor, rect, data, list, dest, label)
11+
local MinionSearchListClass = newClass("MinionSearchListControl", "MinionListControl", function(self, anchor, rect, data, list, dest, label, showCompanionStats)
12+
self.MinionListControl(anchor, rect, data, list, dest, label, showCompanionStats)
1313
self:sortSourceList()
1414
self.unfilteredList = copyTable(list)
1515
self.isMutable = false
@@ -97,10 +97,10 @@ function MinionSearchListClass:sortSourceList()
9797
[6] = { field = "damage", asc = false },
9898
[7] = { field = "companionReservation", asc = true },
9999
[8] = { field = "spectreReservation", asc = true },
100-
[9] = { field = "fireResist", asc = false },
101-
[10] = { field = "coldResist", asc = false },
102-
[11] = { field = "lightningResist", asc = false },
103-
[12] = { field = "chaosResist", asc = false },
100+
[9] = { field = self.showCompanionStats and "companionFireResist" or "fireResist", asc = false },
101+
[10] = { field = self.showCompanionStats and "companionColdResist" or "coldResist", asc = false },
102+
[11] = { field = self.showCompanionStats and "companionLightningResist" or "lightningResist", asc = false },
103+
[12] = { field = self.showCompanionStats and "companionChaosResist" or "chaosResist", asc = false },
104104
[13] = { field = "totalResist", asc = false },
105105
[14] = { field = "baseMovementSpeed", asc = false },
106106
}
@@ -122,8 +122,13 @@ function MinionSearchListClass:sortSourceList()
122122
valueA = (minionA.energyShield or 0) * minionA.life
123123
valueB = (minionB.energyShield or 0) * minionB.life
124124
elseif sortOption.field == "totalResist" then
125-
valueA = (minionA.fireResist or 0) + (minionA.coldResist or 0) + (minionA.lightningResist or 0) + (minionA.chaosResist or 0)
126-
valueB = (minionB.fireResist or 0) + (minionB.coldResist or 0) + (minionB.lightningResist or 0) + (minionB.chaosResist or 0)
125+
if self.showCompanionStats then
126+
valueA = (minionA.companionFireResist or 0) + (minionA.companionColdResist or 0) + (minionA.companionLightningResist or 0) + (minionA.companionChaosResist or 0)
127+
valueB = (minionB.companionFireResist or 0) + (minionB.companionColdResist or 0) + (minionB.companionLightningResist or 0) + (minionB.companionChaosResist or 0)
128+
else
129+
valueA = (minionA.fireResist or 0) + (minionA.coldResist or 0) + (minionA.lightningResist or 0) + (minionA.chaosResist or 0)
130+
valueB = (minionB.fireResist or 0) + (minionB.coldResist or 0) + (minionB.lightningResist or 0) + (minionB.chaosResist or 0)
131+
end
127132
end
128133
if valueA == valueB then
129134
return minionA.name < minionB.name

src/Modules/Build.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,10 @@ function buildMode:OpenSpectreLibrary(library)
16511651
end
16521652
end
16531653
local movementSpeed = minion.baseMovementSpeed / 10 .. " m/s"
1654+
local fireResist = library == "beast" and minion.companionFireResist or minion.fireResist
1655+
local coldResist = library == "beast" and minion.companionColdResist or minion.coldResist
1656+
local lightningResist = library == "beast" and minion.companionLightningResist or minion.lightningResist
1657+
local chaosResist = library == "beast" and minion.companionChaosResist or minion.chaosResist
16541658
controls.minionNameLabel.labelText = "^7" .. minion.name
16551659
controls.lifeLabel.lifeValue = round(totalLife)
16561660
controls.energyshieldLabel.energyShieldValue = round(totalES)
@@ -1659,19 +1663,19 @@ function buildMode:OpenSpectreLibrary(library)
16591663
controls.evasionLabel.evasionValue = round(totalEvasion)
16601664
controls.spawnLocations.list = spawnLocationList
16611665
controls.resistsLabel.resistsValue = (
1662-
colorCodes.FIRE..minion.fireResist.."^7 / "..
1663-
colorCodes.COLD..minion.coldResist.."^7 / "..
1664-
colorCodes.LIGHTNING..minion.lightningResist.."^7 / "..
1665-
colorCodes.CHAOS..minion.chaosResist)
1666+
colorCodes.FIRE..fireResist.."^7 / "..
1667+
colorCodes.COLD..coldResist.."^7 / "..
1668+
colorCodes.LIGHTNING..lightningResist.."^7 / "..
1669+
colorCodes.CHAOS..chaosResist)
16661670
controls.movementSpeedLabel.movementSpeedValue = movementSpeed
16671671
end
16681672

16691673
local label = (library == "beast" and "Beasts" or "Spectres")
1670-
controls.list = new("MinionListControl", nil, {-230, 40, 210, 270}, self.data, destList, nil, label.." in Build:")
1674+
controls.list = new("MinionListControl", nil, {-230, 40, 210, 270}, self.data, destList, nil, label.." in Build:", library == "beast")
16711675
controls.list.OnSelect = function()
16721676
UpdateMinionDisplay(controls.list.selValue)
16731677
end
1674-
controls.source = new("MinionSearchListControl", nil, {0, 80, 210, 230}, self.data, sourceList, controls.list, "^7Available "..label..":")
1678+
controls.source = new("MinionSearchListControl", nil, {0, 80, 210, 230}, self.data, sourceList, controls.list, "^7Available "..label..":", library == "beast")
16751679
controls.source.OnSelect = function()
16761680
UpdateMinionDisplay(controls.source.selValue)
16771681
end

0 commit comments

Comments
 (0)