Skip to content

Equalize team sizes#992

Merged
evanpelle merged 3 commits intomainfrom
team-size
Jun 2, 2025
Merged

Equalize team sizes#992
evanpelle merged 3 commits intomainfrom
team-size

Conversation

@scottanderson
Copy link
Contributor

@scottanderson scottanderson commented Jun 1, 2025

Description:

Ensure that team sizes are equal.

Closes #841

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
  • I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors

@scottanderson scottanderson added this to the v23 milestone Jun 1, 2025
@scottanderson scottanderson self-assigned this Jun 1, 2025
@scottanderson scottanderson requested a review from a team as a code owner June 1, 2025 03:35
@scottanderson scottanderson requested a review from evanpelle June 1, 2025 03:35
@scottanderson scottanderson added the Meta Minor balancing adjustment, mostly value changes, minor calculation changes. label Jun 1, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 1, 2025

Walkthrough

This change updates the logic for determining the maximum number of players in a game lobby. The method now accepts an optional parameter for the number of player teams, adjusts the player count to be divisible by the team count, and modifies how the cap is calculated based on the map and mode.

Changes

File(s) Change Summary
src/core/configuration/Config.ts Updated ServerConfig.lobbyMaxPlayers method signature to accept optional numPlayerTeams parameter.
src/core/configuration/DefaultConfig.ts Modified logic in DefaultServerConfig.lobbyMaxPlayers to use team count for divisibility and capping.
src/server/MapPlaylist.ts Updated call to lobbyMaxPlayers to include numPlayerTeams when game mode is Team.

Sequence Diagram(s)

sequenceDiagram
    participant MapPlaylist
    participant Config
    participant DefaultServerConfig

    MapPlaylist->>Config: lobbyMaxPlayers(map, mode, numPlayerTeams?)
    Config->>DefaultServerConfig: delegate to implementation
    DefaultServerConfig->>DefaultServerConfig: Calculate base player count
    DefaultServerConfig->>DefaultServerConfig: If Team mode, scale and adjust for team divisibility
    DefaultServerConfig-->>Config: Return max player count
    Config-->>MapPlaylist: Return max player count
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure teams have equal sizes (#841)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Possibly related PRs

Suggested reviewers

  • evanpelle

Poem

🎮
When teams divide and players grow,
The lobby counts now ebb and flow.
With maps and modes and teams in mind,
The numbers match, the groups aligned.
No leftover, all fits just right—
Let every match begin tonight!
🟦🟩🟨🟧

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-01T04_57_21_208Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66e6bd1 and d8e471b.

📒 Files selected for processing (1)
  • src/core/configuration/DefaultConfig.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/configuration/DefaultConfig.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Deploy to openfront.dev

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 1, 2025

Walkthrough

The lobbyMaxPlayers method in the server configuration now accepts an optional numPlayerTeams parameter. This change updates its interface, implementation, and usage. The method now adjusts the maximum player count based on the number of teams, ensuring the count is a multiple of team numbers and capped per map.

Changes

Files / Areas Changed Summary
src/core/configuration/Config.ts Updated ServerConfig.lobbyMaxPlayers method signature to include optional numPlayerTeams parameter.
src/core/configuration/DefaultConfig.ts Modified DefaultServerConfig.lobbyMaxPlayers to use numPlayerTeams for adjusting player count logic.
src/server/MapPlaylist.ts Updated call to lobbyMaxPlayers to pass numPlayerTeams when in Team mode.

Sequence Diagram(s)

sequenceDiagram
    participant MapPlaylist
    participant Config
    participant DefaultServerConfig

    MapPlaylist->>Config: lobbyMaxPlayers(map, mode, numPlayerTeams)
    Config->>DefaultServerConfig: lobbyMaxPlayers(map, mode, numPlayerTeams)
    DefaultServerConfig-->>Config: returns adjusted max player count
    Config-->>MapPlaylist: returns max player count
Loading

Possibly related PRs

Suggested reviewers

  • evanpelle

Poem

🎮
Teams and maps, the numbers grow,
A cap adjusted, just so you know.
Players grouped, the logic clear,
Team counts now guide who can appear.
With every match, the limits bend—
To fairer games, onward we send!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-01T03_37_35_038Z-debug-0.log


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/server/MapPlaylist.ts (1)

48-49: Consider team size constraints when generating team count.

The random team generation (2-6 teams) works well, but you might want to consider the relationship between total expected players and team count to avoid very small teams.

For example, if the expected player count is low and you generate 6 teams, you could end up with teams of only 1-2 players each. Consider adding logic like:

const numPlayerTeams =
-  mode === GameMode.Team ? 2 + Math.floor(Math.random() * 5) : undefined;
+  mode === GameMode.Team 
+    ? Math.min(6, Math.max(2, 2 + Math.floor(Math.random() * 5)))
+    : undefined;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ea430f and 8735520.

📒 Files selected for processing (3)
  • src/core/configuration/Config.ts (1 hunks)
  • src/core/configuration/DefaultConfig.ts (1 hunks)
  • src/server/MapPlaylist.ts (1 hunks)
🔇 Additional comments (3)
src/server/MapPlaylist.ts (1)

54-54: LGTM! Clean parameter passing.

The updated method call correctly passes the new numPlayerTeams parameter and maintains backward compatibility.

src/core/configuration/Config.ts (1)

32-36: LGTM! Clean interface extension.

The method signature is properly updated with the optional numPlayerTeams parameter. The type number | undefined clearly expresses the intent and maintains backward compatibility.

src/core/configuration/DefaultConfig.ts (1)

146-150: LGTM! Clean method signature implementation.

The method signature correctly implements the interface with proper parameter typing and naming.

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Jun 1, 2025
Copy link
Collaborator

@evanpelle evanpelle left a comment

Choose a reason for hiding this comment

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

Thanks

@github-project-automation github-project-automation bot moved this from Development to Final Review in OpenFront Release Management Jun 2, 2025
@evanpelle evanpelle merged commit 9831461 into main Jun 2, 2025
10 checks passed
@evanpelle evanpelle deleted the team-size branch June 2, 2025 18:31
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Jun 2, 2025
1brucben pushed a commit that referenced this pull request Jun 3, 2025
## Description:

Ensure that team sizes are equal.

Closes #841

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

---------

Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Jun 3, 2025
5 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jul 7, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Minor balancing adjustment, mostly value changes, minor calculation changes.

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Teams are of unequal sizes

2 participants