Skip to content

Commit

Permalink
delete wrong move from game tree
Browse files Browse the repository at this point in the history
  • Loading branch information
HaonRekcef committed Apr 12, 2024
1 parent de4f73c commit 61d6e79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/model/puzzle/puzzle_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class PuzzleController extends _$PuzzleController {
_onFailOrWin(PuzzleResult.lose);
if (initialStreak == null) {
await Future<void>.delayed(const Duration(milliseconds: 500));
_gameTree.deleteAt(state.currentPath);
_setPath(state.currentPath.penultimate);
}
}
Expand Down Expand Up @@ -584,7 +585,7 @@ class PuzzleState with _$PuzzleState {
String get fen => node.position.fen;
bool get canPlayMove => mode == PuzzleMode.view || node.children.isNotEmpty;
bool get canGoNext => node.children.isNotEmpty;
bool get canGoBack => currentPath.size > initialPath.size;
bool get canGoBack => currentPath.size > 0;

IMap<String, ISet<String>> get validMoves => algebraicLegalMoves(position);
}

0 comments on commit 61d6e79

Please sign in to comment.