Cockatrice/libcockatrice_protocol/libcockatrice/protocol/pb/game_commands.proto
BruebachL 5ea16c805f
[Server/Client/Protocol] Shuffle or reorder player seats before a game starts (#7398)
* [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

* [Server] Shuffle and reorder player seats before a game starts

Auto-shuffles the seats at game start when enabled (now for games with
two or more players instead of three or more) and handles the new
SET_PLAYER_ORDER command so the game host or a moderator can reorder or
randomize the seats before the game starts. Re-seating re-keys the
player ids while keeping the per-user game/seat routing and persistent
player records in sync, then broadcasts the new order to everyone.

* [Client] Add shuffle players option and turn order dialog

Adds the 'Shuffle players at start' checkbox to game creation and a
host-only 'Set turn order...' action that opens a dialog to reorder or
randomize the seats before the game starts. Seating changes are shown in
the game's message log.

* [Client] Move the turn order dialog strings into retranslateUi

Follows the DlgInviteToGame convention so the dialog can be retranslated
instead of freezing its strings at construction time.

* [Server] Keep player ids stable across seat shuffles

* [Client] Lay out table and turn order dialog in seat order

* [Server] Send game-joined player list in seat order

* [Client] Reword the shuffle option to match its behaviour

* [Client] Address the seat-order review comments

- Give the game setup checkboxes a row of their own so they no longer
  collide in the create-game dialog
- Rename DlgTurnOrder::randomize() to isRandomizeRequested()
- Document what the ids in GameState::seatOrder mean
- Keep "Set turn order..." in sync with the game: hidden for non-hosts
  and once the game has started, re-shown when the game ends or hosting
  moves to the local player (new GameState::hostChanged signal)

* [Client] Do not preview a randomized turn order

Randomizing is a request to the server, not a local shuffle. Shuffling the
list locally meant the dialog showed an order the server then discarded, and
let the host re-open it until a favourable order appeared. The dialog now
switches to a mode that says the server will randomize and toggles back to the
manual list on request.

* [Client] Let moderators set the turn order

The server accepts SET_PLAYER_ORDER from the host or a moderator, but the
client hid the action from everyone except the host, making the moderator
branch unreachable. Visibility and the handler now share canSetTurnOrder().

* [Server] Rely on the player order event instead of a full state resend

cmdSetPlayerOrder re-sent the whole game state after reseating, so every
client reloaded its deck view mid-lobby for no reason. The new seating reaches
clients through the Event_PlayerOrderChanged that reseatPlayers broadcasts.

* [Client] Show random turn order in the game selector

The restrictions column listed "open decklists" but not the new seating
option, so a joining player had no way to see that seats will be randomized
each game. Game info already shows the disabled checkbox.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-11-04 15:44:50 +01:00

207 lines
7.2 KiB
Protocol Buffer

syntax = "proto2";
/// Commands that are sent during a game to change the game state
message GameCommand {
/// Identifies the concrete game command to execute
enum GameCommandType {
/// Kick a player from the game.
/// Server: Server_AbstractParticipant::cmdKickFromGame
/// Client: reflected via game state events
KICK_FROM_GAME = 1000;
/// Leave the current game voluntarily.
/// Server: Server_AbstractParticipant::cmdLeaveGame
/// Client: reflected via game state events
LEAVE_GAME = 1001;
/// Send an in-game chat message.
/// Server: Server_AbstractParticipant::cmdGameSay
/// Client: PlayerEventHandler::eventGameSay
GAME_SAY = 1002;
/// Shuffle a zone (typically the library).
/// Server: Server_Player::cmdShuffle
/// Client: PlayerEventHandler::eventShuffle
SHUFFLE = 1003;
/// Take a mulligan at game start.
/// Server: Server_Player::cmdMulligan
/// Client: reflected via game state events
MULLIGAN = 1004;
/// Roll one or more dice.
/// Server: Server_AbstractPlayer::cmdRollDie
/// Client: PlayerEventHandler::eventRollDie
ROLL_DIE = 1005;
/// Draw cards from the deck.
/// Server: Server_Player::cmdDrawCards
/// Client: PlayerEventHandler::eventDrawCards
DRAW_CARDS = 1006;
/// Undo a previous draw action.
/// Server: Server_Player::cmdUndoDraw
/// Client: PlayerEventHandler::eventMoveCard (Context_UndoDraw)
UNDO_DRAW = 1007;
/// Flip a card face up or face down.
/// Server: Server_AbstractPlayer::cmdFlipCard
/// Client: PlayerEventHandler::eventFlipCard
FLIP_CARD = 1008;
/// Attach one card to another.
/// Server: Server_AbstractPlayer::cmdAttachCard
/// Client: PlayerEventHandler::eventAttachCard
ATTACH_CARD = 1009;
/// Create a token card.
/// Server: Server_AbstractPlayer::cmdCreateToken
/// Client: PlayerEventHandler::eventCreateToken
CREATE_TOKEN = 1010;
/// Create a visual arrow between objects.
/// Server: Server_AbstractPlayer::cmdCreateArrow
/// Client: PlayerEventHandler::eventCreateArrow
CREATE_ARROW = 1011;
/// Delete a visual arrow.
/// Server: Server_AbstractPlayer::cmdDeleteArrow
/// Client: PlayerEventHandler::eventDeleteArrow
DELETE_ARROW = 1012;
/// Set a card attribute (e.g. tapped, flipped).
/// Server: Server_AbstractPlayer::cmdSetCardAttr
/// Client: PlayerEventHandler::eventSetCardAttr
SET_CARD_ATTR = 1013;
/// Set a counter value on a card.
/// Server: Server_AbstractPlayer::cmdSetCardCounter
/// Client: PlayerEventHandler::eventSetCardCounter
SET_CARD_COUNTER = 1014;
/// Increment a counter on a card.
/// Server: Server_AbstractPlayer::cmdIncCardCounter
/// Client: PlayerEventHandler::eventSetCardCounter
INC_CARD_COUNTER = 1015;
/// Mark the player as ready to start the game.
/// Server: Server_AbstractPlayer::cmdReadyStart
/// Client: reflected via game state events
READY_START = 1016;
/// Concede the game.
/// Server: Server_AbstractPlayer::cmdConcede
/// Client: reflected via game state events
CONCEDE = 1017;
/// Increment a global (non-card) counter.
/// Server: Server_Player::cmdIncCounter
/// Client: PlayerEventHandler::eventSetCounter
INC_COUNTER = 1018;
/// Create a new global counter.
/// Server: Server_Player::cmdCreateCounter
/// Client: PlayerEventHandler::eventCreateCounter
CREATE_COUNTER = 1019;
/// Set a global counter value.
/// Server: Server_Player::cmdSetCounter
/// Client: PlayerEventHandler::eventSetCounter
SET_COUNTER = 1020;
/// Delete a global counter.
/// Server: Server_Player::cmdDelCounter
/// Client: PlayerEventHandler::eventDelCounter
DEL_COUNTER = 1021;
/// Advance to the next turn.
/// Server: Server_Player::cmdNextTurn
/// Client: reflected via active player / phase events
NEXT_TURN = 1022;
/// Set the active phase of the turn.
/// Server: Server_Player::cmdSetActivePhase
/// Client: reflected via game state events
SET_ACTIVE_PHASE = 1023;
/// Dump the contents of a zone.
/// Server: Server_AbstractPlayer::cmdDumpZone
/// Client: PlayerEventHandler::eventDumpZone
DUMP_ZONE = 1024;
/// Reveal specific cards to players.
/// Server: Server_AbstractPlayer::cmdRevealCards
/// Client: PlayerEventHandler::eventRevealCards
REVEAL_CARDS = 1026;
/// Move a card between zones.
/// Server: Server_AbstractPlayer::cmdMoveCard
/// Client: PlayerEventHandler::eventMoveCard
MOVE_CARD = 1027;
/// Set the sideboard plan for the game.
/// Server: Server_Player::cmdSetSideboardPlan
/// Client: not forwarded as a game event
SET_SIDEBOARD_PLAN = 1028;
/// Select a deck for the game.
/// Server: Server_Player::cmdDeckSelect
/// Client: reflected via lobby / game state
DECK_SELECT = 1029;
/// Lock or unlock sideboarding.
/// Server: Server_Player::cmdSetSideboardLock
/// Client: reflected via game state
SET_SIDEBOARD_LOCK = 1030;
/// Change zone properties (visibility, reveal-top, etc.).
/// Server: Server_Player::cmdChangeZoneProperties
/// Client: PlayerEventHandler::eventChangeZoneProperties
CHANGE_ZONE_PROPERTIES = 1031;
/// Undo a previous concede.
/// Server: Server_AbstractPlayer::cmdUnconcede
/// Client: reflected via game state
UNCONCEDE = 1032;
/// Execute a command on behalf of another player.
/// Server: Server_AbstractParticipant::cmdJudge
/// Client: transparent (wrapped commands handled normally)
JUDGE = 1033;
/// Reverse the current turn order.
/// Server: Server_Player::cmdReverseTurn
/// Client: reflected via subsequent turn events
REVERSE_TURN = 1034;
/// Set the player's playmat independently of the deck.
/// 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;
}
/// A wrapper around a normal game command that allows a privileged user
/// to send a command on behalf of another player.
message Command_Judge {
extend GameCommand {
/// Judge command extension payload
optional Command_Judge ext = 1033;
}
/// The player on whose behalf this command is sent.
optional sint32 target_id = 1 [default = -1];
/// One or more wrapped game commands to execute.
repeated GameCommand game_command = 2;
}