-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChessPiece.h
87 lines (73 loc) · 1.73 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef CHESSPIECE_H
#define CHESSPIECE_H
#include <vector>
#include "Square.h"
class Square;
class ChessPiece
{
protected:
Square *current_square;
bool has_moved = false;
public:
const bool color;
ChessPiece(bool in_color);
virtual ~ChessPiece();
Square* get_square();
const Square* get_square() const;
virtual bool is_valid_move(const Square &new_square) const = 0;
void move_to(Square &new_square);
// Move a piece from one square to another
void place(Square &starting_square);
void remove_from_play();
virtual char letter_representation() const = 0;
bool is_in_play() const;
};
class Pawn : public ChessPiece
{
public:
Pawn(bool in_color);
virtual ~Pawn();
virtual bool is_valid_move(const Square &new_square) const;
virtual char letter_representation() const;
};
class Knight : public ChessPiece
{
public:
Knight(bool in_color);
virtual ~Knight();
virtual bool is_valid_move(const Square &new_square) const;
virtual char letter_representation() const;
};
class Bishop : public ChessPiece
{
public:
Bishop(bool in_color);
virtual ~Bishop();
virtual bool is_valid_move(const Square &new_square) const;
virtual char letter_representation() const;
};
class Rook : public ChessPiece
{
public:
Rook(bool in_color);
virtual ~Rook();
virtual bool is_valid_move(const Square &new_square) const;
virtual char letter_representation() const;
};
class Queen : public ChessPiece
{
public:
Queen(bool in_color);
virtual ~Queen();
virtual bool is_valid_move(const Square &new_square) const;
virtual char letter_representation() const;
};
class King : public ChessPiece
{
public:
King(bool in_color);
virtual ~King();
virtual bool is_valid_move(const Square &new_square) const;
virtual char letter_representation() const;
};
#endif