-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpiece.h
47 lines (37 loc) · 927 Bytes
/
piece.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
#ifndef __PIECE_H
#define __PIECE_H
#include <QImage>
#include <QObject>
class Piece {
public:
enum class MovementType { Leaper, Slider, Rider, Hopper, EnPassant, Castle };
enum class CaptureRule { CannotCapture, CanCapture, MustCapture };
struct MovementRule {
MovementType type;
int dx;
int dy;
bool omnidirectional;
bool firstMove;
bool setEp;
CaptureRule captures;
};
static QRectF iconBox;
QString name;
QList<MovementRule> moveRules;
bool royal;
int promotes;
explicit Piece(QString name);
[[nodiscard]] const QImage &icon(bool white) const { return white ? whiteIcon : blackIcon; }
private:
QImage whiteIcon;
QImage blackIcon;
};
class GamePiece {
public:
Piece *piece;
bool white;
bool moved;
GamePiece() : piece(nullptr), white(false), moved(false) {}
GamePiece(Piece *piece, bool white) : piece(piece), white(white), moved(false) {}
};
#endif