1 /*
2     SPDX-FileCopyrightText: 2008-2009 Stefan Majewsky <majewsky@gmx.net>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef KDIAMOND_GAMESTATE_H
8 #define KDIAMOND_GAMESTATE_H
9 
10 #include <QObject>
11 
12 namespace KDiamond
13 {
14 
15 class GameStatePrivate;
16 
17 //base duration of a game in seconds
18 const int GameDuration = 200;
19 
20 enum Mode {
21     NormalGame,
22     UntimedGame
23 };
24 enum State {
25     Playing,
26     Paused,
27     Finished
28 };
29 
30 class GameState : public QObject
31 {
32     Q_OBJECT
33 public:
34     GameState();
35     ~GameState() override;
36 
37     Mode mode() const;
38     State state() const;
39     int leftTime() const;
40     int points() const;
41 
42     void setMode(Mode mode);
43     void setState(State state);
44 public Q_SLOTS:
45     void addPoints(int removedDiamonds);
46     void removePoints(int points);
47     void resetCascadeCounter();
48     void startNewGame();
49     void update(bool forceRecalculation = false);
50 Q_SIGNALS:
51     void message(const QString &text); //text == QString() means: hide the message popup
52     void stateChanged(KDiamond::State state); //warning: moc needs the full identifier of KDiamond::State
53     void pointsChanged(int points);
54     void leftTimeChanged(int seconds);
55 protected:
56     void timerEvent(QTimerEvent *event) override;
57 private:
58     GameStatePrivate *p;
59 };
60 
61 }
62 
63 #endif // KDIAMOND_GAMESTATE_H
64