-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiecesManipulator.h
83 lines (62 loc) · 1.64 KB
/
PiecesManipulator.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef PIECESMANIPULATOR_H
#define PIECESMANIPULATOR_H
#include "Board.h"
#include "ChessPiece.h"
#include "Movement.h"
#include "SimpleMovement.h"
#include "ComplexMovement.h"
#include <stack>
namespace Chess {
namespace ChessComponents {
namespace PlayField {
class Board;
}
}
namespace GameLogic {
namespace GameComponents{
using namespace Chess::GameLogic::Movements;
using namespace Chess::ChessComponents::ChessPieces;
enum Error
{
WrongColour,
EmptyPosition,
Success,
InvalidDestination,
Check,
ReachedEnd
};
enum CastlingType
{
Kingside,
Queenside
};
const int KSCASTLING_KING_X = 6;
const int KSCASTLING_ROOK_X = 5;
const int QSCASTLING_KING_X = 2;
const int QSCASTLING_ROOK_X = 3;
const Position WHITE_KING_POSITION = Position( 4, 7 );
const Position BLACK_KING_POSITION = Position( 4, 0 );
const Position WHITE_K_ROOK_POSITION = Position( 7, 7 );
const Position WHITE_Q_ROOK_POSITION = Position( 0, 7 );
const Position BLACK_K_ROOK_POSITION = Position( 7, 0 );
const Position BLACK_Q_ROOK_POSITION = Position( 0, 0 );
class PiecesManipulator
{
public:
PiecesManipulator( Board* board = 0 );
~PiecesManipulator();
void undo();
Error makeAMove( const Position& from, const Position& to , Colour colour );
bool isCastlingAllowed( ChessPiece* const king, ChessPiece* const rook, const CastlingType& type );
bool castling( const Colour& colour, const CastlingType& type );
void destroy();
bool kingInCheck( const Colour& colour );
private:
stack< Movement* > m_moves;
Colour m_currentColour;
Board* m_board;
};
}
}
}
#endif // PIECESMANIPULATOR_H