Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
game_state.h
Go to the documentation of this file.
1
6
7#ifndef COCKATRICE_GAME_STATE_H
8#define COCKATRICE_GAME_STATE_H
9
10#include <QTimer>
12
13class AbstractGame;
14class ServerInfo_PlayerProperties;
15class ServerInfo_User;
16
17class GameState : public QObject
18{
19 Q_OBJECT
20
21public:
22 explicit GameState(AbstractGame *parent,
24 int hostId,
25 bool isLocalGame,
26 QList<AbstractClient *> clients,
27 bool gameStateKnown,
28 bool resuming,
29 int currentPhase,
30 bool gameClosed);
31
32 void setHostId(int _hostId)
33 {
34 hostId = _hostId;
35 }
36
37 QList<AbstractClient *> getClients() const
38 {
39 return clients;
40 }
41
42 bool getIsLocalGame() const
43 {
44 return isLocalGame;
45 }
46
47 bool isResuming() const
48 {
49 return resuming;
50 }
51
52 void setResuming(bool _resuming)
53 {
54 resuming = _resuming;
55 }
56
57 bool isGameStateKnown() const
58 {
59 return gameStateKnown;
60 }
61
62 int getCurrentPhase() const
63 {
64 return currentPhase;
65 }
66
67 void setCurrentPhase(int phase)
68 {
69 currentPhase = phase;
70 emit activePhaseChanged(phase);
71 }
72
73 void setActivePlayer(int activePlayerId)
74 {
75 activePlayer = activePlayerId;
77 }
78
79 int getActivePlayer() const
80 {
81 return activePlayer;
82 }
83
84 void setGameClosed(bool closed)
85 {
86 gameClosed = closed;
87 }
88
89 bool isGameClosed() const
90 {
91 return gameClosed;
92 }
93
94 void onStartedChanged(bool _started)
95 {
96 if (_started) {
97 emit gameStarted(_started);
98 } else {
99 emit gameStopped();
100 }
101 }
102
103 void setGameStateKnown(bool known)
104 {
105 gameStateKnown = known;
106 }
107
108 int getHostId() const
109 {
110 return hostId;
111 }
112
113signals:
114 void updateTimeElapsedLabel(QString newTime);
117 void activePhaseChanged(int activePhase);
118 void activePlayerChanged(int playerId);
119
120public slots:
121 void incrementGameTime();
122 void setGameTime(int _secondsElapsed);
123
124private:
125 QTimer *gameTimer;
128 const bool isLocalGame;
129 QList<AbstractClient *> clients;
135};
136
137#endif // COCKATRICE_GAME_STATE_H
TODO: Document this.
Definition abstract_game.h:21
int getHostId() const
Definition game_state.h:108
bool resuming
Definition game_state.h:131
int secondsElapsed
Definition game_state.h:126
bool getIsLocalGame() const
Definition game_state.h:42
QList< AbstractClient * > clients
Definition game_state.h:129
void setActivePlayer(int activePlayerId)
Definition game_state.h:73
void setHostId(int _hostId)
Definition game_state.h:32
void setGameClosed(bool closed)
Definition game_state.h:84
void gameStopped()
int hostId
Definition game_state.h:127
void updateTimeElapsedLabel(QString newTime)
void setGameTime(int _secondsElapsed)
Definition game_state.cpp:29
void incrementGameTime()
Definition game_state.cpp:24
GameState(AbstractGame *parent, int secondsElapsed, int hostId, bool isLocalGame, QList< AbstractClient * > clients, bool gameStateKnown, bool resuming, int currentPhase, bool gameClosed)
Definition game_state.cpp:5
void onStartedChanged(bool _started)
Definition game_state.h:94
int getCurrentPhase() const
Definition game_state.h:62
QList< AbstractClient * > getClients() const
Definition game_state.h:37
void activePhaseChanged(int activePhase)
int currentPhase
Definition game_state.h:132
void setGameStateKnown(bool known)
Definition game_state.h:103
int getActivePlayer() const
Definition game_state.h:79
QTimer * gameTimer
Definition game_state.h:125
const bool isLocalGame
Definition game_state.h:128
void setCurrentPhase(int phase)
Definition game_state.h:67
bool isGameClosed() const
Definition game_state.h:89
bool gameClosed
Definition game_state.h:134
int activePlayer
Definition game_state.h:133
bool gameStateKnown
Definition game_state.h:130
void activePlayerChanged(int playerId)
void gameStarted(bool resuming)
void setResuming(bool _resuming)
Definition game_state.h:52
bool isResuming() const
Definition game_state.h:47
bool isGameStateKnown() const
Definition game_state.h:57