modified userTouch to allow movements only to highlighted positions
(+made sure turn increments only if a move is made)
This commit is contained in:
parent
70b945dbfa
commit
28b5df793b
|
|
@ -157,16 +157,16 @@ public class Board {
|
|||
this.pieces.remove(whatPiece(x,y)); //if there is a piece at the position we want to move we remove it from the array list
|
||||
}
|
||||
}
|
||||
if(this.positionOccupied(x, y) == false || pieces.get(whatPiece(x,y)).isWhite() != pieces.get(whatPiece(this.x,this.y)).isWhite()) {//moves the piece only if the position selected is not occupied by a piece of the same color
|
||||
if((this.positionOccupied(x, y) == false || pieces.get(whatPiece(x,y)).isWhite() != pieces.get(whatPiece(this.x,this.y)).isWhite()) && (isHighlighted(x,y))) {//moves the piece only if the position selected is not occupied by a piece of the same color
|
||||
int indexPiece = this.whatPiece(this.x, this.y);
|
||||
pieces.get(indexPiece).setX(x);
|
||||
pieces.get(indexPiece).setY(y);
|
||||
this.turnNumber +=1;
|
||||
}
|
||||
// we now reset our parameters
|
||||
this.x=-1;
|
||||
this.y=-1;
|
||||
// we add 1 to the number of turned played
|
||||
this.turnNumber +=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue