Compare commits

...

3 Commits

Author SHA1 Message Date
mimie b8cff8bead comments added
Merge branch 'master' of
https://gitarero.ecam.fr/aurele.wittke/OOP_Groupe_1A5_Project.git
2025-05-16 08:42:38 +02:00
edwin 0cb6318a8a Merge branch 'master' of https://gitarero.ecam.fr/aurele.wittke/OOP_1A5_Project 2025-05-16 08:18:44 +02:00
edwin bb029240f2 Turn number after save 2025-05-16 08:18:29 +02:00
1 changed files with 9 additions and 8 deletions

View File

@ -12,7 +12,7 @@ public class Board {
private int y;
private int turnNumber;
private boolean lastTurnPawnTwo = false;//for en passant
private int xTwo;
private int xTwo;//coordinates of pawn that moved two
private int yTwo;
private boolean enPassant = false;
@ -185,13 +185,13 @@ public class Board {
pieces.get(indexPiece).setX(x);
pieces.get(indexPiece).setY(y);
this.turnNumber +=1;
this.turnNumber +=1; // we add 1 to the number of turns played
}
// we now reset our parameters
this.x=-1;
this.y=-1;
// we add 1 to the number of turned played
}
}
}
@ -207,21 +207,20 @@ public class Board {
/* saving-loading feature :*/
public String[] toFileRep() {
String[] saveFile = new String[8]; // creation of the string array which will be the one returned
String[] saveFile = new String[9]; // creation of the string array which will be the one returned
String actualBoard = this.toString();
int nbLine = 0;
saveFile[0] = "";
for(int i = 0; i<200 ;i++) { // there are in total 200 strings in the
if (actualBoard.charAt(i) == '\n') {
nbLine+=1;
if (nbLine < 8 ) {
saveFile[nbLine]= "";
}
}
else {
saveFile[nbLine] += actualBoard.charAt(i);
}
}
saveFile[8] += this.turnNumber;
return saveFile;
}
@ -230,7 +229,6 @@ public class Board {
this.lineNum = 8;
x = -1;
y = -1;
turnNumber= 0;
pieces = new ArrayList<>();
for(int i=0; i<8;i++) { // this will be the Y coordinate
for(int j=0; j<8;j++) { // this will be the X coordinate
@ -249,7 +247,10 @@ public class Board {
}
}
}
turnNumber = Integer.parseInt(array[8]);
System.out.println(turnNumber);
int turn = this.getTurnNumber();
System.out.println(turn);
}
/* The following methods require more work ! */