From 3e0f23aafde8d9f5768a0fdd4a8bbaeadb58f05f Mon Sep 17 00:00:00 2001 From: edwin Date: Thu, 22 May 2025 09:37:19 +0200 Subject: [PATCH] Undo auto player play black then white --- src/backend/Board.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backend/Board.java b/src/backend/Board.java index b928c48..84f6f22 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -248,10 +248,12 @@ public class Board { public void userTouch(int x, int y) { boolean positionOccupied = this.positionOccupied(x, y) ; // verify if the square is occupied - if ((this.x == -1 ) && (positionOccupied == true)){ // set coordinates of the piece to play + boolean isWhitePiece = pieces.get(this.whatPiece(x, y)).isWhite(); + if(isWhitePiece == this.isTurnWhite()) { this.x = x; this.y = y; + } } else { if((this.x == x) && (this.y == y)) { // reset since square is already selected @@ -338,7 +340,12 @@ public class Board { this.turnNumber +=1; } - + int j = 0; + for (int i=0; i<8;i++) { + if (this.positionOccupied(x, y)==true) { + + } + } // we now reset our parameters this.x=-1; this.y=-1; @@ -1283,9 +1290,6 @@ public class Board { pieceToMove = piece; } } - if (pieceToMove == null) { - return; - } Piece pieceTargeted = null; for (int i=0; i < this.pieces.size(); i++) { Piece piece = this.pieces.get(i); @@ -1301,6 +1305,7 @@ public class Board { this.turnNumber = this.turnNumber + 1; this.x = -1; this.y = -1; + previousBoard.add(this.toString()); } }