Resolve issue with duo/trio/quad team forming logic - #4758
Conversation
WalkthroughTeam assignment now receives explicit Duos/Trios/Quads context. Human placement prefers fuller teams in these modes, and both game assignment and lobby previews pass the new flag. Tests cover legacy behavior and nation pairing. ChangesTeam packing behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/core/game/TeamAssignment.ts (1)
107-120: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPut friend groups before friendless humans.
The new tie-breaker cannot preserve a friend pair when a friendless human is processed first. In Duos,
[friendless, A↔B]fills the first team withfriendless + A, forcingBonto another team. Partition humans with present friends before friendless humans before placement, and add this regression case.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/core/game/TeamAssignment.ts` around lines 107 - 120, The team-placement flow in TeamAssignment must prioritize humans with existing friends before friendless humans. Partition or order the input before placement so friend-connected players are processed first, then add a regression case covering a friendless player preceding an A↔B pair and verify the pair remains together.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/core/game/TeamAssignment.ts`:
- Around line 107-120: The team-placement flow in TeamAssignment must prioritize
humans with existing friends before friendless humans. Partition or order the
input before placement so friend-connected players are processed first, then add
a regression case covering a friendless player preceding an A↔B pair and verify
the pair remains together.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: be14334f-cc5f-4e20-9b93-807172f79f7a
📒 Files selected for processing (4)
src/client/components/LobbyPlayerView.tssrc/core/game/GameImpl.tssrc/core/game/TeamAssignment.tstests/TeamAssignment.test.ts
|
Looking at the review from coderabbit, I can see this is outside the scope of the original ticket because it's behaviour that was already present in the code before I made changes. I can update the PR to include a fix to this flagged issue also, if this is preferred? |
Add approved & assigned issue number here:
Resolves #4253
Description:
This resolves an issue with duos/trios/quads where humans would be automatically assigned to the emptiest teams, thereby resulting in combinations of humans + nations fighting each other, whereas the preferred behaviour is for humans to be put together where possible.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
sjg.