addMove method

void addMove({
  1. required String move,
  2. required String fen,
  3. String? san,
})

Add a new move to history

Implementation

void addMove({
  required String move,
  required String fen,
  String? san,
}) {
  // If we're not at the end of history, truncate future moves
  if (_currentIndex < _history.length - 1) {
    _history.removeRange(_currentIndex + 1, _history.length);
  }

  final historyMove = HistoryMove(
    move: move,
    fen: fen,
    san: san,
    timestamp: DateTime.now(),
  );

  _history.add(historyMove);
  _currentIndex = _history.length - 1;
}