-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathking.cpp
More file actions
36 lines (28 loc) · 818 Bytes
/
king.cpp
File metadata and controls
36 lines (28 loc) · 818 Bytes
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
#include "king.h"
char King::print() const {
if (this->colour == white) {
return 'K';
} else if (this->colour == black) {
return 'k';
} else {
return '?';
}
}
Name King::get_name() const {
return king;
}
bool King::check_move(Cube chessboard[5][5][5], int const dst_rank, int const dst_file, int const dst_level) const {
if (abs(dst_rank - rank) > 1 || abs(dst_file - file) > 1 || abs(dst_level - level) > 1) {
return false;
}
if (Bishop::check_move(chessboard, dst_rank, dst_file, dst_level)) {
return true;
}
if (Rook::check_move(chessboard, dst_rank, dst_file, dst_level)) {
return true;
}
if (Unicorn::check_move(chessboard, dst_rank, dst_file, dst_level)) {
return true;
}
return false;
}