Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
PlayerEventHandler Class Reference

Applies player-specific game events and emits corresponding log signals. More...

#include <player_event_handler.h>

Inheritance diagram for PlayerEventHandler:
[legend]
Collaboration diagram for PlayerEventHandler:
[legend]

Signals

void cardZoneChanged (CardItem *card, bool sameZone)
void requestCardMenuUpdate (const CardItem *card)
Logging signals
void logSay (PlayerLogic *player, QString message)
void logShuffle (PlayerLogic *player, CardZoneLogic *zone, int start, int end)
void logRollDie (PlayerLogic *player, int sides, const QList< uint > &rolls)
void logCreateArrow (PlayerLogic *player, PlayerLogic *startPlayer, QString startCard, PlayerLogic *targetPlayer, QString targetCard, bool _playerTarget)
void logCreateToken (PlayerLogic *player, QString cardName, QString pt, bool faceDown)
void logDrawCards (PlayerLogic *player, int number, bool deckIsEmpty)
void logUndoDraw (PlayerLogic *player, QString cardName)
void logUndoDrawFailed (PlayerLogic *player)
void logMoveCard (PlayerLogic *player, CardItem *card, CardZoneLogic *startZone, int oldX, CardZoneLogic *targetZone, int newX)
void logFlipCard (PlayerLogic *player, QString cardName, bool faceDown)
void logDestroyCard (PlayerLogic *player, QString cardName)
void logAttachCard (PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName)
void logUnattachCard (PlayerLogic *player, QString cardName)
void logSetCardCounter (PlayerLogic *player, QString cardName, int counterId, int value, int oldValue)
void logSetTapped (PlayerLogic *player, CardItem *card, bool tapped)
void logSetCounter (PlayerLogic *player, QString counterName, int value, int oldValue)
void logSetDoesntUntap (PlayerLogic *player, CardItem *card, bool doesntUntap)
void logSetPT (PlayerLogic *player, CardItem *card, QString newPT)
void logSetAnnotation (PlayerLogic *player, CardItem *card, QString newAnnotation)
void logDumpZone (PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed=false)
void logRevealCards (PlayerLogic *player, CardZoneLogic *zone, int cardId, QString cardName, PlayerLogic *otherPlayer, bool faceDown, int amount, bool isLentToAnotherPlayer=false)
void logAlwaysRevealTopCard (PlayerLogic *player, CardZoneLogic *zone, bool reveal)
void logAlwaysLookAtTopCard (PlayerLogic *player, CardZoneLogic *zone, bool reveal)

Public Member Functions

 PlayerEventHandler (PlayerLogic *player)
 Construct a PlayerEventHandler bound to a Player.
void eventGameLogNotice (const Event_GameLogNotice &event)
Event dispatch
void processGameEvent (GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context, EventProcessingOptions options)
 Dispatch a generic GameEvent to the appropriate handler.
Chat and randomization events
void eventGameSay (const Event_GameSay &event)
 Handle in-game chat messages from this player.
void eventShuffle (const Event_Shuffle &event)
 Handle zone shuffle events (typically libraries).
void eventRollDie (const Event_RollDie &event)
 Handle die roll events.
Arrow and targeting events
void eventCreateArrow (const Event_CreateArrow &event)
 Create a visual arrow between cards or players.
void eventDeleteArrow (const Event_DeleteArrow &event)
 Delete an existing arrow.
Token and card creation
void eventCreateToken (const Event_CreateToken &event)
 Create a token card in a target zone.
Card attribute and counter updates
void eventSetCardAttr (const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options)
 Set a card attribute (tapped, PT, annotation, etc.).
void eventSetCardCounter (const Event_SetCardCounter &event)
 Update a counter attached to a card.
void eventCreateCounter (const Event_CreateCounter &event)
 Create a player-level counter.
void eventSetCounter (const Event_SetCounter &event)
 Set a player-level counter value.
void eventDelCounter (const Event_DelCounter &event)
 Delete a player-level counter.
Zone-level operations
void eventDumpZone (const Event_DumpZone &event)
 Log a zone dump (e.g. reveal graveyard/library contents).
void eventMoveCard (const Event_MoveCard &event, const GameEventContext &context)
 Move a card between zones and/or players.
void eventFlipCard (const Event_FlipCard &event)
 Flip a card face up or face down.
void eventDestroyCard (const Event_DestroyCard &event)
 Destroy a card and clean up attachments.
void eventAttachCard (const Event_AttachCard &event)
 Attach or detach a card to/from another card.
Draw and reveal operations
void eventDrawCards (const Event_DrawCards &event)
 Draw one or more cards from the deck.
void eventRevealCards (const Event_RevealCards &event, EventProcessingOptions options)
 Reveal cards from a zone.
Zone configuration
void eventChangeZoneProperties (const Event_ChangeZoneProperties &event)
 Update zone visibility and reveal behavior.

Private Member Functions

void setCardAttrHelper (const GameEventContext &context, CardItem *card, CardAttribute attribute, const QString &avalue, bool allCards, EventProcessingOptions options)

