-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiece.h
85 lines (67 loc) · 1.65 KB
/
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
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
//
// Created by Sindre Nistad on 6/19/16.
//
//===============================
// include guard
#ifndef CHESS_PIECE_H
#define CHESS_PIECE_H
//===============================
// forward declared dependencies
//class Board;
//===============================
// included dependencies
#include "string"
#include "Board.h"
//===============================
// define enums
enum Type {none, pawn, knight, bishop, rook, queen, king};
enum Color {black, white};
// structs
//struct Position{
// int column;
// int row;
//};
class Board;
class Position{
private:
int column;
int row;
std::string position;
public:
Position(int row, int column);
Position(std::string position);
Position();
void setPosition(int row, int column);
void setPosition(std::string position);
int getRow(void);
int getColumn(void);
std::string getPosition(void);
};
//===============================
// The Piece class
class Piece {
private:
Type type;
Color color;
Position position;
bool hasMoved;
bool canMovePawn(Board* board, std::string move_to);
public:
Piece();
Piece(Type type, Color color);
Piece(Type t, Color c, int column, int row);
Piece(Type t, Color c, Position position);
~Piece();
char to_string(void);
bool canMove(Board* board, std::string move_to);
bool canTake(Board* board, std::string opposing_piece);
bool move(Board* board, std::string move_to);
// Setters
void setPosition(Position position);
void setPosition(int column, int row);
// Getters
Position getPosition(void);
Type getType(void);
Color getColor(void);
};
#endif //CHESS_PIECE_H