[Protocol] Add tournament state event and tournament game commands

Adds the protocol layer for the tournament game mode:
- Event_TournamentState (2027) carrying phase, round counters, player
  standings, pairings, and settings (games_per_match)
- Command_ReportMatchResult / Command_AdvanceTournament /
  Command_TournamentSettingsSelect game command extensions (1037-1039)
- is_tournament flag on Command_CreateGame and ServerInfo_Game;
  is_tournament and parent_game_id on Event_GameStateChanged


Took 13 minutes
This commit is contained in:
Lukas Brübach 2026-08-24 08:43:46 +02:00 committed by GitHub
parent 048fe247f4
commit e82b311c8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 96 additions and 0 deletions

View file

@ -60,6 +60,7 @@ set(PROTO_FILES
command_set_sideboard_lock.proto
command_set_sideboard_plan.proto
command_shuffle.proto
command_tournament.proto
command_undo_draw.proto
commands.proto
context_concede.proto
@ -117,6 +118,7 @@ set(PROTO_FILES
event_set_card_counter.proto
event_set_counter.proto
event_shuffle.proto
event_tournament_state.proto
event_user_joined.proto
event_user_left.proto
event_user_message.proto

View file

@ -0,0 +1,26 @@
syntax = "proto2";
import "game_commands.proto";
import "event_tournament_state.proto";
message Command_ReportMatchResult {
extend GameCommand {
optional Command_ReportMatchResult ext = 1037;
}
optional sint32 game_id = 1 [default = -1];
optional sint32 winner_id = 2 [default = -1];
}
message Command_AdvanceTournament {
extend GameCommand {
optional Command_AdvanceTournament ext = 1038;
}
}
message Command_TournamentSettingsSelect {
extend GameCommand {
optional Command_TournamentSettingsSelect ext = 1039;
}
optional TournamentSettings settings = 1;
}

View file

@ -24,4 +24,10 @@ message Event_GameStateChanged {
// the amount of seconds since the game started
optional uint32 seconds_elapsed = 5;
// whether this game is a tournament game
optional bool is_tournament = 9;
// for tournament sub-games: the ID of the parent tournament game (-1 if not a sub-game)
optional sint32 parent_game_id = 10 [default = -1];
}

View file

@ -0,0 +1,43 @@
syntax = "proto2";
import "game_event.proto";
message TournamentPlayer {
optional sint32 player_id = 1;
optional string player_name = 2;
optional uint32 wins = 3;
optional uint32 losses = 4;
optional uint32 draws = 5;
optional bool deck_submitted = 6;
}
message TournamentPairing {
optional sint32 player1_id = 1;
optional sint32 player2_id = 2 [default = -1];
optional sint32 game_id = 3;
optional sint32 winner_id = 4 [default = -1];
optional sint32 player1_match_wins = 5 [default = 0];
optional sint32 player2_match_wins = 6 [default = 0];
}
message TournamentSettings {
optional uint32 games_per_match = 1 [default = 1];
}
message Event_TournamentState {
extend GameEvent {
optional Event_TournamentState ext = 2027;
}
enum TournamentPhase {
PHASE_DECK_BUILDING = 0;
PHASE_PLAYING = 1;
PHASE_FINISHED = 2;
}
optional TournamentPhase phase = 1;
optional uint32 current_round = 2;
optional uint32 total_rounds = 3;
repeated TournamentPlayer players = 4;
repeated TournamentPairing pairings = 5;
optional TournamentSettings settings = 6;
}

View file

@ -180,6 +180,15 @@ message GameCommand {
/// Server: Server_Player::cmdSetPlaymat
/// Client: reflected via player properties changed event
SET_PLAYMAT = 1035;
/// Report the result of a tournament match sub-game.
REPORT_MATCH_RESULT = 1037;
/// Advance the tournament to the next round.
ADVANCE_TOURNAMENT = 1038;
/// Select tournament settings.
TOURNAMENT_SETTINGS_SELECT = 1039;
}
extensions 100 to max;

View file

@ -34,6 +34,7 @@ message GameEvent {
CHANGE_ZONE_PROPERTIES = 2020;
REVERSE_TURN = 2021;
GAME_LOG_NOTICE = 2022;
TOURNAMENT_STATE = 2027;
}
optional sint32 player_id = 1 [default = -1];
extensions 100 to max;

View file

@ -69,6 +69,12 @@ message Command_CreateGame {
// share decklists with all players when selected
optional bool share_decklists_on_load = 14;
// number of games per match in tournament mode (e.g. 3 for best of 3)
optional uint32 games_per_match = 15 [default = 1];
// whether this is a tournament game
optional bool is_tournament = 16;
}
message Command_JoinGame {

View file

@ -65,4 +65,7 @@ message ServerInfo_Game {
// the current host of the game, which may differ from the creator after a host transfer
optional ServerInfo_User host_info = 53;
// whether this game is a tournament game
optional bool is_tournament = 54;
}