Private Attributes

PlayerLogicplayer

Detailed Description

Applies player-specific game events and emits corresponding log signals.

Design notes:

  • All event handlers assume events are authoritative and already validated by the server.
  • Most handlers mutate both logical state (CardItem, CardZoneLogic, counters) and visual/UI state (views, arrows, menus).
  • Logging signals are emitted after or during state mutation, depending on whether later mutations would invalidate log data.

Constructor & Destructor Documentation

◆ PlayerEventHandler()

PlayerEventHandler::PlayerEventHandler ( PlayerLogic * player)
explicit

Construct a PlayerEventHandler bound to a Player.

Parameters
playerOwning player instance.
Here is the call graph for this function:

Member Function Documentation

◆ cardZoneChanged

void PlayerEventHandler::cardZoneChanged ( CardItem * card,
bool sameZone )
signal
Here is the caller graph for this function:

◆ eventAttachCard()

void PlayerEventHandler::eventAttachCard ( const Event_AttachCard & event)

Attach or detach a card to/from another card.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventChangeZoneProperties()

void PlayerEventHandler::eventChangeZoneProperties ( const Event_ChangeZoneProperties & event)

Update zone visibility and reveal behavior.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventCreateArrow()

void PlayerEventHandler::eventCreateArrow ( const Event_CreateArrow & event)

Create a visual arrow between cards or players.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventCreateCounter()

void PlayerEventHandler::eventCreateCounter ( const Event_CreateCounter & event)

Create a player-level counter.

Here is the caller graph for this function:

◆ eventCreateToken()

void PlayerEventHandler::eventCreateToken ( const Event_CreateToken & event)

Create a token card in a target zone.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventDelCounter()

void PlayerEventHandler::eventDelCounter ( const Event_DelCounter & event)

Delete a player-level counter.

Here is the caller graph for this function:

◆ eventDeleteArrow()

void PlayerEventHandler::eventDeleteArrow ( const Event_DeleteArrow & event)

Delete an existing arrow.

Here is the caller graph for this function:

◆ eventDestroyCard()

void PlayerEventHandler::eventDestroyCard ( const Event_DestroyCard & event)

Destroy a card and clean up attachments.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventDrawCards()

void PlayerEventHandler::eventDrawCards ( const Event_DrawCards & event)

Draw one or more cards from the deck.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventDumpZone()

void PlayerEventHandler::eventDumpZone ( const Event_DumpZone & event)

Log a zone dump (e.g. reveal graveyard/library contents).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFlipCard()

void PlayerEventHandler::eventFlipCard ( const Event_FlipCard & event)

Flip a card face up or face down.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventGameLogNotice()

void PlayerEventHandler::eventGameLogNotice ( const Event_GameLogNotice & event)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventGameSay()

void PlayerEventHandler::eventGameSay ( const Event_GameSay & event)

Handle in-game chat messages from this player.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventMoveCard()

void PlayerEventHandler::eventMoveCard ( const Event_MoveCard & event,
const GameEventContext & context )

Move a card between zones and/or players.

This is one of the most complex handlers:

  • Removes the card from the start zone
  • Updates card identity and ownership if needed
  • Handles attachments and arrows
  • Emits appropriate move or undo-draw logs
  • Inserts the card into the target zone
Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventRevealCards()

void PlayerEventHandler::eventRevealCards ( const Event_RevealCards & event,
EventProcessingOptions options )

Reveal cards from a zone.

Handles peeking, in-place top-card reveals, full reveal windows, and write-access granting.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventRollDie()

void PlayerEventHandler::eventRollDie ( const Event_RollDie & event)

Handle die roll events.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventSetCardAttr()

void PlayerEventHandler::eventSetCardAttr ( const Event_SetCardAttr & event,
const GameEventContext & context,
EventProcessingOptions options )

Set a card attribute (tapped, PT, annotation, etc.).

May apply to a single card or all cards in a zone if no card ID is provided by the event.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventSetCardCounter()

void PlayerEventHandler::eventSetCardCounter ( const Event_SetCardCounter & event)

Update a counter attached to a card.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventSetCounter()

void PlayerEventHandler::eventSetCounter ( const Event_SetCounter & event)

Set a player-level counter value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventShuffle()

void PlayerEventHandler::eventShuffle ( const Event_Shuffle & event)

Handle zone shuffle events (typically libraries).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ logAlwaysLookAtTopCard

void PlayerEventHandler::logAlwaysLookAtTopCard ( PlayerLogic * player,
CardZoneLogic * zone,
bool reveal )
signal
Here is the caller graph for this function:

◆ logAlwaysRevealTopCard

void PlayerEventHandler::logAlwaysRevealTopCard ( PlayerLogic * player,
CardZoneLogic * zone,
bool reveal )
signal
Here is the caller graph for this function:

◆ logAttachCard

void PlayerEventHandler::logAttachCard ( PlayerLogic * player,
QString cardName,
PlayerLogic * targetPlayer,
QString targetCardName )
signal
Here is the caller graph for this function:

