Skip to content

Stage 5 — Team Mode (3v3) #8

Description

@KineticTactic

What this is: Extending the room engine for teams with multiple users per side. A 3v3 match is a standard room with 2 Teams, each containing 3 Users. Does not touch the tournament layer.

Owner: Can be a second developer working in parallel with Stage 6A–6B.

Tasks

  1. ContestTeam multi-user logic

    • Room creation with teamSize: 3: accept teams: [{ name, members: [userId, userId, userId] }].
    • Validate team sizes (1 or 3 per team, consistent within a contest).
    • Populate team:<teamId>:users Set with all member userId values.
    • In the cf_sync_queue worker: resolve userId → teamId by checking team:<teamId>:users membership before updating room:<id>:scores.
  2. Team score aggregation

    • Any team member's AC increments the team's score: ZINCRBY room:<id>:scores <points> <teamId>.
    • Individual attribution is preserved in ContestSubmission via the userId field.
    • Activity appended to room:<id>:submissions stream: { userId, teamId, problemId, ... }.
  3. Arena team claim

    • A problem is locked by teamId when any member of the team claims it.
    • Lua claim script uses teamId|cfTimestamp as the lock value (not userId|cfTimestamp).
  4. Ready check for teams

    • All members of all teams must POST /api/contests/rooms/:id/ready.
    • If any member fails to ready within 60s, their entire team is withdrawn as a unit.

Testing Gate

  • 3v3 Blitz: 6 real CF accounts, two teams of 3. Any team member's AC increments the team score in room:<id>:scores. Verify ContestTeam.score in MongoDB after room end.
  • 3v3 Arena claim: A member of Team 1 and a member of Team 2 race for a problem. Earlier CF timestamp wins the claim for their respective team.
  • Regression: all Stage 3 and Stage 4 1v1 tests still pass after team mode changes.

Handoff Contract

  • Team and 1v1 modes work without conflict. Full Stage 3 + Stage 4 regression passes.
  • ContestTeam schema works for both standalone rooms and knockout tournament context (nullable roundId, contestId fields).

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions