diff --git a/composition echec/test1 b/composition echec/test1 index fb30642..24ae103 100644 --- a/composition echec/test1 +++ b/composition echec/test1 @@ -1,11 +1,11 @@ -BR, ,BB,BQ,BK,BB,BN,BR, -BP,BP,BP, , , , ,BP, -BN, , , , , , , , - , , ,BP,BP,BP,BP, , - , , , , ,WP,WP, , - , , , , ,WN, ,WB, -WP,WP,WP,WP,WP, , ,WP, +BR,BN,BB,BQ,BK,BB,BN,BR, +BP,BP, ,BP, , , ,BP, + , , , ,BP, , , , + , ,BP, , ,BP,BP, , + ,WP,WB, ,WP, , , , + , , , , , , ,WN, +WP, ,WP,WP, ,WP,WP,WP, WR,WN,WB,WQ,WK, , ,WR, -9 -1630 +8 +1230 00000010 diff --git a/src/backend/Board.java b/src/backend/Board.java index 84f6f22..3a4de92 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -340,10 +340,19 @@ public class Board { this.turnNumber +=1; } - int j = 0; + // Promotion + int j1 = 0; // the lines at the top and the bottom of the board + int j2 = 7; for (int i=0; i<8;i++) { - if (this.positionOccupied(x, y)==true) { - + if (this.positionOccupied(i, j1)==true) { // verify if there is a piece on the top line + if(pieces.get(this.whatPiece(i, j1)).getType() == PieceType.Pawn) { // if there is a piece is it a pawn + pieces.get(this.whatPiece(i, j1)).setType(PieceType.Queen); // if yes transform it into a queen + } + } + if (this.positionOccupied(i, j2)==true) { + if(pieces.get(this.whatPiece(i, j2)).getType() == PieceType.Pawn) { + pieces.get(this.whatPiece(i, j2)).setType(PieceType.Queen); + } } } // we now reset our parameters