bonus 1 board part

This commit is contained in:
clara 2025-05-07 14:02:13 +02:00
parent 4764a49a7c
commit bef58173c8
1 changed files with 20 additions and 2 deletions

View File

@ -180,7 +180,25 @@ public class Board {
}
public Board(String[] array) {
//TODO
this.colNum = 8;
this.lineNum = 8;
this.turnNumber = Integer.parseInt(array[0]);
this.isWhiteTurn = Boolean.parseBoolean(array[1]);
this.pieces = new ArrayList<>();
for (int i = 2; i < array.length; i++) {
String[] parts = array[i].split(",");
PieceType type = PieceType.valueOf(parts[0]);
int x = Integer.parseInt(parts[1]);
int y = Integer.parseInt(parts[2]);
boolean isWhite = Boolean.parseBoolean(parts[3]);
pieces.add(new Piece(x, y, isWhite, type));}
}
@ -230,5 +248,5 @@ public class Board {
return new ArrayList<>();
}
}
}