From 8fc4b0038c55725775e13b5947bf6df5ffc48e5a Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sat, 27 Mar 2021 23:37:40 +0800 Subject: [PATCH] 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. --- src/ui/flutter_app/lib/widgets/game_page.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ui/flutter_app/lib/widgets/game_page.dart b/src/ui/flutter_app/lib/widgets/game_page.dart index 17dc30a1..a3fb645d 100644 --- a/src/ui/flutter_app/lib/widgets/game_page.dart +++ b/src/ui/flutter_app/lib/widgets/game_page.dart @@ -106,6 +106,14 @@ class _GamePageState extends State 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; }