Turn number after save
This commit is contained in:
parent
fefb67a12a
commit
bb029240f2
|
|
@ -187,21 +187,20 @@ public class Board {
|
||||||
/* saving-loading feature :*/
|
/* saving-loading feature :*/
|
||||||
|
|
||||||
public String[] toFileRep() {
|
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();
|
String actualBoard = this.toString();
|
||||||
int nbLine = 0;
|
int nbLine = 0;
|
||||||
saveFile[0] = "";
|
saveFile[0] = "";
|
||||||
for(int i = 0; i<200 ;i++) { // there are in total 200 strings in the
|
for(int i = 0; i<200 ;i++) { // there are in total 200 strings in the
|
||||||
if (actualBoard.charAt(i) == '\n') {
|
if (actualBoard.charAt(i) == '\n') {
|
||||||
nbLine+=1;
|
nbLine+=1;
|
||||||
if (nbLine < 8 ) {
|
|
||||||
saveFile[nbLine]= "";
|
saveFile[nbLine]= "";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
saveFile[nbLine] += actualBoard.charAt(i);
|
saveFile[nbLine] += actualBoard.charAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
saveFile[8] += this.turnNumber;
|
||||||
return saveFile;
|
return saveFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,7 +209,6 @@ public class Board {
|
||||||
this.lineNum = 8;
|
this.lineNum = 8;
|
||||||
x = -1;
|
x = -1;
|
||||||
y = -1;
|
y = -1;
|
||||||
turnNumber= 0;
|
|
||||||
pieces = new ArrayList<>();
|
pieces = new ArrayList<>();
|
||||||
for(int i=0; i<8;i++) { // this will be the Y coordinate
|
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
|
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 ! */
|
/* The following methods require more work ! */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue