Skip to content

fix: stop lust allocation from starving completable teams#15

Merged
devi4nt merged 1 commit into
mainfrom
fix/lust-team-starvation
Jun 8, 2026
Merged

fix: stop lust allocation from starving completable teams#15
devi4nt merged 1 commit into
mainfrom
fix/lust-team-starvation

Conversation

@devi4nt

@devi4nt devi4nt commented Jun 8, 2026

Copy link
Copy Markdown
Owner

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's ceil(14/5) = 3 slots 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:

  • Assign tanks → healers → dps in full round-robin passes, so the scarce tank/healer roles are reserved across every team before dps are handed out. (This ordering is what keeps multi-spec / flex players working — they aren't spent as dps on an early team and missed as a tank/healer on a later one.)
  • 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-dup map — pruning by player already prevents multi-spec players being picked twice.

Tests

Added regression tests for three shapes that previously dropped a team:

  • 2 tanks / 2 healers / surplus dps (the reported case)
  • 3 tanks / 3 healers / scarce dps (doomed slot stealing dps)
  • the reported case with stale captain flags set

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

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>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mythic-plus-team-randomiser with  Cloudflare Pages  Cloudflare Pages

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

View logs

@devi4nt devi4nt merged commit 3ffb44a into main Jun 8, 2026
2 checks passed
@devi4nt devi4nt deleted the fix/lust-team-starvation branch June 8, 2026 19:11
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.

1 participant