Fix preset alliance teams being randomised by draft-order shuffle - #115
Merged
shenanigans-be merged 1 commit intoJul 16, 2026
Merged
Conversation
generatePlayerData() shuffled the player list for random draft order before assigning alliance teams by adjacency, so "Preset teams" only worked when "Use specified player order" was also enabled. With random draft order (the default) the preset pairs were scrambled. Capture the preset team-per-player mapping from the original input order before the draft-order shuffle, and re-apply it afterwards so team composition stays fixed regardless of draft order. Random teams keep their existing pairing behaviour. Fixes shenanigans-be#114
shenanigans-be
approved these changes
Jul 16, 2026
shenanigans-be
left a comment
Owner
There was a problem hiding this comment.
Thank you for the high quality PR!
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
Fixes #114. When the Alliance variant is used with Preset teams, the teams are randomised anyway unless "Use specified player order" is also enabled.
Cause
In
GenerateDraft::generatePlayerData(), the player list is shuffled for random draft order (presetDraftOrder = false, the default) before alliance teams are assigned. Teams are then formed by pairing adjacent players in that already-shuffled list, so the preset pairs entered in the form are lost.The two settings —
presetDraftOrder(pick sequence) andallianceTeamMode(team composition) — were conflated. The existingitCanGeneratePlayerDataForAlliancestest only passed because it setpresetDraftOrder => true, which skips the shuffle and masked the bug.Fix
$playersarray in place).Test
Adds
itKeepsPresetTeamsWhenDraftOrderIsRandomised, which runs withpresetDraftOrder => falseand asserts (across 20 shuffled runs) that each player keeps their preset team. This fails against the old code and passes with the fix.