blob: 5e23444be4da80712251a9048b7b6afff6197d6a (
plain)
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
|
#include "../include/chess_ai.hpp"
chess_ai::chess_piece::chess_piece(piece_type type, piece_colour colour) {
this->type = type;
this->colour = colour;
if(colour == black) {
y = 0;
} else {
y = 7;
}
if(type == king) {
x = 4;
} else {
x = 3;
}
}
chess_ai::chess_piece::chess_piece(piece_type type, piece_colour colour,
unsigned x, unsigned y) {
this->type = type;
this->colour = colour;
this->x = x;
this->y = y;
}
void chess_ai::chess_piece::set_type(piece_type type) {
this->type = type;
}
void chess_ai::chess_piece::set_colour(piece_colour colour) {
this->colour = colour;
}
void chess_ai::chess_piece::set_x(unsigned x) {
this->x = x;
}
void chess_ai::chess_piece::set_y(unsigned y) {
this->y = y;
}
std::string chess_ai::chess_piece::str() {
if(type == empty)
return " ";
else if(type == pawn)
return "p";
else if(type == rook)
return "r";
else if(type == knight)
return "n";
else if(type == bishop)
return "b";
else if(type == queen)
return "q";
return "k";
}
|