Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
player_event_handler.h
Go to the documentation of this file.
1
18
19#ifndef COCKATRICE_PLAYER_EVENT_HANDLER_H
20#define COCKATRICE_PLAYER_EVENT_HANDLER_H
21
23
24#include <QObject>
25#include <libcockatrice/protocol/pb/card_attributes.pb.h>
26#include <libcockatrice/protocol/pb/game_event.pb.h>
27#include <libcockatrice/protocol/pb/game_event_context.pb.h>
28
29class CardItem;
30class CardZoneLogic;
31class PlayerLogic;
32
41class Event_DrawCards;
42class Event_DumpZone;
43class Event_FlipCard;
44class Event_GameSay;
45class Event_MoveCard;
47class Event_RollDie;
51class Event_Shuffle;
53
66class PlayerEventHandler : public QObject
67{
68 Q_OBJECT
69
70public:
76
80
94 const GameEvent &event,
95 const GameEventContext &context,
96 EventProcessingOptions options);
97
99
103
105 void eventGameSay(const Event_GameSay &event);
106
108 void eventShuffle(const Event_Shuffle &event);
109
111 void eventRollDie(const Event_RollDie &event);
112
114
118
120 void eventCreateArrow(const Event_CreateArrow &event);
121
123 void eventDeleteArrow(const Event_DeleteArrow &event);
124
126
130
132 void eventCreateToken(const Event_CreateToken &event);
133
135
139
146 void
147 eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options);
148
150 void eventSetCardCounter(const Event_SetCardCounter &event);
151
153 void eventCreateCounter(const Event_CreateCounter &event);
154
156 void eventSetCounter(const Event_SetCounter &event);
157
159 void eventDelCounter(const Event_DelCounter &event);
160
162
166
168 void eventDumpZone(const Event_DumpZone &event);
169
180 void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context);
181
183 void eventFlipCard(const Event_FlipCard &event);
184
186 void eventDestroyCard(const Event_DestroyCard &event);
187
189 void eventAttachCard(const Event_AttachCard &event);
190
192
196
198 void eventDrawCards(const Event_DrawCards &event);
199
206 void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options);
207
209
213
216
218
219 void eventGameLogNotice(const Event_GameLogNotice &event);
220signals:
224 void logSay(PlayerLogic *player, QString message);
225 void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end);
226 void logRollDie(PlayerLogic *player, int sides, const QList<uint> &rolls);
228 PlayerLogic *startPlayer,
229 QString startCard,
230 PlayerLogic *targetPlayer,
231 QString targetCard,
232 bool _playerTarget);
233 void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
234 void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
235 void logUndoDraw(PlayerLogic *player, QString cardName);
238 CardItem *card,
239 CardZoneLogic *startZone,
240 int oldX,
241 CardZoneLogic *targetZone,
242 int newX);
243 void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown);
244 void logDestroyCard(PlayerLogic *player, QString cardName);
245 void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName);
246 void logUnattachCard(PlayerLogic *player, QString cardName);
247 void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue);
248 void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped);
249 void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue);
250 void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap);
251 void logSetPT(PlayerLogic *player, CardItem *card, QString newPT);
252 void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation);
253 void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false);
255 CardZoneLogic *zone,
256 int cardId,
257 QString cardName,
258 PlayerLogic *otherPlayer,
259 bool faceDown,
260 int amount,
261 bool isLentToAnotherPlayer = false);
265
266 void cardZoneChanged(CardItem *card, bool sameZone);
268
269private:
272
273 void setCardAttrHelper(const GameEventContext &context,
274 CardItem *card,
275 CardAttribute attribute,
276 const QString &avalue,
277 bool allCards,
278 EventProcessingOptions options);
279};
280
281#endif // COCKATRICE_PLAYER_EVENT_HANDLER_H
CardAttribute
Definition card_attributes.proto:2
Definition card_item.h:27
Definition card_zone_logic.h:26
void logUndoDrawFailed(PlayerLogic *player)
void processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context, EventProcessingOptions options)
Dispatch a generic GameEvent to the appropriate handler.
Definition player_event_handler.cpp:594
void logUndoDraw(PlayerLogic *player, QString cardName)
void eventCreateToken(const Event_CreateToken &event)
Create a token card in a target zone.
Definition player_event_handler.cpp:132
void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue)
void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown)
void requestCardMenuUpdate(const CardItem *card)
void logUnattachCard(PlayerLogic *player, QString cardName)
void eventShuffle(const Event_Shuffle &event)
Handle zone shuffle events (typically libraries).
Definition player_event_handler.cpp:48
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event)
Update zone visibility and reveal behavior.
Definition player_event_handler.cpp:565
PlayerLogic * player
Definition player_event_handler.h:271
void logDestroyCard(PlayerLogic *player, QString cardName)
void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed=false)
void logRollDie(PlayerLogic *player, int sides, const QList< uint > &rolls)
PlayerEventHandler(PlayerLogic *player)
Construct a PlayerEventHandler bound to a Player.
Definition player_event_handler.cpp:38
void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation)
void cardZoneChanged(CardItem *card, bool sameZone)
void eventDumpZone(const Event_DumpZone &event)
Log a zone dump (e.g. reveal graveyard/library contents).
Definition player_event_handler.cpp:281
void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue)
void eventGameSay(const Event_GameSay &event)
Handle in-game chat messages from this player.
Definition player_event_handler.cpp:43
void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty)
void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context)
Move a card between zones and/or players.
Definition player_event_handler.cpp:294
void logMoveCard(PlayerLogic *player, CardItem *card, CardZoneLogic *startZone, int oldX, CardZoneLogic *targetZone, int newX)
void setCardAttrHelper(const GameEventContext &context, CardItem *card, CardAttribute attribute, const QString &avalue, bool allCards, EventProcessingOptions options)
Definition player_event_handler.cpp:187
void eventRollDie(const Event_RollDie &event)
Handle die roll events.
Definition player_event_handler.cpp:82
void eventFlipCard(const Event_FlipCard &event)
Flip a card face up or face down.
Definition player_event_handler.cpp:382
void logSay(PlayerLogic *player, QString message)
void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName)
void eventDrawCards(const Event_DrawCards &event)
Draw one or more cards from the deck.
Definition player_event_handler.cpp:473
void eventCreateArrow(const Event_CreateArrow &event)
Create a visual arrow between cards or players.
Definition player_event_handler.cpp:94
void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown)
void eventDestroyCard(const Event_DestroyCard &event)
Destroy a card and clean up attachments.
Definition player_event_handler.cpp:404
void eventDelCounter(const Event_DelCounter &event)
Delete a player-level counter.
Definition player_event_handler.cpp:276
void logRevealCards(PlayerLogic *player, CardZoneLogic *zone, int cardId, QString cardName, PlayerLogic *otherPlayer, bool faceDown, int amount, bool isLentToAnotherPlayer=false)
void eventGameLogNotice(const Event_GameLogNotice &event)
Definition player_event_handler.cpp:582
void eventSetCounter(const Event_SetCounter &event)
Set a player-level counter value.
Definition player_event_handler.cpp:265
void eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options)
Set a card attribute (tapped, PT, annotation, etc.).
Definition player_event_handler.cpp:159
void eventAttachCard(const Event_AttachCard &event)
Attach or detach a card to/from another card.
Definition player_event_handler.cpp:427
void logSetPT(PlayerLogic *player, CardItem *card, QString newPT)
void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options)
Reveal cards from a zone.
Definition player_event_handler.cpp:500
void logAlwaysLookAtTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal)
void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end)
void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap)
void logAlwaysRevealTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal)
void eventSetCardCounter(const Event_SetCardCounter &event)
Update a counter attached to a card.
Definition player_event_handler.cpp:242
void eventCreateCounter(const Event_CreateCounter &event)
Create a player-level counter.
Definition player_event_handler.cpp:260
void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped)
void logCreateArrow(PlayerLogic *player, PlayerLogic *startPlayer, QString startCard, PlayerLogic *targetPlayer, QString targetCard, bool _playerTarget)
void eventDeleteArrow(const Event_DeleteArrow &event)
Delete an existing arrow.
Definition player_event_handler.cpp:127
Definition player_logic.h:65
static constexpr int amount
Definition deck_hash_performance_test.cpp:5
Definition event_attach_card.proto:3
Definition event_change_zone_properties.proto:3
Definition event_create_arrow.proto:4
Definition event_create_counter.proto:4
Definition event_create_token.proto:3
Definition event_del_counter.proto:3
Definition event_delete_arrow.proto:3
Definition event_destroy_card.proto:3
Definition event_draw_cards.proto:4
Definition event_dump_zone.proto:3
Definition event_flip_card.proto:3
Definition event_game_log_notice.proto:6
Definition event_game_say.proto:3
Definition event_move_card.proto:5
Definition event_reveal_cards.proto:4
Definition event_roll_die.proto:3
Definition event_set_card_attr.proto:4
Definition event_set_card_counter.proto:3
Definition event_set_counter.proto:3
Definition event_shuffle.proto:3
Definition game_event_context.proto:2
Definition game_event.proto:4
GameEventType
Definition game_event.proto:5