Cockatrice 2026-10-19-Development-3.1.2-beta.2
A 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 <QList>
11#include <QObject>
12#include <QString>
13#include <qtmetamacros.h>
14
15class AbstractGame;
16class AbstractClient;
17class QTimer;
18
19class GameState : public QObject
20{
21 Q_OBJECT
22
23public:
24 explicit GameState(AbstractGame *parent,
26 int hostId,
27 bool isLocalGame,
29 bool gameStateKnown,
30 bool resuming,
31 int currentPhase,
32 bool gameClosed);
33
34 void setHostId(int _hostId)
35 {
36 hostId = _hostId;
37 }
38
40 {
41 return clients;
42 }
43
44 bool getIsLocalGame() const
45 {
46 return isLocalGame;
47 }
48
49 bool isResuming() const
50 {
51 return resuming;
52 }
53
54 void setResuming(bool _resuming)
55 {
56 resuming = _resuming;
57 }
58
59 bool isGameStateKnown() const
60 {
61 return gameStateKnown;
62 }
63
64 int getCurrentPhase() const
65 {
66 return currentPhase;
67 }
68
69 void setCurrentPhase(int phase)
70 {
71 currentPhase = phase;
72 emit activePhaseChanged(phase);
73 }
74
75 void setActivePlayer(int activePlayerId)
76 {
77 activePlayer = activePlayerId;
79 }
80
81 int getActivePlayer() const
82 {
83 return activePlayer;
84 }
85
86 void setGameClosed(bool closed)
87 {
88 gameClosed = closed;
89 }
90
91 bool isGameClosed() const
92 {
93 return gameClosed;
94 }
95
96 void onStartedChanged(bool _started)
97 {
98 if (_started) {
99 emit gameStarted(_started);
100 } else {
101 emit gameStopped();
102 }
103 }
104
105 void setGameStateKnown(bool known)
106 {
107 gameStateKnown = known;
108 }
109
110 int getHostId() const
111 {
112 return hostId;
113 }
114
116 {
117 return secondsElapsed;
118 }
119
120signals:
121 void updateTimeElapsedLabel(QString newTime);
124 void activePhaseChanged(int activePhase);
125 void activePlayerChanged(int playerId);
126
127public slots:
128 void incrementGameTime();
129 void setGameTime(int _secondsElapsed);
130
131public:
132 static QString formatElapsedTime(int _secondsElapsed);
133
134private:
135 QTimer *gameTimer;
138 const bool isLocalGame;
145};
146
147#endif // COCKATRICE_GAME_STATE_H
Definition abstract_client.h:73
Definition abstract_game.h:23
int getHostId() const
Definition game_state.h:110
bool resuming
Definition game_state.h:141
int secondsElapsed
Definition game_state.h:136
bool getIsLocalGame() const
Definition game_state.h:44
QList< AbstractClient * > clients
Definition game_state.h:139
void setActivePlayer(int activePlayerId)
Definition game_state.h:75
void setHostId(int _hostId)
Definition game_state.h:34
void setGameClosed(bool closed)
Definition game_state.h:86
void gameStopped()
int hostId
Definition game_state.h:137
void updateTimeElapsedLabel(QString newTime)
void setGameTime(int _secondsElapsed)
Definition game_state.cpp:34
void incrementGameTime()
Definition game_state.cpp:29
GameState(AbstractGame *parent, int secondsElapsed, int hostId, bool isLocalGame, QList< AbstractClient * > clients, bool gameStateKnown, bool resuming, int currentPhase, bool gameClosed)
Definition game_state.cpp:10
void onStartedChanged(bool _started)
Definition game_state.h:96
int getCurrentPhase() const
Definition game_state.h:64
QList< AbstractClient * > getClients() const
Definition game_state.h:39
static QString formatElapsedTime(int _secondsElapsed)
Definition game_state.cpp:40
void activePhaseChanged(int activePhase)
int getSecondsElapsed() const
Definition game_state.h:115
int currentPhase
Definition game_state.h:142
void setGameStateKnown(bool known)
Definition game_state.h:105
int getActivePlayer() const
Definition game_state.h:81
QTimer * gameTimer
Definition game_state.h:135
const bool isLocalGame
Definition game_state.h:138
void setCurrentPhase(int phase)
Definition game_state.h:69
bool isGameClosed() const
Definition game_state.h:91
bool gameClosed
Definition game_state.h:144
int activePlayer
Definition game_state.h:143
bool gameStateKnown
Definition game_state.h:140
void activePlayerChanged(int playerId)
void gameStarted(bool resuming)
void setResuming(bool _resuming)
Definition game_state.h:54
bool isResuming() const
Definition game_state.h:49
bool isGameStateKnown() const
Definition game_state.h:59
Definition remote_connection_controller.h:20