File indexing completed on 2024-07-21 03:28:56

0001 /*
0002     SPDX-FileCopyrightText: 2005 Albert Astals Cid <aacid@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef BLINKENGAME_H
0008 #define BLINKENGAME_H
0009 
0010 #include <QObject>
0011 #include <QList>
0012 
0013 class QTimer;
0014 
0015 class soundsPlayer;
0016 
0017 class blinkenGame : public QObject
0018 {
0019 Q_OBJECT
0020     public:
0021         blinkenGame();
0022         ~blinkenGame() override;
0023         
0024         enum gamePhase { starting, choosingLevel, waiting3, waiting2, waiting1, learningTheSequence, typingTheSequence };
0025         enum color
0026         {
0027             none = 0,
0028             red = 1,
0029             green = 2,
0030             blue = 4,
0031             yellow = 8,
0032             all = 15};
0033         
0034         int level() const;
0035         bool canType() const;
0036         gamePhase phase() const;
0037         int score() const;
0038         
0039         void clicked(color c);
0040         void setPhase(gamePhase p);
0041         void start(int level);
0042     
0043     Q_SIGNALS:
0044         void gameEnded();
0045         void phaseChanged();
0046         void highlight(blinkenGame::color c, bool unhighlight);
0047         
0048     private Q_SLOTS:
0049         void nextSound();
0050         void soundEnded();
0051         void unhighlight();
0052         void waiting();
0053         
0054     private:
0055         void nextRound();
0056         color generateColor();
0057     
0058         gamePhase m_phase;
0059         int m_level;
0060         int m_sequenceLength;
0061         
0062         QTimer *m_waitTimer;
0063         
0064         soundsPlayer *m_soundsPlayer;
0065         QList<color> m_sequence;
0066         QList<color>::const_iterator m_nextColor;
0067 };
0068 
0069 #endif