diff --git a/libcockatrice_protocol/libcockatrice/protocol/pb/CMakeLists.txt b/libcockatrice_protocol/libcockatrice/protocol/pb/CMakeLists.txt index 1164e1523..fd254a564 100644 --- a/libcockatrice_protocol/libcockatrice/protocol/pb/CMakeLists.txt +++ b/libcockatrice_protocol/libcockatrice/protocol/pb/CMakeLists.txt @@ -185,6 +185,7 @@ set(PROTO_FILES serverinfo_replay_match.proto serverinfo_report.proto serverinfo_room.proto + serverinfo_tournament.proto serverinfo_user.proto serverinfo_user_alt.proto serverinfo_user_session.proto diff --git a/libcockatrice_protocol/libcockatrice/protocol/pb/command_tournament.proto b/libcockatrice_protocol/libcockatrice/protocol/pb/command_tournament.proto index ee958f587..f465ed6f7 100644 --- a/libcockatrice_protocol/libcockatrice/protocol/pb/command_tournament.proto +++ b/libcockatrice_protocol/libcockatrice/protocol/pb/command_tournament.proto @@ -1,6 +1,6 @@ syntax = "proto2"; import "game_commands.proto"; -import "event_tournament_state.proto"; +import "serverinfo_tournament.proto"; message Command_ReportMatchResult { extend GameCommand { @@ -8,7 +8,12 @@ message Command_ReportMatchResult { } optional sint32 game_id = 1 [default = -1]; + // The winning player's ID. A drawn match is reported with is_draw set and + // winner_id left unset so a missing report stays distinguishable from a + // reported draw via has_winner_id(). optional sint32 winner_id = 2 [default = -1]; + // Whether the match ended in a draw; winner_id is meaningless then. + optional bool is_draw = 3; } message Command_AdvanceTournament { @@ -23,4 +28,4 @@ message Command_TournamentSettingsSelect { } optional TournamentSettings settings = 1; -} +} \ No newline at end of file diff --git a/libcockatrice_protocol/libcockatrice/protocol/pb/event_tournament_state.proto b/libcockatrice_protocol/libcockatrice/protocol/pb/event_tournament_state.proto index 5fb003f50..cfaaa6f01 100644 --- a/libcockatrice_protocol/libcockatrice/protocol/pb/event_tournament_state.proto +++ b/libcockatrice_protocol/libcockatrice/protocol/pb/event_tournament_state.proto @@ -1,27 +1,6 @@ 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]; -} +import "serverinfo_tournament.proto"; message Event_TournamentState { extend GameEvent { @@ -40,4 +19,4 @@ message Event_TournamentState { repeated TournamentPlayer players = 4; repeated TournamentPairing pairings = 5; optional TournamentSettings settings = 6; -} +} \ No newline at end of file diff --git a/libcockatrice_protocol/libcockatrice/protocol/pb/room_commands.proto b/libcockatrice_protocol/libcockatrice/protocol/pb/room_commands.proto index bf4d5310f..e2f46e338 100644 --- a/libcockatrice_protocol/libcockatrice/protocol/pb/room_commands.proto +++ b/libcockatrice_protocol/libcockatrice/protocol/pb/room_commands.proto @@ -1,4 +1,5 @@ syntax = "proto2"; +import "serverinfo_tournament.proto"; message RoomCommand { enum RoomCommandType { LEAVE_ROOM = 1000; @@ -70,8 +71,8 @@ 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]; + // tournament settings shared by game creation and mid-game changes + optional TournamentSettings tournament_settings = 15; // whether this is a tournament game optional bool is_tournament = 16; diff --git a/libcockatrice_protocol/libcockatrice/protocol/pb/serverinfo_tournament.proto b/libcockatrice_protocol/libcockatrice/protocol/pb/serverinfo_tournament.proto new file mode 100644 index 000000000..217967ff8 --- /dev/null +++ b/libcockatrice_protocol/libcockatrice/protocol/pb/serverinfo_tournament.proto @@ -0,0 +1,32 @@ +syntax = "proto2"; + +// Player-entered tournament metadata as shown in the standings and bracket views. +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; +} + +// A single match pairing within a tournament round. +message TournamentPairing { + optional sint32 player1_id = 1; + // -1 when the pairing is a bye. + optional sint32 player2_id = 2 [default = -1]; + optional sint32 game_id = 3; + // The winning player's ID, or -1 when the match ended in a draw (is_draw). + // An unset field reads back as -1 too; has_winner_id() distinguishes those. + optional sint32 winner_id = 4 [default = -1]; + optional uint32 player1_match_wins = 5; + optional uint32 player2_match_wins = 6; + // Whether the match ended in a draw; winner_id is meaningless then. + optional bool is_draw = 7; +} + +// Settings governing all matches of a tournament. +message TournamentSettings { + // Number of games per match (e.g. 3 for best of 3). + optional uint32 games_per_match = 1 [default = 1]; +} \ No newline at end of file