[Client] Add tournament event plumbing and player extension points

Wires the client game layer for tournament state without touching
existing behavior:
- GameEventHandler dispatches Event_TournamentState (2027) to a new
  tournamentStateChanged signal
- GameMetaInfo exposes isTournament and parentGameId over the new
  ServerInfo_Game field
- PlayerEventHandler::processGameEvent is virtual and player is
  protected; PlayerLogic gains a protected constructor accepting a
  custom handler, so mode-specific subclasses can intercept events
This commit is contained in:
Lukas Brübach 2026-08-24 09:07:11 +02:00 committed by GitHub
parent de03428e51
commit 2d5734de21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 6 deletions

View file

@ -26,6 +26,7 @@
#include <libcockatrice/protocol/pb/event_reverse_turn.pb.h>
#include <libcockatrice/protocol/pb/event_set_active_phase.pb.h>
#include <libcockatrice/protocol/pb/event_set_active_player.pb.h>
#include <libcockatrice/protocol/pb/event_tournament_state.pb.h>
#include <libcockatrice/protocol/pb/game_event_container.pb.h>
#include <libcockatrice/protocol/pending_command.h>
@ -158,6 +159,9 @@ void GameEventHandler::processGameEventContainer(const GameEventContainer &cont,
case GameEvent::REVERSE_TURN:
eventReverseTurn(event.GetExtension(Event_ReverseTurn::ext), playerId, context);
break;
case GameEvent::TOURNAMENT_STATE:
emit tournamentStateChanged(event.GetExtension(Event_TournamentState::ext));
break;
default: {
PlayerLogic *player = game->getPlayerManager()->getPlayers().value(playerId, 0);
@ -263,6 +267,12 @@ void GameEventHandler::eventGameStateChanged(const Event_GameStateChanged &event
int /*eventPlayerId*/,
const GameEventContext & /*context*/)
{
// Sub-games of a tournament report their parent hub game so the client can
// route "close game" back to the parent tab.
if (event.parent_game_id() != -1) {
game->getGameMetaInfo()->setParentGameId(event.parent_game_id());
}
const int playerListSize = event.player_list_size();
QVector<QPair<int, QPair<QString, QString>>> opponentDecksToDisplay;