![]() |
Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
|
Central dispatcher for game-wide commands and events. More...
#include <game_event_handler.h>
Public Slots | |
Command dispatch slots | |
Low-level command transmission. | |
| void | sendGameCommand (PendingCommand *pend, int playerId=-1) |
| Send a prepared PendingCommand. | |
| void | sendGameCommand (const ::google::protobuf::Message &command, int playerId=-1) |
| Send a single protobuf command. | |
| void | commandFinished (const Response &response) |
| Called when a PendingCommand finishes execution. | |
Signals | |
Core state signals | |
| void | emitUserEvent () |
| void | containerProcessingStarted (GameEventContext context) |
| void | containerProcessingDone () |
| void | gameFlooded () |
| void | setContextJudgeName (QString judgeName) |
Player and spectator signals | |
| void | addPlayerToAutoCompleteList (QString playerName) |
| void | localPlayerDeckSelected (PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo) |
| void | remotePlayerDeckSelected (QString deckList, int playerId, QString playerName) |
| void | remotePlayersDecksSelected (QVector< QPair< int, QPair< QString, QString > > > opponentDecks) |
| void | localPlayerSideboardLocked (int playerId, bool sideboardLocked) |
| void | localPlayerReadyStateChanged (int playerId, bool ready) |
Game flow signals | |
| void | gameStopped () |
| void | gameClosed () |
| void | playerPropertiesChanged (const ServerInfo_PlayerProperties &prop, int playerId) |
| void | playerJoined (const ServerInfo_PlayerProperties &playerInfo) |
| void | playerLeft (int leavingPlayerId) |
| void | playerKicked () |
| void | spectatorJoined (const ServerInfo_PlayerProperties &spectatorInfo) |
| void | spectatorLeft (int leavingSpectatorId) |
| void | arrowDeleted (int creatorId, int arrowId) |
Logging signals | |
Signals consumed by MessageLogWidget. | |
| void | logSpectatorSay (ServerInfo_User userInfo, QString message) |
| void | logSpectatorLeave (QString name, QString reason) |
| void | logGameStart () |
| void | logReadyStart (PlayerLogic *player) |
| void | logNotReadyStart (PlayerLogic *player) |
| void | logDeckSelect (PlayerLogic *player, QString deckHash, int sideboardSize) |
| void | logSideboardLockSet (PlayerLogic *player, bool sideboardLocked) |
| void | logConnectionStateChanged (PlayerLogic *player, bool connected) |
| void | logJoinSpectator (QString spectatorName) |
| void | logJoinPlayer (PlayerLogic *player) |
| void | logLeave (PlayerLogic *player, QString reason) |
| void | logKicked () |
| void | logTurnReversed (PlayerLogic *player, bool reversed) |
| void | logGameClosed () |
| void | logActivePlayer (PlayerLogic *activePlayer) |
| void | logActivePhaseChanged (int activePhase) |
| void | logConcede (int playerId) |
| void | logUnconcede (int playerId) |
Public Member Functions | |
Construction | |
Lifecycle and ownership. | |
| GameEventHandler (AbstractGame *_game) | |
| Construct a GameEventHandler. | |
Outgoing game commands | |
Commands initiated locally and sent to the server. These methods construct and send protobuf commands corresponding to user actions in the UI. | |
| void | handleNextTurn () |
| Request advancing the game to the next turn. | |
| void | handleReverseTurn () |
| Request reversing the current turn order. | |
| void | handleActiveLocalPlayerConceded () |
| Concede the game for the currently active local player. | |
| void | handleActiveLocalPlayerUnconceded () |
| Undo a previous concede for the active local player. | |
| void | handleActivePhaseChanged (int phase) |
| Set the active phase of the game. | |
| void | handleGameLeft () |
| Leave the current game session. | |
| void | handleChatMessageSent (const QString &chatMessage) |
| Send a chat message to all players and spectators. | |
| void | handleArrowDeletion (int creatorId, int arrowId) |
| Delete an existing arrow. | |
| void | handleArrowDeletionFinished (const Response &response, int creatorId, int arrowId) |
Incoming event processing | |
Entry points for server-sent events. | |
| void | processGameEventContainer (const GameEventContainer &cont, AbstractClient *client, EventProcessingOptions options) |
| Process a container of game events received from the server. | |
Command preparation helpers | |
Internal helpers for building command containers. | |
| PendingCommand * | prepareGameCommand (const ::google::protobuf::Message &cmd) |
| Wrap a single protobuf command in a PendingCommand. | |
| PendingCommand * | prepareGameCommand (const QList< const ::google::protobuf::Message * > &cmdList) |
| Wrap multiple protobuf commands in a single PendingCommand. | |
Spectator event handlers | |
Events originating from spectators. | |
| void | eventSpectatorSay (const Event_GameSay &event, int eventPlayerId, const GameEventContext &context) |
| Handle a spectator chat message. | |
| void | eventSpectatorLeave (const Event_Leave &event, int eventPlayerId, const GameEventContext &context) |
| Handle a spectator leaving the game. | |
Game state event handlers | |
Events that affect global game state. | |
| void | eventGameStateChanged (const Event_GameStateChanged &event, int eventPlayerId, const GameEventContext &context) |
| Handle a full game state update from the server. | |
| void | processCardAttachmentsForPlayers (const Event_GameStateChanged &event) |
| Update card attachment relationships for all players. | |
| void | eventGameHostChanged (const Event_GameHostChanged &event, int eventPlayerId, const GameEventContext &context) |
| Handle a change in game host. | |
| void | eventGameClosed (const Event_GameClosed &event, int eventPlayerId, const GameEventContext &context) |
| Handle the game being closed by the server. | |
| void | eventSetActivePlayer (const Event_SetActivePlayer &event, int eventPlayerId, const GameEventContext &context) |
| Handle a change of the active player. | |
| void | eventSetActivePhase (const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context) |
| Handle a change of the active phase. | |
| void | eventReverseTurn (const Event_ReverseTurn &event, int eventPlayerId, const GameEventContext &context) |
| Handle a turn reversal event. | |
| void | eventPing (const Event_Ping &event, int eventPlayerId, const GameEventContext &context) |
| Handle ping / latency updates. | |
Player lifecycle and property handlers | |
Events related to players joining, leaving, or changing state. | |
| void | eventPlayerPropertiesChanged (const Event_PlayerPropertiesChanged &event, int eventPlayerId, const GameEventContext &context) |
| Handle updates to a player's properties. | |
| void | eventJoin (const Event_Join &event, int eventPlayerId, const GameEventContext &context) |
| Handle a player or spectator joining the game. | |
| void | eventLeave (const Event_Leave &event, int eventPlayerId, const GameEventContext &context) |
| Handle a player leaving the game. | |
| void | eventKicked (const Event_Kicked &event, int eventPlayerId, const GameEventContext &context) |
| Handle the local player being kicked from the game. | |
| QString | getLeaveReason (Event_Leave::LeaveReason reason) |
| Convert a leave reason enum to a human-readable string. | |
Private Attributes | |
| AbstractGame * | game |
Central dispatcher for game-wide commands and events.
This class owns no game state itself. Instead, it:
|
explicit |
Construct a GameEventHandler.
The handler is owned by the AbstractGame instance and uses it to access the game state, players, and network clients.
| _game | Owning game instance (also used as QObject parent). |
|
signal |
|
signal |
|
slot |
Called when a PendingCommand finishes execution.
Used to detect server-side errors such as chat flood protection.
|
signal |
|
signal |
|
signal |
| void GameEventHandler::eventGameClosed | ( | const Event_GameClosed & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle the game being closed by the server.
| void GameEventHandler::eventGameHostChanged | ( | const Event_GameHostChanged & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a change in game host.
| void GameEventHandler::eventGameStateChanged | ( | const Event_GameStateChanged & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a full game state update from the server.
Used during game startup, reconnection, and resynchronization.
| void GameEventHandler::eventJoin | ( | const Event_Join & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a player or spectator joining the game.
| void GameEventHandler::eventKicked | ( | const Event_Kicked & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle the local player being kicked from the game.
| void GameEventHandler::eventLeave | ( | const Event_Leave & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a player leaving the game.
| void GameEventHandler::eventPing | ( | const Event_Ping & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle ping / latency updates.
| void GameEventHandler::eventPlayerPropertiesChanged | ( | const Event_PlayerPropertiesChanged & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle updates to a player's properties.
Includes readiness, concede state, deck selection, sideboard lock, and connection state changes.
| void GameEventHandler::eventReverseTurn | ( | const Event_ReverseTurn & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a turn reversal event.
| void GameEventHandler::eventSetActivePhase | ( | const Event_SetActivePhase & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a change of the active phase.
| void GameEventHandler::eventSetActivePlayer | ( | const Event_SetActivePlayer & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a change of the active player.
| void GameEventHandler::eventSpectatorLeave | ( | const Event_Leave & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a spectator leaving the game.
| void GameEventHandler::eventSpectatorSay | ( | const Event_GameSay & | event, |
| int | eventPlayerId, | ||
| const GameEventContext & | context ) |
Handle a spectator chat message.
|
signal |
|
signal |
|
signal |
| QString GameEventHandler::getLeaveReason | ( | Event_Leave::LeaveReason | reason | ) |
Convert a leave reason enum to a human-readable string.
| void GameEventHandler::handleActiveLocalPlayerConceded | ( | ) |
Concede the game for the currently active local player.
| void GameEventHandler::handleActiveLocalPlayerUnconceded | ( | ) |
Undo a previous concede for the active local player.
| void GameEventHandler::handleActivePhaseChanged | ( | int | phase | ) |
Set the active phase of the game.
Typically triggered by the active player selecting a new phase.
| phase | Phase identifier. |
| void GameEventHandler::handleArrowDeletion | ( | int | creatorId, |
| int | arrowId ) |
Delete an existing arrow.
| arrowId | Unique identifier of the arrow to delete. |
| void GameEventHandler::handleArrowDeletionFinished | ( | const Response & | response, |
| int | creatorId, | ||
| int | arrowId ) |
| void GameEventHandler::handleChatMessageSent | ( | const QString & | chatMessage | ) |
Send a chat message to all players and spectators.
| chatMessage | Message text. |
| void GameEventHandler::handleGameLeft | ( | ) |
Leave the current game session.
| void GameEventHandler::handleNextTurn | ( | ) |
Request advancing the game to the next turn.
| void GameEventHandler::handleReverseTurn | ( | ) |
Request reversing the current turn order.
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
| PendingCommand * GameEventHandler::prepareGameCommand | ( | const ::google::protobuf::Message & | cmd | ) |
Wrap a single protobuf command in a PendingCommand.
| cmd | Protobuf command message. |
| PendingCommand * GameEventHandler::prepareGameCommand | ( | const QList< const ::google::protobuf::Message * > & | cmdList | ) |
Wrap multiple protobuf commands in a single PendingCommand.
Ownership of the messages in cmdList is transferred to the handler.
| cmdList | List of protobuf command messages. |
| void GameEventHandler::processCardAttachmentsForPlayers | ( | const Event_GameStateChanged & | event | ) |
Update card attachment relationships for all players.
Called after a game state update to ensure attachments are resolved consistently across all zones.
| void GameEventHandler::processGameEventContainer | ( | const GameEventContainer & | cont, |
| AbstractClient * | client, | ||
| EventProcessingOptions | options ) |
Process a container of game events received from the server.
This is the main dispatch function for incoming game events. Events are routed to spectator handlers, game-level handlers, or forwarded to PlayerEventHandler instances as appropriate.
| cont | Game event container from the server. |
| client | Client that received the container. |
| options | Processing flags (e.g. silent, replay). |
|
signal |
|
signal |
|
slot |
Send a single protobuf command.
| command | Protobuf command message. |
| playerId | Player whose client should send the command. |
|
slot |
Send a prepared PendingCommand.
| pend | Pending command to send. |
| playerId | Player whose client should send the command. |
|
signal |
|
signal |
|
signal |
|
private |
Pointer to the owning game instance.