From 812564b3d5b82c6088df1fc81af5fac0e80d41ae Mon Sep 17 00:00:00 2001 From: Lucas Karsten Date: Sat, 15 Aug 2026 14:35:05 -0300 Subject: [PATCH] Name the weapon set that has points available The warning for unspent weapon set points was formatted with "Weapon set 2" hardcoded, so a character with fewer points allocated in set 1 was told the spare points belonged to set 2. The count was already correct, as it is the difference between the two sets: a node allocated in both sets is only paid for once, which is why the smaller set is the one with room to grow, and the same reason EstimatePlayerProgress subtracts the minimum of the two from the normal passive count. --- spec/System/TestWeaponSetPoints_spec.lua | 38 ++++++++++++++++++++++++ src/Modules/Build.lua | 7 +++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 spec/System/TestWeaponSetPoints_spec.lua diff --git a/spec/System/TestWeaponSetPoints_spec.lua b/spec/System/TestWeaponSetPoints_spec.lua new file mode 100644 index 0000000000..e4df20a3e8 --- /dev/null +++ b/spec/System/TestWeaponSetPoints_spec.lua @@ -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) diff --git a/src/Modules/Build.lua b/src/Modules/Build.lua index e8b9a48140..4c1c6319ba 100644 --- a/src/Modules/Build.lua +++ b/src/Modules/Build.lua @@ -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