-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRook.cpp
32 lines (26 loc) · 822 Bytes
/
Rook.cpp
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
#include <iostream>
#include "Rook.h"
#include "Piece.h"
using std::pair;
// Checks to see if the entered move is legal for the piece
bool Rook::legal_move_shape( pair< char , char > start , pair< char , char > end ) const {
if(start.first < 'A' || start.first > 'H' ||
end.first < 'A' || end.first > 'H') {
// Not Legal Move. Too far horizontal off board
return false;
}
if(start.second < '1' || start.second > '8' ||
end.second < '1' || end.second > '8') {
// Not Legal Move. Too far vertical off board
return false;
}
if(start.first != end.first && start.second != end.second) {
// Rook did not move in a straight line
return false;
}
if(start.first == end.first && start.second == end.second) {
// Rook did not move at all
return false;
}
return true;
}