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