flutter: Fix first tap response slow when piece count changed

Call tree:
Game.shared.newGame(); ->
      Game.shared.start();
      Game.shared.position.init(); ->
		setPosition(rule); ->
			getNPiecesInHand();

To fix fen string.
This commit is contained in:
Calcitem 2021-03-27 23:37:40 +08:00
parent be5b877885
commit 8fc4b0038c
1 changed files with 8 additions and 0 deletions

View File

@ -106,6 +106,14 @@ class _GamePageState extends State<GamePage> with RouteAware {
return;
}
// TODO
// WAR: Fix first tap response slow when piece count changed
if (position.phase == Phase.placing &&
position.pieceOnBoardCount[PieceColor.black] == 0 &&
position.pieceOnBoardCount[PieceColor.white] == 0) {
Game.shared.newGame();
}
if (Game.shared.isAiToMove() || Game.shared.aiIsSearching()) {
return false;
}