diff --git a/OOP_3B5_Project/src/backend/Board.java b/OOP_3B5_Project/src/backend/Board.java index 3cd4892..3686bdd 100644 --- a/OOP_3B5_Project/src/backend/Board.java +++ b/OOP_3B5_Project/src/backend/Board.java @@ -7,7 +7,7 @@ public class Board { private int line; // constructors for column and line public ArrayList pieces; // list of all pieces on the board private Piece newPiece; // to add a piece to the board - private int turnNb = 0; + public int turnNb = 0; private int selectX = -1; private int selectY = -1; private Move move; @@ -31,7 +31,11 @@ public class Board { } public int getTurnNumber() { - return this.turnNb; + return turnNb; + } + + public void setTurnNb(int turnNb) { + this.turnNb = turnNb; } public int getZero() { @@ -115,7 +119,6 @@ public class Board { boardState += bOrW + "[" + type + "] (" + xCord + ";" + yCord + ")\n"; // str concatenation bOrW = ""; //reinitialization of this local var bc white and black will pile up if not - zero++; } return boardState; //gives back the full string @@ -145,7 +148,6 @@ public class Board { } else { move.movePiece(selectX, selectY, x, y); //if not clicking in same position, calls move piece to change the piece coordinates - turnNb++; // Increment turn number and change turn color selectX = -1; selectY = -1; } @@ -208,7 +210,7 @@ public class Board { type = myPiece.getType(); color = myPiece.isWhite(); - yCord = myPiece.getY(); + yCord = myPiece.getY(); } diff --git a/OOP_3B5_Project/src/backend/Move.java b/OOP_3B5_Project/src/backend/Move.java index 237e934..9edb6d4 100644 --- a/OOP_3B5_Project/src/backend/Move.java +++ b/OOP_3B5_Project/src/backend/Move.java @@ -20,7 +20,8 @@ public class Move { Piece movingPiece = null ; // initializing variable to work with and store it PieceType type = null; boolean color = true; - + int turnNb = board.getTurnNumber(); // Increment turn number and change turn color; // Increment turn number and change turn color + 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 @@ -41,6 +42,7 @@ public class Move { } movingPiece.setX(toX); // change coordinates to the new coordinate movingPiece.setY(toY); + board.setTurnNb(turnNb + 1); } break; }