-
Notifications
You must be signed in to change notification settings - Fork 0
/
MinesArea.h
66 lines (53 loc) · 1.68 KB
/
MinesArea.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 MINESWEEPER_H
#define MINESWEEPER_H
#include <QObject>
#include <QVector>
#include <QSettings>
#include "MCell.h"
struct prevState
{
int x;
int y;
int state;
};
class Minesweeper : public QObject
{
Q_OBJECT
public:
explicit Minesweeper();
Q_INVOKABLE int cellsWidthNumbers() { return m_cellsWidthSize; }
Q_INVOKABLE int cellsHeightNumbers() { return m_cellsHeightSize; }
Q_INVOKABLE void newGame();
Q_INVOKABLE void setAreaSize(const int numbersX, const int numbersY, const int bombs = 0);
Q_INVOKABLE int getCellState(const int);
Q_INVOKABLE int getCellDigit(const int);
Q_INVOKABLE bool getCellVisibility(const int);
Q_INVOKABLE void leftMouseBtnClick(const int);
Q_INVOKABLE void rightMouseBtnClick(const int);
Q_INVOKABLE void middleMouseClick(const int, const int);
void firstAreaBuild(const int position);
void foundEmptyCells(const int position);
~Minesweeper();
signals:
void imageUpdate();
void areaResize();
void victorySignal();
void loseSignal();
private:
int m_cellsWidthSize;
int m_cellsHeightSize;
int m_bombsNumber;
QVector<QVector <MCell*>> m_cells2dArr;
QVector<prevState> m_prevStates;
//convertation position to X-Y coordinates
QPair<int, int> posToCords(int position);
int cordsToPos(const int, const int);
QSettings m_settings;
void readSettings();
void writeSettings();
//this function generate empty fields around start position;
void removeElement(QVector<QPair <int, int> >&, int, int);
void showAllBombs();
void checkVictory();
};
#endif // MINESWEEPER_H