Cockatrice 2026-10-19-Development-3.1.2-beta.2
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 <QString>
26#include <libcockatrice/protocol/pb/game_event.pb.h>
27#include <qtmetamacros.h>
28#include <sys/types.h>
29
30class CardItem;
31class CardZoneLogic;
32class PlayerLogic;
41class Event_DrawCards;
42class Event_DumpZone;
43class Event_FlipCard;
44class Event_GameSay;
45class Event_MoveCard;
47class Event_RollDie;
51class Event_Shuffle;
54enum CardAttribute : int;
55template <typename T> class QList;
56
69class PlayerEventHandler : public QObject
70{
71 Q_OBJECT
72
73public:
79
83
97 const GameEvent &event,
98 const GameEventContext &context,
99 EventProcessingOptions options);
100
102
106
108 void eventGameSay(const Event_GameSay &event);
109
111 void eventShuffle(const Event_Shuffle &event);
112
114 void eventRollDie(const Event_RollDie &event);
115
117
121
123 void eventCreateArrow(const Event_CreateArrow &event);
124
126 void eventDeleteArrow(const Event_DeleteArrow &event);
127
129
133
135 void eventCreateToken(const Event_CreateToken &event);
136
138
142
149 void
150 eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options);
151
153 void eventSetCardCounter(const Event_SetCardCounter &event);
154
156 void eventCreateCounter(const Event_CreateCounter &event);
157
159 void eventSetCounter(const Event_SetCounter &event, EventProcessingOptions options);
160
162 void eventDelCounter(const Event_DelCounter &event);
163
165
169
171 void eventDumpZone(const Event_DumpZone &event);
172
183 void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context);
184
186 void eventFlipCard(const Event_FlipCard &event);
187
189 void eventDestroyCard(const Event_DestroyCard &event);
190
192 void eventAttachCard(const Event_AttachCard &event);
193
195
199
201 void eventDrawCards(const Event_DrawCards &event);
202
209 void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options);
210
212
216
219
221
222 void eventGameLogNotice(const Event_GameLogNotice &event);
223signals:
227 void logSay(PlayerLogic *player, QString message);
228 void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end);
229 void logRollDie(PlayerLogic *player, int sides, const QList<uint> &rolls);
231 PlayerLogic *startPlayer,
232 QString startCard,
233 PlayerLogic *targetPlayer,
234 QString targetCard,
235 bool _playerTarget);
236 void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
237 void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
238 void logUndoDraw(PlayerLogic *player, QString cardName);
241 CardItem *card,
242 CardZoneLogic *startZone,
243 int oldX,
244 CardZoneLogic *targetZone,
245 int newX);
246 void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown);
247 void logDestroyCard(PlayerLogic *player, QString cardName);
248 void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName);
249 void logUnattachCard(PlayerLogic *player, QString cardName);
250 void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue);
251 void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped);
252 void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue);
253 void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap);
254 void logSetPT(PlayerLogic *player, CardItem *card, QString newPT);
255 void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation);
256 void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false);
258 CardZoneLogic *zone,
259 int cardId,
260 QString cardName,
261 PlayerLogic *otherPlayer,
262 bool faceDown,
263 int amount,
264 bool isLentToAnotherPlayer = false);
268
269 void cardZoneChanged(CardItem *card, bool sameZone);
271
272private:
275
276 void setCardAttrHelper(const GameEventContext &context,
277 CardItem *card,
278 CardAttribute attribute,
279 const QString &avalue,
280 bool allCards,
281 EventProcessingOptions options);
282};
283
284#endif // COCKATRICE_PLAYER_EVENT_HANDLER_H
CardAttribute
Definition card_attributes.proto:2
Definition card_item.h:33
Definition card_zone_logic.h:27
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:613
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:150
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:66
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event)
Update zone visibility and reveal behavior.
Definition player_event_handler.cpp:584
PlayerLogic * player
Definition player_event_handler.h:274
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:56
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:300
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:61
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:313
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:205
void eventRollDie(const Event_RollDie &event)
Handle die roll events.
Definition player_event_handler.cpp:100
void eventFlipCard(const Event_FlipCard &event)
Flip a card face up or face down.
Definition player_event_handler.cpp:401
void logSay(PlayerLogic *player, QString message)
void eventSetCounter(const Event_SetCounter &event, EventProcessingOptions options)
Set a player-level counter value.
Definition player_event_handler.cpp:283
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:492
void eventCreateArrow(const Event_CreateArrow &event)
Create a visual arrow between cards or players.
Definition player_event_handler.cpp:112
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:423
void eventDelCounter(const Event_DelCounter &event)
Delete a player-level counter.
Definition player_event_handler.cpp:295
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:601
void eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options)
Set a card attribute (tapped, PT, annotation, etc.).
Definition player_event_handler.cpp:177
void eventAttachCard(const Event_AttachCard &event)
Attach or detach a card to/from another card.
Definition player_event_handler.cpp:446
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:519
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:260
void eventCreateCounter(const Event_CreateCounter &event)
Create a player-level counter.
Definition player_event_handler.cpp:278
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:145
Definition player_logic.h:56
Definition remote_connection_controller.h:20
EmailType type
Definition smtpclient.cpp:30
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