-
Notifications
You must be signed in to change notification settings - Fork 0
/
NineHoles.h
66 lines (50 loc) · 1.15 KB
/
NineHoles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef NINEHOLES_H
#define NINEHOLES_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class NineHoles; }
QT_END_NAMESPACE
class Hole;
class NineHoles : public QMainWindow {
Q_OBJECT
public:
enum Player {
RedPlayer,
BluePlayer
};
Q_ENUM(Player)
enum Phase {
DropPhase,
MovePhase
};
Q_ENUM(Phase)
NineHoles(QWidget *parent = nullptr);
virtual ~NineHoles();
Hole* holeAt(int row, int col) const;
signals:
void gameOver(Player player);
private:
Ui::NineHoles *ui;
Hole* m_holes[9];
Player m_player;
Phase m_phase;
int m_dropCount;
Hole* m_selected;
void drop(Hole* hole);
void move(Hole* hole);
void switchPlayer();
void clearSelectable();
QList<Hole*> findSelectable(Hole* hole);
bool checkRow(Player player, int col);
bool checkCol(Player player, int row);
bool checkDiagonals(Player player);
bool isGameOver(Hole* hole);
private slots:
void play(int id);
void reset();
void showAbout();
void showAuthor();
void showGameOver(Player player);
void updateStatusBar();
};
#endif // NINEHOLES_H