Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
server_abstract_participant.h
Go to the documentation of this file.
1#ifndef ABSTRACT_PARTICIPANT_H
2#define ABSTRACT_PARTICIPANT_H
3
6
7#include <QMutex>
8#include <libcockatrice/protocol/pb/card_attributes.pb.h>
9#include <libcockatrice/protocol/pb/response.pb.h>
10
11class Server_Game;
13class ServerInfo_User;
14class ServerInfo_Player;
15class ServerInfo_PlayerProperties;
16class GameEventContainer;
19class GameCommand;
20
21class Command_KickFromGame;
22class Command_LeaveGame;
23class Command_GameSay;
24class Command_Shuffle;
25class Command_Mulligan;
26class Command_RollDie;
27class Command_DrawCards;
28class Command_UndoDraw;
29class Command_FlipCard;
30class Command_AttachCard;
31class Command_CreateToken;
32class Command_CreateArrow;
33class Command_DeleteArrow;
34class Command_SetCardAttr;
35class Command_SetCardCounter;
36class Command_IncCardCounter;
37class Command_ReadyStart;
38class Command_Concede;
39class Command_Unconcede;
40class Command_Judge;
41class Command_IncCounter;
42class Command_CreateCounter;
43class Command_SetCounter;
44class Command_DelCounter;
45class Command_NextTurn;
46class Command_SetActivePhase;
47class Command_DumpZone;
48class Command_RevealCards;
49class Command_ReverseTurn;
50class Command_MoveCard;
51class Command_SetSideboardPlan;
52class Command_DeckSelect;
53class Command_SetSideboardLock;
54class Command_ChangeZoneProperties;
55
57{
58 Q_OBJECT
59protected:
65 bool judge;
66 virtual void getPlayerProperties(ServerInfo_PlayerProperties &result);
67 mutable QMutex playerMutex;
68
69public:
71 int _playerId,
72 const ServerInfo_User &_userInfo,
73 bool _judge,
76 virtual void prepareDestroy()
77 {
79 }
80 void removeFromGame();
86 void disconnectClient();
87
88 int getPlayerId() const
89 {
90 return playerId;
91 }
92 bool getSpectator() const
93 {
94 return spectator;
95 }
96 bool getJudge() const
97 {
98 return judge;
99 }
101 {
102 return game;
103 }
104 int getPingTime() const
105 {
106 return pingTime;
107 }
108 bool updatePingTime();
109 void getProperties(ServerInfo_PlayerProperties &result, bool withUserInfo);
110
111 virtual Response::ResponseCode
112 cmdLeaveGame(const Command_LeaveGame &cmd, ResponseContainer &rc, GameEventStorage &ges);
113 virtual Response::ResponseCode
114 cmdKickFromGame(const Command_KickFromGame &cmd, ResponseContainer &rc, GameEventStorage &ges);
115 virtual Response::ResponseCode cmdConcede(const Command_Concede &cmd, ResponseContainer &rc, GameEventStorage &ges);
116 virtual Response::ResponseCode
117 cmdUnconcede(const Command_Unconcede &cmd, ResponseContainer &rc, GameEventStorage &ges);
118 virtual Response::ResponseCode cmdJudge(const Command_Judge &cmd, ResponseContainer &rc, GameEventStorage &ges);
119 virtual Response::ResponseCode
120 cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges);
121 virtual Response::ResponseCode
122 cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges);
123 virtual Response::ResponseCode
124 cmdSetSideboardPlan(const Command_SetSideboardPlan &cmd, ResponseContainer &rc, GameEventStorage &ges);
125 virtual Response::ResponseCode
126 cmdSetSideboardLock(const Command_SetSideboardLock &cmd, ResponseContainer &rc, GameEventStorage &ges);
127 virtual Response::ResponseCode cmdGameSay(const Command_GameSay &cmd, ResponseContainer &rc, GameEventStorage &ges);
128 virtual Response::ResponseCode cmdShuffle(const Command_Shuffle &cmd, ResponseContainer &rc, GameEventStorage &ges);
129 virtual Response::ResponseCode
130 cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges);
131 virtual Response::ResponseCode
132 cmdRollDie(const Command_RollDie &cmd, ResponseContainer &rc, GameEventStorage &ges) const;
133 virtual Response::ResponseCode
134 cmdDrawCards(const Command_DrawCards &cmd, ResponseContainer &rc, GameEventStorage &ges);
135 virtual Response::ResponseCode
136 cmdUndoDraw(const Command_UndoDraw &cmd, ResponseContainer &rc, GameEventStorage &ges);
137 virtual Response::ResponseCode
138 cmdMoveCard(const Command_MoveCard &cmd, ResponseContainer &rc, GameEventStorage &ges);
139 virtual Response::ResponseCode
140 cmdFlipCard(const Command_FlipCard &cmd, ResponseContainer &rc, GameEventStorage &ges);
141 virtual Response::ResponseCode
142 cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &rc, GameEventStorage &ges);
143 virtual Response::ResponseCode
144 cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer &rc, GameEventStorage &ges);
145 virtual Response::ResponseCode
146 cmdCreateArrow(const Command_CreateArrow &cmd, ResponseContainer &rc, GameEventStorage &ges);
147 virtual Response::ResponseCode
148 cmdDeleteArrow(const Command_DeleteArrow &cmd, ResponseContainer &rc, GameEventStorage &ges);
149 virtual Response::ResponseCode
150 cmdSetCardAttr(const Command_SetCardAttr &cmd, ResponseContainer &rc, GameEventStorage &ges);
151 virtual Response::ResponseCode
152 cmdSetCardCounter(const Command_SetCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges);
153 virtual Response::ResponseCode
154 cmdIncCardCounter(const Command_IncCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges);
155 virtual Response::ResponseCode
156 cmdIncCounter(const Command_IncCounter &cmd, ResponseContainer &rc, GameEventStorage &ges);
157 virtual Response::ResponseCode
158 cmdCreateCounter(const Command_CreateCounter &cmd, ResponseContainer &rc, GameEventStorage &ges);
159 virtual Response::ResponseCode
160 cmdSetCounter(const Command_SetCounter &cmd, ResponseContainer &rc, GameEventStorage &ges);
161 virtual Response::ResponseCode
162 cmdDelCounter(const Command_DelCounter &cmd, ResponseContainer &rc, GameEventStorage &ges);
163 virtual Response::ResponseCode
164 cmdNextTurn(const Command_NextTurn &cmd, ResponseContainer &rc, GameEventStorage &ges);
165 virtual Response::ResponseCode
166 cmdSetActivePhase(const Command_SetActivePhase &cmd, ResponseContainer &rc, GameEventStorage &ges);
167 virtual Response::ResponseCode
168 cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, GameEventStorage &ges);
169 virtual Response::ResponseCode
170 cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer &rc, GameEventStorage &ges);
171 virtual Response::ResponseCode
172 cmdReverseTurn(const Command_ReverseTurn & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges);
173 virtual Response::ResponseCode
174 cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd, ResponseContainer &rc, GameEventStorage &ges);
175
176 Response::ResponseCode processGameCommand(const GameCommand &command, ResponseContainer &rc, GameEventStorage &ges);
177 void sendGameEvent(const GameEventContainer &event);
178
179 virtual void
180 getInfo(ServerInfo_Player *info, Server_AbstractParticipant *recipient, bool omniscient, bool withUserInfo);
181};
182
183#endif
Definition server_response_containers.h:46
Definition server_response_containers.h:89
ServerInfo_User_Container(ServerInfo_User *_userInfo=nullptr)
Definition serverinfo_user_container.cpp:5
Definition server_abstract_participant.h:57
Server_Game * game
Definition server_abstract_participant.h:60
virtual Response::ResponseCode cmdUndoDraw(const Command_UndoDraw &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:247
virtual Response::ResponseCode cmdDeleteArrow(const Command_DeleteArrow &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:289
Server_AbstractUserInterface * getUserInterface() const
Definition server_abstract_participant.h:81
int getPingTime() const
Definition server_abstract_participant.h:104
QMutex playerMutex
Definition server_abstract_participant.h:67
virtual Response::ResponseCode cmdDelCounter(const Command_DelCounter &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:338
virtual Response::ResponseCode cmdIncCardCounter(const Command_IncCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:310
int getPlayerId() const
Definition server_abstract_participant.h:88
void setUserInterface(Server_AbstractUserInterface *_userInterface)
Definition server_abstract_participant.cpp:542
virtual void prepareDestroy()
Definition server_abstract_participant.h:76
~Server_AbstractParticipant() override
bool updatePingTime()
Definition server_abstract_participant.cpp:73
virtual Response::ResponseCode cmdIncCounter(const Command_IncCounter &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:317
void getProperties(ServerInfo_PlayerProperties &result, bool withUserInfo)
Definition server_abstract_participant.cpp:87
virtual Response::ResponseCode cmdUnconcede(const Command_Unconcede &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:154
virtual Response::ResponseCode cmdMulligan(const Command_Mulligan &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:226
virtual Response::ResponseCode cmdSetCounter(const Command_SetCounter &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:331
virtual Response::ResponseCode cmdSetCardCounter(const Command_SetCardCounter &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:303
virtual Response::ResponseCode cmdGameSay(const Command_GameSay &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:190
virtual Response::ResponseCode cmdLeaveGame(const Command_LeaveGame &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:103
virtual Response::ResponseCode cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:268
virtual Response::ResponseCode cmdCreateCounter(const Command_CreateCounter &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:324
virtual Response::ResponseCode cmdConcede(const Command_Concede &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:147
Response::ResponseCode processGameCommand(const GameCommand &command, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:423
virtual Response::ResponseCode cmdChangeZoneProperties(const Command_ChangeZoneProperties &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:392
virtual Response::ResponseCode cmdKickFromGame(const Command_KickFromGame &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:111
Server_Game * getGame() const
Definition server_abstract_participant.h:100
virtual Response::ResponseCode cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:385
virtual Response::ResponseCode cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:126
void sendGameEvent(const GameEventContainer &event)
Definition server_abstract_participant.cpp:533
virtual Response::ResponseCode cmdSetCardAttr(const Command_SetCardAttr &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:296
void removeFromGame()
Definition server_abstract_participant.cpp:65
virtual Response::ResponseCode cmdRollDie(const Command_RollDie &cmd, ResponseContainer &rc, GameEventStorage &ges) const
Definition server_abstract_participant.cpp:233
virtual Response::ResponseCode cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:182
bool judge
Definition server_abstract_participant.h:65
virtual Response::ResponseCode cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:275
virtual void getPlayerProperties(ServerInfo_PlayerProperties &result)
Definition server_abstract_participant.cpp:99
bool getSpectator() const
Definition server_abstract_participant.h:92
virtual void getInfo(ServerInfo_Player *info, Server_AbstractParticipant *recipient, bool omniscient, bool withUserInfo)
Definition server_abstract_participant.cpp:569
void disconnectClient()
Definition server_abstract_participant.cpp:559
Server_AbstractParticipant(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _judge, Server_AbstractUserInterface *_handler)
Definition server_abstract_participant.cpp:53
virtual Response::ResponseCode cmdSetSideboardPlan(const Command_SetSideboardPlan &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:133
virtual Response::ResponseCode cmdReverseTurn(const Command_ReverseTurn &, ResponseContainer &, GameEventStorage &ges)
Definition server_abstract_participant.cpp:399
int playerId
Definition server_abstract_participant.h:63
virtual Response::ResponseCode cmdDumpZone(const Command_DumpZone &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:378
virtual Response::ResponseCode cmdFlipCard(const Command_FlipCard &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:261
virtual Response::ResponseCode cmdMoveCard(const Command_MoveCard &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:254
virtual Response::ResponseCode cmdNextTurn(const Command_NextTurn &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:345
bool spectator
Definition server_abstract_participant.h:64
bool getJudge() const
Definition server_abstract_participant.h:96
virtual Response::ResponseCode cmdCreateArrow(const Command_CreateArrow &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:282
virtual Response::ResponseCode cmdSetActivePhase(const Command_SetActivePhase &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:361
int pingTime
Definition server_abstract_participant.h:62
virtual Response::ResponseCode cmdSetSideboardLock(const Command_SetSideboardLock &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:140
virtual Response::ResponseCode cmdShuffle(const Command_Shuffle &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:219
virtual Response::ResponseCode cmdJudge(const Command_Judge &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:162
virtual Response::ResponseCode cmdDrawCards(const Command_DrawCards &cmd, ResponseContainer &rc, GameEventStorage &ges)
Definition server_abstract_participant.cpp:240
Server_AbstractUserInterface * userInterface
Definition server_abstract_participant.h:61
Definition server_abstractuserinterface.h:20
Definition server_arrowtarget.h:7
Definition server_game.h:47