flutter: stack_trace: Add chain to more code
This commit is contained in:
parent
26e89124fb
commit
6f1e7f7d74
|
@ -30,6 +30,7 @@ import 'package:sanmill/mill/types.dart';
|
||||||
import 'package:sanmill/services/audios.dart';
|
import 'package:sanmill/services/audios.dart';
|
||||||
import 'package:sanmill/style/colors.dart';
|
import 'package:sanmill/style/colors.dart';
|
||||||
import 'package:sanmill/style/toast.dart';
|
import 'package:sanmill/style/toast.dart';
|
||||||
|
import 'package:stack_trace/stack_trace.dart';
|
||||||
|
|
||||||
import 'board.dart';
|
import 'board.dart';
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
Chain.capture(() {
|
||||||
switch (position.action) {
|
switch (position.action) {
|
||||||
case Act.place:
|
case Act.place:
|
||||||
if (position.putPiece(sq)) {
|
if (position.putPiece(sq)) {
|
||||||
|
@ -203,12 +204,14 @@ class _GamePageState extends State<GamePage> with RouteAware {
|
||||||
Game.shared.sideToMove = position.sideToMove();
|
Game.shared.sideToMove = position.sideToMove();
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
});
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
engineToGo() async {
|
engineToGo() async {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
while ((Config.isAutoRestart == true ||
|
while ((Config.isAutoRestart == true ||
|
||||||
Game.shared.position.winner == PieceColor.nobody) &&
|
Game.shared.position.winner == PieceColor.nobody) &&
|
||||||
Game.shared.isAiToMove() &&
|
Game.shared.isAiToMove() &&
|
||||||
|
@ -229,7 +232,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
final response = await widget.engine.search(Game.shared.position);
|
final response = await widget.engine.search(Game.shared.position);
|
||||||
|
Chain.capture(() {
|
||||||
if (response.type == 'move') {
|
if (response.type == 'move') {
|
||||||
Move mv = response.value;
|
Move mv = response.value;
|
||||||
final Move move = new Move(mv.move);
|
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.position.winner != PieceColor.nobody) {
|
||||||
Game.shared.newGame();
|
Game.shared.newGame();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue