aboutsummaryrefslogtreecommitdiffstats
path: root/include/chess_piece.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/chess_piece.hpp')
-rw-r--r--include/chess_piece.hpp55
1 files changed, 40 insertions, 15 deletions
diff --git a/include/chess_piece.hpp b/include/chess_piece.hpp
index f03dad8..60b6fe5 100644
--- a/include/chess_piece.hpp
+++ b/include/chess_piece.hpp
@@ -19,27 +19,51 @@
// names
namespace ymhChessAI {
+// Colour enum class so that we can have the colours in the Chess Piece and not
+// using normal enums because of undefined errors
+
+enum class Colour {
+ White,
+ Black
+};
+
+
+// Base Chess Piece class that is inherited by all other chess pieces
+
class ChessPiece {
public:
+ // constructor sets the initial position of the chess piece to 0, 0
ChessPiece();
+ // using the default constructor for the copy constructor
ChessPiece(const ChessPiece& other) = default;
- ChessPiece(const int& x, const int& y);
+ // initialise piece at a specific location on the board to save code
+ ChessPiece(const int& x, const int& y, const Colour& colour);
+ // using default virtual d, const Colour &colourfault;
virtual ~ChessPiece() = default;
+ // pure virtual function to move a piece as it depends completely on the
+ // implementation of the piece
virtual void move(const int& x, const int& y) = 0;
protected:
+ // current location of the piece which is protected as it can still be
+ // inherited by the piece classes
int m_x, m_y;
-private:
+
+ // defines what colour the piece is
+ Colour m_colour;
};
+
+// King class that provides the class for the king
+
class King : public ChessPiece {
public:
King();
King(const King& other) = default;
- King(const int& x, const int& y);
+ King(const int& x, const int& y, const Colour& colour);
~King() = default;
- void move(const int& x, const int& y);
+ virtual void move(const int& x, const int& y);
protected:
private:
};
@@ -48,10 +72,10 @@ class Queen : public ChessPiece {
public:
Queen();
Queen(const Queen& other) = default;
- Queen(const int& x, const int& y);
+ Queen(const int& x, const int& y, const Colour& colour);
~Queen() = default;
- void move(const int& x, const int& y);
+ virtual void move(const int& x, const int& y);
protected:
private:
};
@@ -60,22 +84,23 @@ class Rook : public ChessPiece {
public:
Rook();
Rook(const Rook& other) = default;
- Rook(const int& x, const int& y);
+ Rook(const int& x, const int& y, const Colour& colour);
~Rook() = default;
- void move(const int& x, const int& y);
+ virtual void move(const int& x, const int& y);
protected:
private:
};
+
class Bishop : public ChessPiece {
public:
Bishop();
- Bishop(const Bishop& other) = default;
- Bishop(const int& x, const int& y);
+ Bishop(const Bishop &other) = default;
+ Bishop(const int& x, const int& y, const Colour& colour);
~Bishop() = default;
- void move(const int& x, const int& y);
+ virtual void move(const int& x, const int& y);
protected:
private:
};
@@ -84,10 +109,10 @@ class Knight : public ChessPiece {
public:
Knight();
Knight(const Knight& other) = default;
- Knight(const int& x, const int& y);
+ Knight(const int& x, const int& y, const Colour& colour);
~Knight() = default;
- void move(const int& x, const int& y);
+ virtual void move(const int& x, const int& y);
protected:
private:
};
@@ -96,10 +121,10 @@ class Pawn : public ChessPiece {
public:
Pawn();
Pawn(const Pawn& other) = default;
- Pawn(const int& x, const int& y);
+ Pawn(const int& x, const int& y, const Colour& colour);
~Pawn() = default;
- void move(const int& x, const int& y);
+ virtual void move(const int& x, const int& y);
protected:
private:
};