fix: stop lust allocation from starving completable teams#15
Merged
Conversation
When the roster had more team slots (ceil(players / 5)) than could actually be completed - e.g. 2 tanks, 2 healers and surplus dps giving 3 slots but only 2 completable teams - the lust pre-pass ran before roles were assigned and let a doomed trailing slot grab a scarce lust-capable healer. That consumed one of only two healers, leaving an otherwise-completable team with four members, which was then silently dropped. The result was fewer groups than the roster supported (the reported 2-tanks/2-healers/6+-dps case producing a single team). Commit 74024d0 fixed lust over-stacking a team to six members but not this starvation case. Stale captain flags were not the cause - the bug reproduces with no captains at all. Fold lust into the role-assignment passes as a preference instead of a separate pre-pass: - Assign tanks, then healers, then dps in full round-robin passes so the scarce tank/healer roles are reserved across every team before damage dealers are handed out (preserves correct behaviour for multi-spec players who can fill more than one role). - Prefer a lust-capable member only when filling a slot the team needs anyway (its healer, or a dps), so spreading lust can never consume a scarce role a sibling team requires. - Remove the now-redundant lust provider de-duplication map; pruning by player already prevents multi-spec players being used twice. Adds regression tests for the surplus-dps, scarce-dps and stale-captain variants, and runs the formatter across the touched files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying mythic-plus-team-randomiser with
|
| Latest commit: |
94d2281
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2c1d3b4b.mythic-plus-team-randomiser.pages.dev |
| Branch Preview URL: | https://fix-lust-team-starvation.mythic-plus-team-randomiser.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A re-occurrence of the "fewer groups than it should" bug: with 2 tanks, 2 healers and 6+ dps (enough for 2 complete teams) and lots of lust classes, the randomiser produced only one team.
Root cause
amount = ceil(players / 5)can be larger than the number of teams that can actually be completed. With 2 tanks / 2 healers / 10 dps that'sceil(14/5) = 3slots but only 2 completable teams.The lust allocation ran as a separate pass before roles were assigned, iterating every slot — including the doomed 3rd one. That doomed slot was allowed to grab a scarce lust-capable healer, consuming one of only two healers. A genuinely completable team was then left with 4 members and silently dropped (teams are only kept when
members.length === 5).#12 (74024d0) fixed lust over-stacking a team to 6; it didn't cover this starvation case. This was reproduced deterministically with no captains at all, so stale captain flags are not the cause.
Fix
Fold lust into the role-assignment passes as a preference rather than a separate pre-pass:
Tests
Added regression tests for three shapes that previously dropped a team:
All 35 tests pass; lint, typecheck and formatting are clean. (The diff also includes formatter output across the touched files, which were not previously formatted to the current config.)
🤖 Generated with Claude Code