Compare commits
3 Commits
c6912dc166
...
b8cff8bead
| Author | SHA1 | Date |
|---|---|---|
|
|
b8cff8bead | |
|
|
0cb6318a8a | |
|
|
bb029240f2 |
|
|
@ -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 ! */
|
||||
|
|
|
|||
Loading…
Reference in New Issue