Skip to content

Fix negative stat item sorting#1889

Open
unrealdreamz wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
unrealdreamz:fix/negative-stat-sorting
Open

Fix negative stat item sorting#1889
unrealdreamz wants to merge 1 commit into
PathOfBuildingCommunity:devfrom
unrealdreamz:fix/negative-stat-sorting

Conversation

@unrealdreamz
Copy link
Copy Markdown
Contributor

Fixes #848

Summary

  • Preserve negative measured item scores while sorting unique items by defensive/taken-damage stats.
  • Add a regression that verifies an item whose best score is still negative can sort ahead of a weaker baseline item.

Root Cause

ItemDBControl:ListBuilder initialized every stat-sort score to 0 before evaluating replacement slots. For stats such as Taken Fire Damage, the sort transform intentionally negates the output so lower damage is better. When all valid candidates were negative, m_max(0, negativeScore) kept every item at 0, producing a full stat tie and falling back to name sorting.

Fix

Initialize measuredPower as nil for each item and only fall back to 0 after all valid replacement slots have been evaluated. This keeps real negative scores, while still giving unsortable/no-slot items the old neutral fallback.

Validation

  • git diff --check - pass, exit code 0.
  • Targeted regression added in spec/System/TestItemMods_spec.lua.
  • Docker/Busted not run locally in this pass because this machine was explicitly kept free of local test/container windows; GitHub Actions should run the normal suite on the PR.

Risk/Rollback

Low risk: the change is restricted to item database stat sorting. Rollback restores the previous zero-initialization behavior, but would reintroduce name-sorting for all-negative stat scores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sorting Uniques by 'Taken --- Damage' instead sorts by Name

1 participant