Turn number after save
This commit is contained in:
parent
fefb67a12a
commit
bb029240f2
|
|
@ -187,21 +187,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;
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +209,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
|
||||
|
|
@ -229,7 +227,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