◆ logCreateArrow

void PlayerEventHandler::logCreateArrow ( PlayerLogic * player,
PlayerLogic * startPlayer,
QString startCard,
PlayerLogic * targetPlayer,
QString targetCard,
bool _playerTarget )
signal
Here is the caller graph for this function:

◆ logCreateToken

void PlayerEventHandler::logCreateToken ( PlayerLogic * player,
QString cardName,
QString pt,
bool faceDown )
signal
Here is the caller graph for this function:

◆ logDestroyCard

void PlayerEventHandler::logDestroyCard ( PlayerLogic * player,
QString cardName )
signal
Here is the caller graph for this function:

◆ logDrawCards

void PlayerEventHandler::logDrawCards ( PlayerLogic * player,
int number,
bool deckIsEmpty )
signal
Here is the caller graph for this function:

◆ logDumpZone

void PlayerEventHandler::logDumpZone ( PlayerLogic * player,
CardZoneLogic * zone,
int numberCards,
bool isReversed = false )
signal
Here is the caller graph for this function:

◆ logFlipCard

void PlayerEventHandler::logFlipCard ( PlayerLogic * player,
QString cardName,
bool faceDown )
signal
Here is the caller graph for this function:

◆ logMoveCard

void PlayerEventHandler::logMoveCard ( PlayerLogic * player,
CardItem * card,
CardZoneLogic * startZone,
int oldX,
CardZoneLogic * targetZone,
int newX )
signal
Here is the caller graph for this function:

◆ logRevealCards

void PlayerEventHandler::logRevealCards ( PlayerLogic * player,
CardZoneLogic * zone,
int cardId,
QString cardName,
PlayerLogic * otherPlayer,
bool faceDown,
int amount,
bool isLentToAnotherPlayer = false )
signal
Here is the caller graph for this function:

◆ logRollDie

void PlayerEventHandler::logRollDie ( PlayerLogic * player,
int sides,
const QList< uint > & rolls )
signal
Here is the caller graph for this function:

◆ logSay

void PlayerEventHandler::logSay ( PlayerLogic * player,
QString message )
signal
Here is the caller graph for this function:

◆ logSetAnnotation

void PlayerEventHandler::logSetAnnotation ( PlayerLogic * player,
CardItem * card,
QString newAnnotation )
signal
Here is the caller graph for this function:

◆ logSetCardCounter

void PlayerEventHandler::logSetCardCounter ( PlayerLogic * player,
QString cardName,
int counterId,
int value,
int oldValue )
signal
Here is the caller graph for this function:

◆ logSetCounter

void PlayerEventHandler::logSetCounter ( PlayerLogic * player,
QString counterName,
int value,
int oldValue )
signal
Here is the caller graph for this function:

◆ logSetDoesntUntap

void PlayerEventHandler::logSetDoesntUntap ( PlayerLogic * player,
CardItem * card,
bool doesntUntap )
signal
Here is the caller graph for this function:

◆ logSetPT

void PlayerEventHandler::logSetPT ( PlayerLogic * player,
CardItem * card,
QString newPT )
signal
Here is the caller graph for this function:

◆ logSetTapped

void PlayerEventHandler::logSetTapped ( PlayerLogic * player,
CardItem * card,
bool tapped )
signal
Here is the caller graph for this function:

◆ logShuffle

void PlayerEventHandler::logShuffle ( PlayerLogic * player,
CardZoneLogic * zone,
int start,
int end )
signal
Here is the caller graph for this function:

◆ logUnattachCard

void PlayerEventHandler::logUnattachCard ( PlayerLogic * player,
QString cardName )
signal
Here is the caller graph for this function:

◆ logUndoDraw

void PlayerEventHandler::logUndoDraw ( PlayerLogic * player,
QString cardName )
signal
Here is the caller graph for this function:

◆ logUndoDrawFailed

void PlayerEventHandler::logUndoDrawFailed ( PlayerLogic * player)
signal
Here is the caller graph for this function:

◆ processGameEvent()

void PlayerEventHandler::processGameEvent ( GameEvent::GameEventType type,
const GameEvent & event,
const GameEventContext & context,
EventProcessingOptions options )

Dispatch a generic GameEvent to the appropriate handler.

This is the single entry point used by GameEventHandler. It extracts the correct protobuf extension and forwards the event to a typed handler method.

Parameters
typeGame event type enum.
eventGeneric protobuf container.
contextAdditional context (undo, judge, etc.).
optionsProcessing options (UI suppression, reveal behavior).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ requestCardMenuUpdate

void PlayerEventHandler::requestCardMenuUpdate ( const CardItem * card)
signal
Here is the caller graph for this function:

◆ setCardAttrHelper()

void PlayerEventHandler::setCardAttrHelper ( const GameEventContext & context,
CardItem * card,
CardAttribute attribute,
const QString & avalue,
bool allCards,
EventProcessingOptions options )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ player

PlayerLogic* PlayerEventHandler::player
private

Owning player instance.


The documentation for this class was generated from the following files: