Cockatrice 2026-06-27-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);
87
88public:
90
91 void processGameEvent(GameEvent::GameEventType type,
92 const GameEvent &event,
93 const GameEventContext &context,
94 EventProcessingOptions options);
95
96 void eventGameSay(const Event_GameSay &event);
97 void eventShuffle(const Event_Shuffle &event);
98 void eventRollDie(const Event_RollDie &event);
99 void eventCreateArrow(const Event_CreateArrow &event);
100 void eventDeleteArrow(const Event_DeleteArrow &event);
101 void eventCreateToken(const Event_CreateToken &event);
102 void
103 eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options);
104 void eventSetCardCounter(const Event_SetCardCounter &event);
105 void eventCreateCounter(const Event_CreateCounter &event);
106 void eventSetCounter(const Event_SetCounter &event);
107 void eventDelCounter(const Event_DelCounter &event);
108 void eventDumpZone(const Event_DumpZone &event);
109 void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context);
110 void eventFlipCard(const Event_FlipCard &event);
111 void eventDestroyCard(const Event_DestroyCard &event);
112 void eventAttachCard(const Event_AttachCard &event);
113 void eventDrawCards(const Event_DrawCards &event);
114 void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options);
115 void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
116 void eventGameLogNotice(const Event_GameLogNotice &event);
117
118private:
120
121 void setCardAttrHelper(const GameEventContext &context,
122 CardItem *card,
123 CardAttribute attribute,
124 const QString &avalue,
125 bool allCards,
126 EventProcessingOptions options);
127};
128
129#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:594
void logUndoDraw(PlayerLogic *player, QString cardName)
void eventCreateToken(const Event_CreateToken &event)
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)
Definition player_event_handler.cpp:48
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event)
Definition player_event_handler.cpp:565
PlayerLogic * player
Definition player_event_handler.h:119
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:281
void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue)
void eventGameSay(const Event_GameSay &event)
Definition player_event_handler.cpp:43
void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty)
void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context)
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)
Definition player_event_handler.cpp:82
void eventFlipCard(const Event_FlipCard &event)
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)
Definition player_event_handler.cpp:473
void eventCreateArrow(const Event_CreateArrow &event)
Definition player_event_handler.cpp:94
void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown)
void eventDestroyCard(const Event_DestroyCard &event)
Definition player_event_handler.cpp:404
void eventDelCounter(const Event_DelCounter &event)
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)
Definition player_event_handler.cpp:265
void eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context, EventProcessingOptions options)
Definition player_event_handler.cpp:159
void eventAttachCard(const Event_AttachCard &event)
Definition player_event_handler.cpp:427
void logSetPT(PlayerLogic *player, CardItem *card, QString newPT)
void eventRevealCards(const Event_RevealCards &event, EventProcessingOptions options)
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)
Definition player_event_handler.cpp:242
void eventCreateCounter(const Event_CreateCounter &event)
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)
Definition player_event_handler.cpp:127
Definition player_logic.h:64
static constexpr int amount
Definition deck_hash_performance_test.cpp:5