-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueen.cpp
More file actions
38 lines (32 loc) · 1.07 KB
/
Copy pathQueen.cpp
File metadata and controls
38 lines (32 loc) · 1.07 KB
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
//Courtney King and Elizabeth Mathew (cking61 and emathew4)
//Function file for Queen piece
#include "Queen.h"
bool Queen::legal_move_shape( std::pair< char , char > start , std::pair< char , char > end ) const {
char startLet = std::get<0>(start);
char startNum = std::get<1>(start);
char endLet = std::get<0>(end);
char endNum = std::get<1>(end);
//Bishop Qualities of a Queen
//calculating the difference between rows and columns
int rowDiff = startNum - endNum;
int colDiff = startLet - endLet;
//Cases when difference is negative
if (rowDiff < 0) {
rowDiff = rowDiff * -1;
}
if (colDiff < 0) {
colDiff = colDiff * -1;
}
if (colDiff == rowDiff) {
return true;
}
else if ((startLet == endLet && startNum != endNum)) {
return true;
}
else if ((startLet != endLet && startNum == endNum)) {
return true;
}
else {
return false;
}
}