Cockatrice 2026-06-01-Development-3.1.0-beta.3
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
player_event_handler.h
Go to the documentation of this file.
1
6
7#ifndef COCKATRICE_PLAYER_EVENT_HANDLER_H
8#define COCKATRICE_PLAYER_EVENT_HANDLER_H
10
11#include <QObject>
12#include <libcockatrice/protocol/pb/card_attributes.pb.h>
13#include <libcockatrice/protocol/pb/game_event.pb.h>
14#include <libcockatrice/protocol/pb/game_event_context.pb.h>
15
16class CardItem;
17class CardZoneLogic;
18class PlayerLogic;
19class Event_AttachCard;
20class Event_ChangeZoneProperties;
21class Event_CreateArrow;
22class Event_CreateCounter;
23class Event_CreateToken;
24class Event_DelCounter;
25class Event_DeleteArrow;
26class Event_DestroyCard;
27class Event_DrawCards;
28class Event_DumpZone;
29class Event_FlipCard;
30class Event_GameSay;
31class Event_MoveCard;
32class Event_RevealCards;
33class Event_RollDie;
34class Event_SetCardAttr;
35class Event_SetCardCounter;
36class Event_SetCounter;
37class Event_Shuffle;
38class Event_GameLogNotice;
39
40class PlayerEventHandler : public QObject
41{
42
43 Q_OBJECT
44signals:
45 void logSay(PlayerLogic *player, QString message);
46 void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end);
47 void logRollDie(PlayerLogic *player, int sides, const QList<uint> &rolls);
49 PlayerLogic *startPlayer,
50 QString startCard,
51 PlayerLogic *targetPlayer,
52 QString targetCard,
53 bool _playerTarget);
54 void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
55 void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
56 void logUndoDraw(PlayerLogic *player, QString cardName);
59 CardItem *card,
60 CardZoneLogic *startZone,
61 int oldX,
62 CardZoneLogic *targetZone,
63 int newX);
64 void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown);
65 void logDestroyCard(PlayerLogic *player, QString cardName);
66 void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName);
67 void logUnattachCard(PlayerLogic *player, QString cardName);
68 void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue);
69 void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped);
70 void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue);
71 void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap);
72 void logSetPT(PlayerLogic *player, CardItem *card, QString newPT);
73 void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation);
74 void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false);
76 CardZoneLogic *zone,
77 int cardId,
78 QString cardName,
79 PlayerLogic *otherPlayer,
80 bool faceDown,
81 int amount,
82 bool isLentToAnotherPlayer = false);
85 void cardZoneChanged(CardItem *card, bool sameZone);
86
87public:
89
90 void processGameEvent(GameEvent::GameEventType type,
91 const GameEvent &event,
92 const GameEventContext &context,
93 EventProcessingOptions options);
94
95 void eventGameSay(const Event_GameSay &event);
96 void eventShuffle(const Event_Shuffle &event);
97 void eventRollDie(const Event_RollDie &event);
98 void eventCreateArrow(const Event_CreateArrow &event);
99 void eventDeleteArrow(const Event_DeleteArrow &event);
100 void eventCreateToken(const Event_CreateToken &event);
101 void
102 eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options);
103 void eventSetCardCounter(const Event_SetCardCounter &event);
104 void eventCreateCounter(const Event_CreateCounter &event);
105 void eventSetCounter(const Event_SetCounter &event);
106 void eventDelCounter(const Event_DelCounter &event);
107 void eventDumpZone(const Event_DumpZone &event);
108 void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context);
109 void eventFlipCard(const Event_FlipCard &event);
110 void eventDestroyCard(const Event_DestroyCard &event);
111 void eventAttachCard(const Event_AttachCard &event);
112 void eventDrawCards(const Event_DrawCards &event);
113 void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options);
114 void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
115 void eventGameLogNotice(const Event_GameLogNotice &event);
116
117private:
119
120 void setCardAttrHelper(const GameEventContext &context,
121 CardItem *card,
122 CardAttribute attribute,
123 const QString &avalue,
124 bool allCards,
125 EventProcessingOptions options);
126};
127
128#endif // COCKATRICE_PLAYER_EVENT_HANDLER_H
Definition card_item.h:28
Definition card_zone_logic.h:26
void logUndoDrawFailed(PlayerLogic *player)
void processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context, EventProcessingOptions options)
Definition player_event_handler.cpp:596
void logUndoDraw(PlayerLogic *player, QString cardName)
void eventCreateToken(const Event_CreateToken &event)
Definition player_event_handler.cpp:134
void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue)
void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown)
void logUnattachCard(PlayerLogic *player, QString cardName)
void eventShuffle(const Event_Shuffle &event)
Definition player_event_handler.cpp:47
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event)
Definition player_event_handler.cpp:567
PlayerLogic * player
Definition player_event_handler.h:118
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)
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)
Definition player_event_handler.cpp:283
void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue)
void eventGameSay(const Event_GameSay &event)
Definition player_event_handler.cpp:42
void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty)
void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context)
Definition player_event_handler.cpp:296
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:189
void eventRollDie(const Event_RollDie &event)
Definition player_event_handler.cpp:81
void eventFlipCard(const Event_FlipCard &event)
Definition player_event_handler.cpp:384
void logSay(PlayerLogic *player, QString message)
void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName)
void eventDrawCards(const Event_DrawCards &event)
Definition player_event_handler.cpp:475
void eventCreateArrow(const Event_CreateArrow &event)
Definition player_event_handler.cpp:93
void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown)
void eventDestroyCard(const Event_DestroyCard &event)
Definition player_event_handler.cpp:406
void eventDelCounter(const Event_DelCounter &event)
Definition player_event_handler.cpp:278
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:584
void eventSetCounter(const Event_SetCounter &event)
Definition player_event_handler.cpp:267
void eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options)
Definition player_event_handler.cpp:161
void eventAttachCard(const Event_AttachCard &event)
Definition player_event_handler.cpp:429
void logSetPT(PlayerLogic *player, CardItem *card, QString newPT)
void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options)
Definition player_event_handler.cpp:502
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)
Definition player_event_handler.cpp:244
void eventCreateCounter(const Event_CreateCounter &event)
Definition player_event_handler.cpp:262
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)
Definition player_event_handler.cpp:129
Definition player_logic.h:65
static constexpr int amount
Definition deck_hash_performance_test.cpp:5