Move.fromICString constructor

Move.fromICString(
  1. String s
)

Returns new Move object that corresponds to ICString representation s.

Implementation

factory Move.fromICString(String s) {
  final String? promotionTo =
      s[s.length - 1].toLowerCase() == s[s.length - 1].toUpperCase()
          ? null
          : s[s.length - 1];
  final List<String> squares =
      (promotionTo == null ? s : s.substring(0, s.length - 1)).split('-');

  return Move(
    Square.fromICString(squares.first),
    Square.fromICString(squares.last),
    promotionTo == null ? null : Piece.fromFenSymbol(promotionTo),
  );
}