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
38 changes: 38 additions & 0 deletions spec/System/TestWeaponSetPoints_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
describe("WeaponSetPoints", function()
before_each(function()
newBuild()
end)

-- The warning only reads the per-set counts from CountAllocNodes, so the
-- nodes are placed straight into allocNodes: allocating through the tree
-- would drag pathing into a test about which set gets named.
local function warningFor(set1Used, set2Used)
local id = 0
for _ = 1, set1Used + set2Used do
id = id + 1
build.spec.allocNodes["fake" .. id] = {
type = "Normal",
allocMode = id <= set1Used and 1 or 2,
}
end
build.controls.warnings.lines = { }
build:EstimatePlayerProgress()
for _, line in ipairs(build.controls.warnings.lines) do
if line:match("passives available") then
return line
end
end
end

it("names weapon set 1 when set 1 has fewer points allocated", function()
assert.are.equals("You have 2 Weapon set 1 passives available", warningFor(1, 3))
end)

it("names weapon set 2 when set 2 has fewer points allocated", function()
assert.are.equals("You have 2 Weapon set 2 passives available", warningFor(3, 1))
end)

it("says nothing when both sets have the same number allocated", function()
assert.is_nil(warningFor(2, 2))
end)
end)
7 changes: 5 additions & 2 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,12 @@ function buildMode:EstimatePlayerProgress()
end

if not warningsWeaponSet and weaponSet1Used ~= weaponSet2Used then
-- The set with fewer allocated points is the one with points to
-- spare, since a node allocated in both sets is only paid for once.
InsertIfNew(self.controls.warnings.lines, string.format(
"You have %d Weapon set 2 passives available",
math.abs(weaponSet2Used - weaponSet1Used)
"You have %d Weapon set %d passives available",
math.abs(weaponSet2Used - weaponSet1Used),
weaponSet1Used < weaponSet2Used and 1 or 2
))
end

Expand Down