ca marche paaaaaaas
This commit is contained in:
parent
71ee1b1eb3
commit
30dfb5a6cd
|
|
@ -0,0 +1,9 @@
|
|||
BR, ,BB,BQ,BK,BB,BN,BR
|
||||
BP,BP,BP,BP,BP,BP,BP,BP
|
||||
, ,BN, , , , ,
|
||||
, , , , , , ,
|
||||
, , ,WP, ,WB, ,
|
||||
, , , , , , ,
|
||||
WP,WP,WP, ,WP,WP,WP,WP
|
||||
WR,WN, ,WQ,WK,WB,WN,WR
|
||||
3B
|
||||
|
|
@ -195,11 +195,18 @@ public class Board {
|
|||
return boardToFile.toFile();
|
||||
}
|
||||
|
||||
public Board(String[] array) {
|
||||
FileBoard boardToFile = new FileBoard(array);
|
||||
this.board = boardToFile.getBoard();
|
||||
this.turnColor = boardToFile.isTurnColor();
|
||||
this.turnNumber = boardToFile.getTurnNumber();
|
||||
public Board(ArrayList<ArrayList<Piece>> board,int turnNumber,boolean turnColor) {
|
||||
this.board = board;
|
||||
this.turnNumber = turnNumber;
|
||||
this.turnColor = turnColor;
|
||||
}
|
||||
public Board toBoard(String[] array) {
|
||||
FileBoard fileToBoard = new FileBoard(array);
|
||||
Board boardF = new Board(fileToBoard.getBoard(),fileToBoard.getTurnNumber(),fileToBoard.isTurnColor());
|
||||
return boardF;
|
||||
// this.turnColor = fileToBoard.isTurnColor();
|
||||
// this.turnNumber = fileToBoard.getTurnNumber();
|
||||
// boardHistory.add(new BoardHistory(board,turnNumber,turnColor));
|
||||
}
|
||||
|
||||
/* The following methods require more work ! */
|
||||
|
|
@ -213,6 +220,10 @@ public class Board {
|
|||
return toBeReturned;
|
||||
}
|
||||
|
||||
public ArrayList<ArrayList<Piece>> getBoard() {
|
||||
return board;
|
||||
}
|
||||
|
||||
public void undoLastMove() {
|
||||
if (boardHistory.size()>=1) {
|
||||
board = boardHistory.get(boardHistory.size() - 1).getBoard();
|
||||
|
|
@ -233,4 +244,20 @@ public class Board {
|
|||
|
||||
}
|
||||
|
||||
public void setBoard(ArrayList<ArrayList<Piece>> board) {
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
public void setTurnNumber(int turnNumber) {
|
||||
this.turnNumber = turnNumber;
|
||||
}
|
||||
|
||||
public void setTurnColor(boolean turnColor) {
|
||||
this.turnColor = turnColor;
|
||||
}
|
||||
|
||||
public void setBoardHistory(LinkedList<BoardHistory> boardHistory) {
|
||||
this.boardHistory = boardHistory;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package backend;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class FileBoard {
|
||||
private ArrayList<ArrayList<Piece>> board = new ArrayList<>();
|
||||
private int turnNumber;
|
||||
private boolean turnColor;
|
||||
public ArrayList<ArrayList<Piece>> board = new ArrayList<>();
|
||||
public int turnNumber;
|
||||
public boolean turnColor;
|
||||
public FileBoard(ArrayList<ArrayList<Piece>> board,int turnNumber, boolean turnColor) {
|
||||
this.board = board;
|
||||
this.turnColor = turnColor;
|
||||
|
|
@ -15,7 +15,7 @@ public class FileBoard {
|
|||
String tC;
|
||||
String toBeWritten = " ";
|
||||
String activeLine = "";
|
||||
String[] boardFile = new String[8];
|
||||
String[] boardFile = new String[9];
|
||||
for (int y = 0;y<8;y++) {
|
||||
for (int x = 0;x<8;x++) {
|
||||
if (x!= 7) {
|
||||
|
|
@ -69,19 +69,18 @@ public class FileBoard {
|
|||
// System.out.println(pieceChar); // Debug
|
||||
color = pieceChar.charAt(0);
|
||||
type = pieceChar.charAt(1);
|
||||
if (color == 'W') {col = true;} else {col = false;}
|
||||
col = color == 'W';
|
||||
Piece piece = PieceCreation.createPiece(x,y,PieceType.fromSummary(type),col);
|
||||
boardF.get(y).set(x, piece);
|
||||
}
|
||||
}
|
||||
}
|
||||
pieceChar = getCharAt(boardFile,0,7);
|
||||
type = pieceChar.charAt(0);
|
||||
color = pieceChar.charAt(1);
|
||||
if (color == 'B') {col = false;} else {col = true;}
|
||||
pieceChar = getCharAt(boardFile,0,8);
|
||||
char turnNb = pieceChar.charAt(0);
|
||||
char colorChar = pieceChar.charAt(1);
|
||||
this.board = boardF;
|
||||
this.turnColor = col;
|
||||
this.turnNumber = type;
|
||||
this.turnColor = colorChar == 'W';
|
||||
this.turnNumber = turnNb - '0';
|
||||
|
||||
}
|
||||
public String getCharAt(String[] str,int x,int y) {
|
||||
|
|
@ -96,5 +95,14 @@ public class FileBoard {
|
|||
public boolean isTurnColor() {
|
||||
return turnColor;
|
||||
}
|
||||
public void setBoard(ArrayList<ArrayList<Piece>> board) {
|
||||
this.board = board;
|
||||
}
|
||||
public void setTurnNumber(int turnNumber) {
|
||||
this.turnNumber = turnNumber;
|
||||
}
|
||||
public void setTurnColor(boolean turnColor) {
|
||||
this.turnColor = turnColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class Game extends Thread {
|
|||
}
|
||||
|
||||
public void setBoard(String[] array) {
|
||||
board = new Board(array);
|
||||
board = board.toBoard(array);
|
||||
}
|
||||
|
||||
public Iterable<Piece> getPieces() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue