Skip to content

matchmakingserver: backfill running battlegrounds toward the team cap - #99

Open
3kynox wants to merge 2 commits into
walkline:masterfrom
3kynox:fix/matchmaking-retail-backfill-target
Open

3kynox wants to merge 2 commits into
walkline:masterfrom
3kynox:fix/matchmaking-retail-backfill-target

Conversation

@3kynox

@3kynox 3kynox commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

BackfillSlotsForTeam capped invites at the opposite team's headcount, so a balanced in-progress match was mathematically unable to grow: someone queuing against a balanced 6v6 could never enter, and a battleground could never reach 10v10 through backfill.

Retail keeps accepting joiners while a team is below MaxPlayersPerTeam, so the target is now the team cap. Arenas are unaffected since their min equals max. Existing tests adjusted to the retail expectation; verified live (a running WSG grows to full through the queue).

…m cap

BackfillSlotsForTeam now fills toward MaxPlayersPerTeam — the retail
behavior: an in-progress battleground keeps accepting joiners while a
team is below the cap. The old cap at the opposite team's headcount
made a balanced match mathematically unable to grow: a player queuing
against a balanced 6v6 could never enter, and a match could never
reach 10v10. Arenas are unaffected (min == max).
Copilot AI lite review requested due to automatic review settings August 30, 2026 13:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The logic change is small and cohesive, and the accompanying tests were updated to cover the new retail-aligned backfill behavior.

Pull request overview

This PR updates battleground backfill logic so running battlegrounds can continue to accept queued players up to MaxPlayersPerTeam (instead of being capped by the opposite team’s current headcount), matching retail behavior and allowing balanced in-progress matches to grow to full team caps.

Changes:

  • Adjust BackfillSlotsForTeam to target MaxPlayersPerTeam regardless of current team balance.
  • Update battleground queue tests to assert groups backfill into an in-progress battleground instead of staying queued.
  • Update battleground backfill unit tests to reflect the new “fill toward max” behavior and invited-player accounting.
File summaries
File Description
apps/matchmakingserver/service/battleground-queue_test.go Updates queue tests to expect backfill into in-progress battlegrounds toward team cap.
apps/matchmakingserver/battleground/battleground.go Changes backfill slot calculation to be based on MaxPlayersPerTeam only.
apps/matchmakingserver/battleground/battleground_test.go Updates unit tests for backfill semantics and invited-player slot handling under the new rules.
Review details

Suppressed comments (1)

apps/matchmakingserver/battleground/battleground.go:114

  • BackfillSlotsForTeam now computes the exact same value as FreeSlotsForTeam (max minus active+invited). Keeping two implementations for the same logic risks them drifting over time; consider delegating BackfillSlotsForTeam to FreeSlotsForTeam to keep behavior consistent in one place.
// BackfillSlotsForTeam returns how many players the team can accept from the
// queue: up to MaxPlayersPerTeam, the retail behavior — a battleground in
// progress keeps accepting joiners while a team is below the cap, regardless
// of the balance (joining a losing match is allowed on retail too).
func (b *Battleground) BackfillSlotsForTeam(team PVPTeam) uint8 {
	teamCount := len(b.ActivePlayersPerTeam[team]) + len(b.InvitedPlayersPerTeam[team])

	r := int(b.MaxPlayersPerTeam) - teamCount
	if r < 0 {
		return 0
	}

	return uint8(r)
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +155 to +156
invited := false
mockService.On("InviteGroups", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Run(func(mock.Arguments) { invited = true }).Return(nil)
Review follow-up: assert exactly one InviteGroups call, for the queued
group's team, carrying exactly the one queued group - instead of a
boolean that would also pass on duplicate or mistargeted invites.
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.

2 participants