[Protocol] Add shuffle players option and player order command/event

Adds a 'Shuffle players at start' option to game creation plus a local
player id on the game state so clients can reconcile seat changes, and a
SET_PLAYER_ORDER command (1206) with a PLAYER_ORDER_CHANGED event (2023)
so the game host can set or randomize the seating order.

Took 6 minutes
This commit is contained in:
Lukas Brübach 2026-08-04 22:51:03 +02:00
parent 44d5138181
commit a2657847ad
8 changed files with 47 additions and 0 deletions

View file

@ -66,6 +66,7 @@ set(PROTO_FILES
command_set_card_attr.proto
command_set_card_counter.proto
command_set_counter.proto
command_set_player_order.proto
command_set_playmat.proto
command_set_sideboard_lock.proto
command_set_sideboard_plan.proto
@ -110,6 +111,7 @@ set(PROTO_FILES
event_list_rooms.proto
event_move_card.proto
event_notify_user.proto
event_player_order_changed.proto
event_player_properties_changed.proto
event_remove_from_list.proto
event_remove_messages.proto

View file

@ -0,0 +1,15 @@
syntax = "proto2";
import "game_commands.proto";
message Command_SetPlayerOrder {
extend GameCommand {
optional Command_SetPlayerOrder ext = 1206;
}
// The desired seating order, expressed as player names. Only used when
// randomize is false.
repeated string player_names = 1;
// When set, the server shuffles the seating order instead of using
// player_names.
optional bool randomize = 2;
}

View file

@ -24,4 +24,9 @@ message Event_GameStateChanged {
// the amount of seconds since the game started
optional uint32 seconds_elapsed = 5;
// the id of the player this event is addressed to. Used to re-identify the
// local player after seats have been shuffled. Only set for events sent to
// a specific participant, never for omniscient/replay events.
optional sint32 local_player_id = 6;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "game_event.proto";
message Event_PlayerOrderChanged {
extend GameEvent {
optional Event_PlayerOrderChanged ext = 2023;
}
// The new seating order, expressed as player names.
repeated string player_names = 1;
// Whether the order was obtained by randomizing rather than set explicitly.
optional bool randomized = 2;
}

View file

@ -180,6 +180,11 @@ message GameCommand {
/// Server: Server_Player::cmdSetPlaymat
/// Client: reflected via player properties changed event
SET_PLAYMAT = 1035;
/// Set the seating (turn) order of the players.
/// Server: Server_AbstractParticipant::cmdSetPlayerOrder
/// Client: reflected via Event_PlayerOrderChanged
SET_PLAYER_ORDER = 1206;
}
extensions 100 to max;

View file

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

View file

@ -78,6 +78,9 @@ message Command_CreateGame {
// share decklists with all players when selected
optional bool share_decklists_on_load = 14;
// shuffle the player order (seats) before each game starts
optional bool shuffle_players = 15;
}
message Command_JoinGame {

View file

@ -48,6 +48,9 @@ message ServerInfo_Game {
// decklists are sent to all players when loaded
optional bool share_decklists_on_load = 15;
// players are shuffled into new seats before each game starts
optional bool shuffle_players = 16;
// the current player count
optional uint32 player_count = 30;