flutter: stack_trace: Add chain to more code

This commit is contained in:
Calcitem 2021-02-27 10:11:39 +08:00
parent 26e89124fb
commit 6f1e7f7d74
1 changed files with 91 additions and 87 deletions

View File

@ -30,6 +30,7 @@ import 'package:sanmill/mill/types.dart';
import 'package:sanmill/services/audios.dart';
import 'package:sanmill/style/colors.dart';
import 'package:sanmill/style/toast.dart';
import 'package:stack_trace/stack_trace.dart';
import 'board.dart';
@ -121,7 +122,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
}
bool ret = false;
Chain.capture(() {
switch (position.action) {
case Act.place:
if (position.putPiece(sq)) {
@ -203,12 +204,14 @@ class _GamePageState extends State<GamePage> with RouteAware {
Game.shared.sideToMove = position.sideToMove();
setState(() {});
});
return ret;
}
engineToGo() async {
// TODO
while ((Config.isAutoRestart == true ||
Game.shared.position.winner == PieceColor.nobody) &&
Game.shared.isAiToMove() &&
@ -229,7 +232,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
}
final response = await widget.engine.search(Game.shared.position);
Chain.capture(() {
if (response.type == 'move') {
Move mv = response.value;
final Move move = new Move(mv.move);
@ -245,6 +248,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
Game.shared.position.winner != PieceColor.nobody) {
Game.shared.newGame();
}
});
}
}