mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 13:00:01 -08:00
[Refactor] Move game logic into libcockatrice_game (#7437)
* [Refactor] Move game logic into libcockatrice_game * [Refactor] Include card_state.h in player_actions.h * [Game] Inject settings providers into libcockatrice_game, drop Widgets * [Game] Follow base rename to createCardRequested after rebase * [Game] Drop unused CardItem forward declaration * [Game] Fix includes after moving game logic into libcockatrice_game --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
78964779c6
commit
345b0e8ba9
108 changed files with 598 additions and 281 deletions
|
|
@ -1,147 +0,0 @@
|
|||
/**
|
||||
* @file game_state.h
|
||||
* @ingroup GameLogic
|
||||
*/
|
||||
//! \todo Document this file.
|
||||
|
||||
#ifndef COCKATRICE_GAME_STATE_H
|
||||
#define COCKATRICE_GAME_STATE_H
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class AbstractGame;
|
||||
class AbstractClient;
|
||||
class QTimer;
|
||||
|
||||
class GameState : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameState(AbstractGame *parent,
|
||||
int secondsElapsed,
|
||||
int hostId,
|
||||
bool isLocalGame,
|
||||
QList<AbstractClient *> clients,
|
||||
bool gameStateKnown,
|
||||
bool resuming,
|
||||
int currentPhase,
|
||||
bool gameClosed);
|
||||
|
||||
void setHostId(int _hostId)
|
||||
{
|
||||
hostId = _hostId;
|
||||
}
|
||||
|
||||
QList<AbstractClient *> getClients() const
|
||||
{
|
||||
return clients;
|
||||
}
|
||||
|
||||
bool getIsLocalGame() const
|
||||
{
|
||||
return isLocalGame;
|
||||
}
|
||||
|
||||
bool isResuming() const
|
||||
{
|
||||
return resuming;
|
||||
}
|
||||
|
||||
void setResuming(bool _resuming)
|
||||
{
|
||||
resuming = _resuming;
|
||||
}
|
||||
|
||||
bool isGameStateKnown() const
|
||||
{
|
||||
return gameStateKnown;
|
||||
}
|
||||
|
||||
int getCurrentPhase() const
|
||||
{
|
||||
return currentPhase;
|
||||
}
|
||||
|
||||
void setCurrentPhase(int phase)
|
||||
{
|
||||
currentPhase = phase;
|
||||
emit activePhaseChanged(phase);
|
||||
}
|
||||
|
||||
void setActivePlayer(int activePlayerId)
|
||||
{
|
||||
activePlayer = activePlayerId;
|
||||
emit activePlayerChanged(activePlayer);
|
||||
}
|
||||
|
||||
int getActivePlayer() const
|
||||
{
|
||||
return activePlayer;
|
||||
}
|
||||
|
||||
void setGameClosed(bool closed)
|
||||
{
|
||||
gameClosed = closed;
|
||||
}
|
||||
|
||||
bool isGameClosed() const
|
||||
{
|
||||
return gameClosed;
|
||||
}
|
||||
|
||||
void onStartedChanged(bool _started)
|
||||
{
|
||||
if (_started) {
|
||||
emit gameStarted(_started);
|
||||
} else {
|
||||
emit gameStopped();
|
||||
}
|
||||
}
|
||||
|
||||
void setGameStateKnown(bool known)
|
||||
{
|
||||
gameStateKnown = known;
|
||||
}
|
||||
|
||||
int getHostId() const
|
||||
{
|
||||
return hostId;
|
||||
}
|
||||
|
||||
int getSecondsElapsed() const
|
||||
{
|
||||
return secondsElapsed;
|
||||
}
|
||||
|
||||
signals:
|
||||
void updateTimeElapsedLabel(QString newTime);
|
||||
void gameStarted(bool resuming);
|
||||
void gameStopped();
|
||||
void activePhaseChanged(int activePhase);
|
||||
void activePlayerChanged(int playerId);
|
||||
|
||||
public slots:
|
||||
void incrementGameTime();
|
||||
void setGameTime(int _secondsElapsed);
|
||||
|
||||
public:
|
||||
static QString formatElapsedTime(int _secondsElapsed);
|
||||
|
||||
private:
|
||||
QTimer *gameTimer;
|
||||
int secondsElapsed;
|
||||
int hostId;
|
||||
const bool isLocalGame;
|
||||
QList<AbstractClient *> clients;
|
||||
bool gameStateKnown;
|
||||
bool resuming;
|
||||
int currentPhase;
|
||||
int activePlayer;
|
||||
bool gameClosed;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_GAME_STATE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue