makeMultipleMoves method
Makes multiple moves
in order, in algebraic format (e.g. e2e4, f7f8q).
Returns the number of moves that were successfully made. If everything
went fine, this should be equal to moves.length
.
If undoOnError
is true, all moves made before the error will be undone.
Implementation
int makeMultipleMoves(
List<String> moves, {
bool undoOnError = true,
bool san = false,
}) {
int movesMade = 0;
for (String move in moves) {
bool ok = san ? makeMoveSan(move) : makeMoveString(move);
if (!ok) break;
movesMade++;
}
if (movesMade < moves.length && undoOnError) {
for (int i = 0; i < movesMade; i++) {
undo();
}
}
return movesMade;
}