safeUndoMove method
Performs a move
but in reverse order, if the square move.to
is not
empty.
This method is a more robust version of undoMove.
Implementation
bool safeUndoMove(PlayedMove move) {
if (atSquare(move.from) != null || atSquare(move.to) == null) return false;
undoMove(move);
return true;
}