Fixed FEN string export when board is in start position
This commit is contained in:
parent
586bf11453
commit
6dd517fbfe
@ -461,11 +461,13 @@ public class Board implements Cloneable {
|
||||
// TODO: en passant availability
|
||||
sb.append(" -");
|
||||
|
||||
final LoggedMove lastMove = log.getLast();
|
||||
|
||||
// Halfmove clock
|
||||
sb.append(" " + log.getLast().halfmoveClock);
|
||||
sb.append(" " + String.valueOf(lastMove == null ? 0 : lastMove.halfmoveClock));
|
||||
|
||||
// Fullmove counter
|
||||
sb.append(" " + log.getLast().fullmoveCounter);
|
||||
sb.append(" " + String.valueOf(lastMove == null ? 1 : lastMove.fullmoveCounter));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class Log implements Cloneable {
|
||||
moves.add(new LoggedMove(move, capturedPiece, fullmoveCounter, halfmoveClock));
|
||||
}
|
||||
|
||||
public LoggedMove getLast() { return moves.get(moves.size() - 1); }
|
||||
public LoggedMove getLast() { return moves.isEmpty() ? null : moves.get(moves.size() - 1); }
|
||||
|
||||
public void removeLast() {
|
||||
if (!moves.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user