diff --git a/src/backend/Board.java b/src/backend/Board.java index ff524e9..c0fcb90 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -202,9 +202,23 @@ public class Board { /* saving-loading feature :*/ public String[] toFileRep() { - //TODO - return null; - } + + ArrayList lines = new ArrayList<>(); + + + lines.add(String.valueOf(turnNumber)); //nombre xe tours + lines.add(String.valueOf(isWhiteTurn)); //couleur du joueur + + + for (Piece piece : pieces) { //ajoute la pièce à la mémoire + String line = piece.getType() + "," + piece.getX() + "," + piece.getY() + "," + piece.isWhite(); + lines.add(line); + } + System.out.println("The modifications are: " + lines); + return lines.toArray(new String[0]); + + } + public Board(String[] array) { this.colNum = 8; @@ -225,8 +239,7 @@ public class Board { boolean isWhite = Boolean.parseBoolean(parts[3]); pieces.add(new Piece(x, y, isWhite, type));} - - + System.out.println("The modifications are: " + pieces); } /* The following methods require more work ! */ diff --git a/src/backend/SpecialMoves.java b/src/backend/SpecialMoves.java index e7d240d..f9c386a 100644 --- a/src/backend/SpecialMoves.java +++ b/src/backend/SpecialMoves.java @@ -1,5 +1,48 @@ package backend; public class SpecialMoves { + private Piece piece; + private Board board; + private int x = piece.getX(); + private int y = piece.getY(); + private PieceType type = PieceType.getType(); + private boolean isWhite; + + /* public SpecialMoves(Piece piece, Board board) { + this.piece = piece; + this.board = board; + } //??? + + public boolean checkCoordinates(int x, int y, PieceType type, boolean isWhite) { + if (type == PieceType.Pawn || isWhite == true || y == 6) { + int[][] offsets = {{1, -2}, {-1, -2}}; + } + if (type == PieceType.Pawn || isWhite == false || y == 1) { + int[][] offsets = {{1, 2}, {-1, 2}}; + }*/ + + public boolean checkCoordinates(int x, int y, PieceType type, boolean isWhite) { + if (type == PieceType.Pawn || isWhite == true || y == 3) { + int[][] offsets = {{1, 0}, {-1, 0}}; + + } + if (type == PieceType.Pawn || isWhite == false || y == 4) { + int[][] offsets = {{1, 0}, {-1, 0}}; + } + + + + } + + public boolean isEnpassant() { + boolean isWhite = piece.isWhite(); + if (boolean isWhite == true|| PieceType getType() == PieceType.Pawn) { //no idea honestly + if () + + } + if (boolean isWhite == false|| //PieceType type == Pawn) { + if () + } + } }