-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield.h
More file actions
75 lines (62 loc) · 2.05 KB
/
field.h
File metadata and controls
75 lines (62 loc) · 2.05 KB
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
67
68
69
70
71
72
73
74
75
#pragma once
#include <QMainWindow>
#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QVector>
#include "constants.h"
#include "figure.h"
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
explicit ClickableLabel(QWidget* parent=nullptr );
~ClickableLabel();
int index;//index of the field[0..SIZE]
bool active = true;//true if the field will answer on the click
void indexChange(int);
signals:
void clicked(int);
protected:
void mousePressEvent(QMouseEvent* event);
};
class field : public QMainWindow
{
Q_OBJECT
public:
field() = default;
field(Color fColor, int coord); //constructor
field(const field&); //copy constructor
field& operator= (const field&);
~field();
void setFigure(Figure*);
Figure* removeFigure(); //remove figure from the field
Figure* getFigure();
void setColor(Color c){fieldColor = c;}
Color getColor(){return fieldColor;}
void setCoordinate(int coord){coordinate = coord;}
int getCoordinate(){return coordinate;}
void setBeat(bool beat){this->beat = beat;}
bool getBeat(){return beat;}
void setActive(bool active);
ClickableLabel* getCheckerbutton(){return checkerbutton;}
//sets correct picture according to the field color and figure
void setPicture();
//marks field as chosen
void markField();
void unmarkField(); //make the field as unchosen
void addMove(int);
bool canMoveTo(int);
QVector<int> moves; //all possible moves from this field
QVector<int> beats; //all possible beat moves from the field
private:
Color fieldColor = Color::WHITE; //field`s color
int coordinate = -1; //field index on the board
Figure* figure = nullptr; //figure on the field
bool beat; // whether the figure on this field needs to beat
ClickableLabel *checkerbutton = new ClickableLabel;
// sets picture of the field
// QString path - path of the picture
void setPicture(const QString& path);
};