A C++ application that acts as a bridge between a Team Fortress 2 MGE server plugin and the Challonge tournament platform, enabling fully automated tournaments.
This project is a modernized C++ replication of an older Rust-based system, featuring an improved communication protocol and robust testing tools.
The manager operates with two primary WebSocket connections:
- WebSocket Server (Admin UI): It hosts a server on port
8080that serves a web-based admin dashboard for starting and stopping tournaments. - WebSocket Client (MGE Plugin): It actively connects as a client to a WebSocket server provided by the MGE game server plugin (expected on port
9001) to receive player data and send match commands.
- Real-time tournament management via the Challonge v1 API.
- Connects to an MGE server plugin to manage players and matches.
- Web-based admin dashboard for tournament control.
- Automatic match assignment to arenas based on a priority list.
- ELO-based seeding for initial player ranking in the tournament.
- Includes a Python-based mock MGE server for easy testing and development.
This project uses CMake.
# Clone the repository
git clone <your-repo-url>
cd mge-tournament-cpp
# Create build directory
mkdir build && cd build
# Configure and build
cmake ..
cmake --build .- Challonge API Key: Create a file named
api_key.txtin the executable's directory and place your Challonge API key inside it. - Challonge Username: In
tournament_manager.cpp, update theChallongeAPIconstructor with your Challonge username.
You need to run two components: the MGE server (or the mock server) and the tournament manager.
The mock server simulates the TF2 game server plugin, allowing you to test the full tournament flow.
# Make sure you have Python 3 and the websockets library
pip install websockets
# Run the mock server
python3 mock_mge_server.pyThe mock server will start and wait for a connection on ws://localhost:9001.
The manager requires the URL slug of a pre-created Challonge tournament as a command-line argument.
./build/mge_tournament <your_challonge_tournament_url>Example: ./build/mge_tournament my_weekly_cup_42
The manager will start, connect to the mock server, and host the admin panel.
Open a web browser and navigate to http://localhost:8080. From here, you can start and stop the tournament.
- Endpoint:
ws://localhost:8080(protocol istf2serverep) - Direction: Admin UI connects to the manager.
- Purpose: Receives commands like
TournamentStartandTournamentStopfrom the admin.
- Endpoint:
ws://localhost:9001(or your configured game server IP/port) - Direction: The manager connects to the MGE server plugin.
- Purpose:
- Sends commands like
get_playersandadd_player_to_arena. - Receives events like
match_end_1v1and responses with player data.
- Sends commands like
All messages use a JSON format:
{
"type": "MessageType",
"payload": {
/* ... message data ... */
}
}- libwebsockets
- libcurl
- nlohmann-json (handled automatically via CMake's FetchContent)
- CMake (for building)
MIT