add of the enPassant in the save of the files
Merge branch 'master' of https://gitarero.ecam.fr/aurele.wittke/OOP_1A5_Project
This commit is contained in:
parent
0cb6318a8a
commit
3c8c060011
|
|
@ -11,10 +11,12 @@ public class Board {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int turnNumber;
|
private int turnNumber;
|
||||||
private boolean lastTurnPawnTwo = false;//for en passant
|
private boolean lastTurnPawnTwo;//for en passant
|
||||||
private int xTwo;
|
private int xTwo;
|
||||||
private int yTwo;
|
private int yTwo;
|
||||||
private boolean enPassant = false;
|
private boolean enPassant;
|
||||||
|
private ArrayList<String> previousBoard;
|
||||||
|
|
||||||
|
|
||||||
public Board(int colNum, int lineNum) {
|
public Board(int colNum, int lineNum) {
|
||||||
this.colNum = colNum;
|
this.colNum = colNum;
|
||||||
|
|
@ -23,6 +25,9 @@ public class Board {
|
||||||
x = -1;
|
x = -1;
|
||||||
y = -1;
|
y = -1;
|
||||||
turnNumber= 0;
|
turnNumber= 0;
|
||||||
|
enPassant = false;
|
||||||
|
lastTurnPawnTwo = false;
|
||||||
|
previousBoard = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
|
@ -89,7 +94,7 @@ public class Board {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pieces = basePieces;
|
pieces = basePieces;
|
||||||
|
previousBoard.add(this.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanBoard() {
|
public void cleanBoard() {
|
||||||
|
|
@ -111,6 +116,22 @@ public class Board {
|
||||||
}
|
}
|
||||||
outputString += "\n";
|
outputString += "\n";
|
||||||
}
|
}
|
||||||
|
outputString+= turnNumber;
|
||||||
|
outputString+= "\n";
|
||||||
|
if (this.lastTurnPawnTwo == false) {
|
||||||
|
outputString+= "0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputString+= "1";
|
||||||
|
}
|
||||||
|
outputString += xTwo;
|
||||||
|
outputString += yTwo;
|
||||||
|
if (this.enPassant == false) {
|
||||||
|
outputString+="0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outputString+= "1";
|
||||||
|
}
|
||||||
return outputString;
|
return outputString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,7 +228,7 @@ public class Board {
|
||||||
/* saving-loading feature :*/
|
/* saving-loading feature :*/
|
||||||
|
|
||||||
public String[] toFileRep() {
|
public String[] toFileRep() {
|
||||||
String[] saveFile = new String[9]; // creation of the string array which will be the one returned
|
String[] saveFile = new String[10]; // 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] = "";
|
||||||
|
|
@ -220,7 +241,23 @@ public class Board {
|
||||||
saveFile[nbLine] += actualBoard.charAt(i);
|
saveFile[nbLine] += actualBoard.charAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
saveFile[8]="";
|
||||||
saveFile[8] += this.turnNumber;
|
saveFile[8] += this.turnNumber;
|
||||||
|
saveFile[9]="";
|
||||||
|
if (this.lastTurnPawnTwo == false) {
|
||||||
|
saveFile[9]+= "0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
saveFile[9]+= "1";
|
||||||
|
}
|
||||||
|
saveFile[9] += xTwo;
|
||||||
|
saveFile[9] += yTwo;
|
||||||
|
if (this.enPassant == false) {
|
||||||
|
saveFile[9]+="0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
saveFile[9]+= "1";
|
||||||
|
}
|
||||||
return saveFile;
|
return saveFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,7 +287,21 @@ public class Board {
|
||||||
turnNumber = Integer.parseInt(array[8]);
|
turnNumber = Integer.parseInt(array[8]);
|
||||||
System.out.println(turnNumber);
|
System.out.println(turnNumber);
|
||||||
int turn = this.getTurnNumber();
|
int turn = this.getTurnNumber();
|
||||||
System.out.println(turn);
|
System.out.println(turn);
|
||||||
|
if(array[9].charAt(0)==0) {
|
||||||
|
lastTurnPawnTwo = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastTurnPawnTwo = true;
|
||||||
|
}
|
||||||
|
xTwo = Character.getNumericValue(array[9].charAt(1));
|
||||||
|
yTwo = Character.getNumericValue(array[9].charAt(2));
|
||||||
|
if(array[9].charAt(3)==0) {
|
||||||
|
enPassant = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enPassant = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following methods require more work ! */
|
/* The following methods require more work ! */
|
||||||
|
|
@ -548,6 +599,7 @@ public class Board {
|
||||||
public void undoLastMove() {
|
public void undoLastMove() {
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Board(Board board) {
|
public Board(Board board) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue