moveHistorySan property

List<String> moveHistorySan

Get the history of the game (i.e. all moves played) in SAN format.

Implementation

List<String> get moveHistorySan {
  final sans = history.skip(1).map((e) => e.meta?.prettyName).toList();
  if (!sans.contains(null)) {
    return sans.map((e) => e as String).toList();
  }
  List<BishopState> stateStack = [];
  while (canUndo) {
    stateStack.add(state);
    undo();
  }
  List<String> moves = [];
  while (stateStack.isNotEmpty) {
    BishopState s = stateStack.removeLast();
    Move m = s.move!;
    String san = s.meta?.prettyName ?? toSan(m);
    moves.add(san);
    makeMove(m);
  }
  return moves;
}