backward method
Moves one move backward in the _gameHistory
.
Difference between backward and undo is that undo cannot be "undone"
but backward can be undone using forward. In other words, backward
does not destroy _gameHistory
.
Method backward can be used in combination with forward to explore
_gameHistory
without deleting any of the moves.
Implementation
PlayedMove? backward() {
if (!canGoBackward) return null;
final PlayedMove lastMove = _gameHistory.backward();
if (_board.safeUndoMove(lastMove)) return lastMove;
_gameHistory.forward();
return null;
}