Skip to content
Open
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
14 changes: 14 additions & 0 deletions spec/System/TestCompareTab_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@ describe("CompareTab", function()
assert.are.equals(build.calcsTab.mainOutput.GemQuality, entry.calcsTab.mainOutput.GemQuality)
assert.are.equals(build.calcsTab.mainOutput.CombinedDPS, entry.calcsTab.mainOutput.CombinedDPS)
end)
it("keeps mercenary groups apart from player groups with the same gems", function()
newBuild()
build.skillsTab:PasteSocketGroup("Spark 20/0 1\n")
build.skillsTab:PasteSocketGroup("Mercenary: true\nSparkMercenary 20/0 1\n")
runCallback("OnFrame")
local entry = new("CompareEntry"):CompareEntry(build:SaveDB("code"), "Self")
local player, mercenary = entry.skillsTab.socketGroupList[1], entry.skillsTab.socketGroupList[2]
assert.is_true(mercenary.mercenary)

local compareTab = build.compareTab
assert.are_not.equals(compareTab:GetSocketGroupSignature(player), compareTab:GetSocketGroupSignature(mercenary))
assert.are.equals("Spark", compareTab:GetSocketGroupLabel(player))
assert.are.equals("Spark (Mercenary)", compareTab:GetSocketGroupLabel(mercenary))
end)
end)
614 changes: 614 additions & 0 deletions spec/System/TestMercenary_spec.lua

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Classes/CalcsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function CalcsTabClass:CalcsTab(build)
self:NewSection(3, "SkillSelect", 1, colorCodes.NORMAL, {{ defaultCollapsed = false, label = "View Skill Details", data = {
{ label = "Socket Group", { controlName = "mainSocketGroup",
control = new("DropDownControl"):DropDownControl(nil, {0, 0, 300, 16}, nil, function(index, value)
self.input.skill_number = index
self.input.skill_number = value.val
self:AddUndoState()
self.build.buildFlag = true
end) {
tooltipFunc = function(tooltip, mode, index, value)
local socketGroup = self.build.skillsTab.socketGroupList[index]
local socketGroup = value and self.build.skillsTab.socketGroupList[value.val]
if socketGroup and tooltip:CheckForUpdate(socketGroup, self.build.outputRevision) then
self.build.skillsTab:AddSocketGroupTooltip(tooltip, socketGroup)
end
Expand Down
9 changes: 6 additions & 3 deletions src/Classes/CompareEntry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,14 @@ end
function CompareEntryClass:RefreshSkillSelectControls(controls, mainGroup, suffix)
-- Populate skill select controls
if not controls or not controls.mainSocketGroup then return end
controls.mainSocketGroup.selIndex = mainGroup
wipeTable(controls.mainSocketGroup.list)
for i, socketGroup in pairs(self.skillsTab.socketGroupList) do
controls.mainSocketGroup.list[i] = { val = i, label = socketGroup.displayLabel }
for i, socketGroup in ipairs(self.skillsTab.socketGroupList) do
if not socketGroup.mercenary then
t_insert(controls.mainSocketGroup.list, { val = i, label = socketGroup.displayLabel })
end
end
controls.mainSocketGroup.selIndex = 1
controls.mainSocketGroup:SelByValue(mainGroup, "val")
controls.mainSocketGroup:CheckDroppedWidth(true)

-- Helper: hide all skill detail controls
Expand Down
17 changes: 11 additions & 6 deletions src/Classes/CompareTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function CompareTabClass:InitControls()
self.controls.cmpSocketGroup = new("DropDownControl"):DropDownControl({"LEFT", self.controls.cmpSkillLabel, "RIGHT"}, {4, 0, 200, 20}, {}, function(index, value)
local entry = self:GetActiveCompare()
if entry then
entry:SetMainSocketGroup(index)
entry:SetMainSocketGroup(value.val)
end
end)
self.controls.cmpSocketGroup.shown = setsEnabled
Expand Down Expand Up @@ -493,7 +493,7 @@ function CompareTabClass:InitControls()
}
-- Primary build calcs skill controls
self.controls.primCalcsSocketGroup = new("DropDownControl"):DropDownControl(nil, {0, 0, 200, 18}, {}, function(index, value)
self.primaryBuild.calcsTab.input.skill_number = index
self.primaryBuild.calcsTab.input.skill_number = value.val
self.primaryBuild.buildFlag = true
end)
self.controls.primCalcsSocketGroup.shown = false
Expand Down Expand Up @@ -597,7 +597,7 @@ function CompareTabClass:InitControls()
self.controls.cmpCalcsSocketGroup = new("DropDownControl"):DropDownControl(nil, {0, 0, 200, 18}, {}, function(index, value)
local entry = self:GetActiveCompare()
if entry then
entry.calcsTab.input.skill_number = index
entry.calcsTab.input.skill_number = value.val
entry.buildFlag = true
end
end)
Expand Down Expand Up @@ -2482,7 +2482,8 @@ function CompareTabClass:GetSocketGroupSignature(group)
end
end
table.sort(names)
return table.concat(names, "+")
-- Mercenary gems share names with player gems
return (group.mercenary and "Mercenary:" or "") .. table.concat(names, "+")
end

-- Get a display label for a socket group (active skills only)
Expand All @@ -2509,7 +2510,7 @@ function CompareTabClass:GetSocketGroupLabel(group)
if #names == 0 then
return "(empty group)"
end
return table.concat(names, " + ")
return table.concat(names, " + ") .. (group.mercenary and " (Mercenary)" or "")
end

-- Coroutine: calculate power of compared build elements against primary build
Expand Down Expand Up @@ -4129,7 +4130,8 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
local scorePairs = {}
for pi = 1, #pGroups do
for ci = 1, #cGroups do
local score = groupSimilarity(pSets[pi], cSets[ci])
-- Mercenary gems share names with player gems, so only groups of the same kind are matched
local score = (not pGroups[pi].mercenary) == (not cGroups[ci].mercenary) and groupSimilarity(pSets[pi], cSets[ci]) or 0
if score > 0 then
t_insert(scorePairs, { pIdx = pi, cIdx = ci, score = score })
end
Expand Down Expand Up @@ -4324,6 +4326,9 @@ function CompareTabClass:DrawSkills(vp, compareEntry)
if group.slot then
groupLabel = groupLabel .. " (" .. group.slot .. ")"
end
if group.mercenary then
groupLabel = groupLabel .. " (Mercenary)"
end
return groupLabel
end
local function getGroupSlotIcon(skillsTab, idx, group)
Expand Down
16 changes: 15 additions & 1 deletion src/Classes/GemSelectControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ function GemSelectClass:FilterSupport(gemId, gemData)
if gemData.grantedEffect.legacy and not self.skillsTab.showLegacyGems then
return false
end
-- Mercenary gems are only used in mercenary socket groups, which have one skill and the supports it lists
local group = self.skillsTab.displayGroup
if (not gemData.mercenary) ~= not (group and group.mercenary) then
return false
end
if gemData.mercenary then
-- The gem being edited is ignored, as it is replaced while typing
for index, gem in ipairs(group.gemList) do
local skill = index ~= self.index and gem.gemData and gem.gemData.grantedEffect
if skill and not skill.support and not (gemData.grantedEffect.support and skill.mercenarySupports and isValueInArray(skill.mercenarySupports, gemData.grantedEffectId)) then
return false
end
end
end

if self.imbuedSelect then
return self.sortCache.canSupport[gemId]
Expand Down Expand Up @@ -362,7 +376,7 @@ function GemSelectClass:UpdateSortCache()
for gemId, gemData in pairs(self.gems) do
sortCache.dps[gemId] = baseDPS
-- Gems that support the active skill or have global effects need DPS calc
if sortCache.canSupport[gemId] or (gemData.grantedEffect.hasGlobalEffect and not gemData.grantedEffect.support) then
if (sortCache.canSupport[gemId] or (gemData.grantedEffect.hasGlobalEffect and not gemData.grantedEffect.support)) and (not gemData.mercenary) == not self.skillsTab.displayGroup.mercenary then
sortCache.pendingGems[#sortCache.pendingGems + 1] = gemId
end
-- Neutral color until DPS is computed
Expand Down
Loading
Loading