added docstring to explain the ishighlighted method
This commit is contained in:
parent
f3be5c6f6c
commit
8dc6c67272
|
|
@ -239,15 +239,28 @@ public class Board {
|
|||
}
|
||||
} else if (type == PieceType.Bishop) {
|
||||
int k = 8; // default range value for bishop to cover the board wherever he is
|
||||
for(int i = 1; i < k;i++) {
|
||||
if (getPiece(selectX + i, selectY + i) != null) {
|
||||
k = i;
|
||||
break;
|
||||
}
|
||||
if (selectX + i == x && selectY + i == y) {
|
||||
isAPieceHere = true;
|
||||
for(int i = 1; i < k; i++) { // range from 1 to k up until the follwing if statement is true
|
||||
if (getPiece(selectX + i, selectY + i) != null) { // true Iff there is a piece at the specified position which are the direction of the specified piece !
|
||||
if (color != getPiece(selectX + i, selectY + i).isWhite()) { // another condition that will be lauched IFF the case has a piece in it and IFF the piece is of a != color than the played piece
|
||||
k = i+1; // if color is diffrent, change K to i (number of case before a piece) + 1 (if the piece is of a different color i can eat it)
|
||||
|
||||
if (selectX + i == x && selectY + i == y) { // iterates trough i but k = i+1 so the for loop will itterate until i+1 allowing for the opposite color piece to be eaten
|
||||
isAPieceHere = true; //set the boolean var to true
|
||||
}
|
||||
break; // break the loop
|
||||
|
||||
} else {
|
||||
k = i; // if the condition "if (color != getPiece(selectX + i, selectY + i).isWhite())" is not compliant, this else statement will change k to be i, hence, the same colored piece present in its path will not be eaten
|
||||
break;
|
||||
}
|
||||
}
|
||||
} k = 8;
|
||||
if(selectX + i == x && selectY + i == y) { // iterate trough i up until i as k = i, it is needed to not light up the pieces of the same color a the played piece
|
||||
isAPieceHere = true;//set the boolean var to true
|
||||
}
|
||||
|
||||
|
||||
|
||||
} k = 8;
|
||||
for (int i = 1; i < k; i++) {
|
||||
if (getPiece(selectX - i, selectY - i) != null) {
|
||||
k = i;
|
||||
|
|
@ -266,7 +279,7 @@ public class Board {
|
|||
isAPieceHere = true;
|
||||
|
||||
}
|
||||
} k = 8;
|
||||
} k = 8;
|
||||
for (int i = 1; i < k; i++) {
|
||||
if (getPiece(selectX + i, selectY - i) != null) {
|
||||
if (color != getPiece(selectX + i, selectY - i).isWhite()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue