-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChessPiece.h
71 lines (59 loc) · 1.59 KB
/
ChessPiece.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
//
// Created by Lukas Bos on 30/11/2017.
// This class provides a backbone for all chess pieces
#ifndef CHESS_CHESSPIECE_H
#define CHESS_CHESSPIECE_H
#include <SFML/Graphics.hpp>
#include <array>
#include "constants.h"
#include "Square.h"
#include "Board.h"
#include "PieceColor.h"
using namespace sf;
using namespace std;
class Square;
class Move;
class Board;
class ChessPiece {
protected:
std::vector<Square *> removeMovesLeadingToSelfCheck(vector<Square *> moves);
std::vector<Square *> calculateMovesForDirections(
Square *location,
Vector2i directions[],
Board *board,
PieceColor color,
short amountOfDirections,
short maxAmountOfSteps,
bool considerCheck
);
PieceType type;
string name;
char letter;
public:
const string &getName() const;
char getLetter() const;
void setLetter(char letter);
protected:
Board *board;
Square *location;
PieceColor color;
int amountOfSteps = 0;
public:
/// Initialize a chesspiece
explicit ChessPiece();
/// Initialize a chessPiece
explicit ChessPiece(Board *board, Square *location, PieceColor color);
/// Returns available squares
virtual vector<Square *> getAvailableSquares(bool considerCheck) =0;
/// Returns available moves
virtual vector<Move *> getAvailableMoves(bool considerCheck);
// Getters and setters
PieceType getType() const;
Square *getLocation() const;
void setLocation(Square *location);
PieceColor getColor() const;
int getAmountOfSteps() const;
void increaseAmountOfSteps(int amount);
void decreaseAmountOfSteps(int amount);
};
#endif //CHESS_CHESSPIECE_H