![]() |
Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
|
GameEventHandler is the central coordinator for game-wide commands and events. It acts as the bridge between the networking layer (protobuf messages received from the server) and the local game model and UI.
Unlike PlayerEventHandler, which is responsible for player-scoped state and zones, GameEventHandler handles:
In short, it is the top-level event dispatcher for an active game.
GameEventHandler has four primary responsibilities:
UI actions that affect the game as a whole (e.g. advancing the turn, changing phases, sending chat messages) are translated into protobuf commands and sent to the server via this class.
Examples include:
These commands are wrapped in PendingCommand instances so their lifecycle and responses can be tracked.
Incoming server messages arrive as a GameEventContainer. GameEventHandler is responsible for:
This design keeps networking concerns isolated from game logic and UI code.
Certain events affect the entire game state and require coordinated updates across multiple subsystems. Examples include:
GameEventHandler ensures these events are processed in a consistent order and that all interested systems are notified via Qt signals.
Rather than directly manipulating UI widgets, GameEventHandler emits high-level signals that are consumed by:
This keeps the handler independent of concrete UI implementations.
GameEventHandler and PlayerEventHandler work together but have distinct roles:
| GameEventHandler | PlayerEventHandler |
|---|---|
| Global game state | Per-player state |
| Turn / phase flow | Zones and cards |
| Player join/leave | Player actions |
| Spectator events | Player-specific events |
| Chat dispatch | Card and zone updates |
When a server event is associated with a specific player, GameEventHandler routes it to the corresponding PlayerEventHandler. Events without a player context are handled directly.
A typical incoming event flow looks like this:
This structured flow makes it easy to:
Outgoing commands follow a similar structured path:
This approach avoids duplicated error handling across UI code.
GameEventHandler is designed to be:
GameEventHandler is the central coordinator for game-wide commands and events. It acts as the bridge between the networking layer (protobuf messages received from the server) and the local game model and UI.
Unlike PlayerEventHandler, which is responsible for player-scoped state and zones, GameEventHandler handles:
In short, it is the top-level event dispatcher for an active game.
GameEventHandler has four primary responsibilities:
UI actions that affect the game as a whole (e.g. advancing the turn, changing phases, sending chat messages) are translated into protobuf commands and sent to the server via this class.
Examples include:
These commands are wrapped in PendingCommand instances so their lifecycle and responses can be tracked.
Incoming server messages arrive as a GameEventContainer. GameEventHandler is responsible for:
This design keeps networking concerns isolated from game logic and UI code.
Certain events affect the entire game state and require coordinated updates across multiple subsystems. Examples include:
GameEventHandler ensures these events are processed in a consistent order and that all interested systems are notified via Qt signals.
Rather than directly manipulating UI widgets, GameEventHandler emits high-level signals that are consumed by:
This keeps the handler independent of concrete UI implementations.
GameEventHandler and PlayerEventHandler work together but have distinct roles:
| GameEventHandler | PlayerEventHandler |
|---|---|
| Global game state | Per-player state |
| Turn / phase flow | Zones and cards |
| Player join/leave | Player actions |
| Spectator events | Player-specific events |
| Chat dispatch | Card and zone updates |
When a server event is associated with a specific player, GameEventHandler routes it to the corresponding PlayerEventHandler. Events without a player context are handled directly.
A typical incoming event flow looks like this:
This structured flow makes it easy to:
Outgoing commands follow a similar structured path:
This approach avoids duplicated error handling across UI code.
GameEventHandler is designed to be: