changed name of setSelectXY to isAPieceThere, working on pawn promotion
This commit is contained in:
parent
f14ed809e5
commit
3e610d6fba
|
|
@ -123,7 +123,7 @@ public class Board {
|
|||
|
||||
public void userTouch(int x, int y) {
|
||||
if(selectX == -1 && selectY == -1) { // if initial position for select x and y
|
||||
if(setSelectXY(x,y) == true) { // checks for pieces at the position x and y
|
||||
if(isAPieceThere(x,y) == true) { // checks for pieces at the position x and y
|
||||
selectX = x; //set select x to x
|
||||
selectY = y; // same with y
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ public class Board {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean setSelectXY(int x, int y) { //verify if there is a piece at the coordinates of the point selectX;selectY
|
||||
public boolean isAPieceThere(int x, int y) { //verify if there is a piece at the coordinates of the point selectX;selectY
|
||||
boolean isPieceHere = false; // setting bool var
|
||||
|
||||
for (Piece piece : pieces) { // iterate trough all pieces
|
||||
|
|
|
|||
|
|
@ -18,13 +18,15 @@ public class Move {
|
|||
//helper function to change the coordinates of a piece
|
||||
public void movePiece(int selectX, int selectY, int toX, int toY) {
|
||||
Piece movingPiece = null ; // initializing variable to work with and store it
|
||||
PieceType type = null;
|
||||
boolean color = true;
|
||||
|
||||
for (Piece piece : pieces) { // iterate trough all pieces
|
||||
|
||||
if(piece.getX() == selectX && piece.getY() == selectY) { // if the coordinates selected and the coordinate of a piece on the board matches, the loop will activate
|
||||
movingPiece = piece; //storing in memory the piece
|
||||
|
||||
if (board.setSelectXY(toX, toY)){//checking if a piece is at the arrival coordinates
|
||||
if (board.isAPieceThere(toX, toY)){//checking if a piece is at the arrival coordinates
|
||||
needPieceDeletion(toX, toY); //if a piece is at arrival coord, remove the piece
|
||||
}
|
||||
movingPiece.setX(toX); // change coordinates to the new coordinate
|
||||
|
|
@ -44,4 +46,7 @@ public class Move {
|
|||
}
|
||||
}
|
||||
}
|
||||
private void pawnPromotion(int x) {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue