From c642064d16a706e10323c111ccd4bd7822b516cc Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 21 Apr 2024 18:44:23 +0800 Subject: [PATCH] setup-pos: Do not show page if removeOpponentsPieceFromHand is on (WAR) --- .../toolbars/src/setup_position_toolbar.dart | 14 +++++++++++-- src/ui/flutter_app/lib/home/home.dart | 21 ++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/ui/flutter_app/lib/game_page/widgets/toolbars/src/setup_position_toolbar.dart b/src/ui/flutter_app/lib/game_page/widgets/toolbars/src/setup_position_toolbar.dart index eff7919c1..7d2774e0e 100644 --- a/src/ui/flutter_app/lib/game_page/widgets/toolbars/src/setup_position_toolbar.dart +++ b/src/ui/flutter_app/lib/game_page/widgets/toolbars/src/setup_position_toolbar.dart @@ -521,8 +521,18 @@ class SetupPositionToolbarState extends State { assert(false); } } else if (newPhase == Phase.moving) { - GameController().position.pieceInHandCount[PieceColor.white] = - GameController().position.pieceInHandCount[PieceColor.black] = 0; + if (DB().ruleSettings.millFormationActionInPlacingPhase == + MillFormationActionInPlacingPhase + .removeOpponentsPieceFromHandThenYourTurn || + DB().ruleSettings.millFormationActionInPlacingPhase == + MillFormationActionInPlacingPhase + .removeOpponentsPieceFromHandThenOpponentsTurn) { + // TODO: Right? + GameController().position.pieceInHandCount[newPieceColor] = 0; + } else { + GameController().position.pieceInHandCount[PieceColor.white] = + GameController().position.pieceInHandCount[PieceColor.black] = 0; + } } else { assert(false); } diff --git a/src/ui/flutter_app/lib/home/home.dart b/src/ui/flutter_app/lib/home/home.dart index d94403d7b..4fadf88a8 100644 --- a/src/ui/flutter_app/lib/home/home.dart +++ b/src/ui/flutter_app/lib/home/home.dart @@ -318,13 +318,20 @@ class HomeState extends State with TickerProviderStateMixin { currentSelectedValue: _drawerIndex, onSelectionChanged: _changeIndex, ), - CustomDrawerItem<_DrawerIndex>( - itemValue: _DrawerIndex.setupPosition, - itemTitle: S.of(context).setupPosition, - itemIcon: const Icon(FluentIcons.drafts_24_regular), - currentSelectedValue: _drawerIndex, - onSelectionChanged: _changeIndex, - ), + // TODO: Support removeOpponentsPieceFromHand + if (DB().ruleSettings.millFormationActionInPlacingPhase != + MillFormationActionInPlacingPhase + .removeOpponentsPieceFromHandThenYourTurn && + DB().ruleSettings.millFormationActionInPlacingPhase != + MillFormationActionInPlacingPhase + .removeOpponentsPieceFromHandThenOpponentsTurn) + CustomDrawerItem<_DrawerIndex>( + itemValue: _DrawerIndex.setupPosition, + itemTitle: S.of(context).setupPosition, + itemIcon: const Icon(FluentIcons.drafts_24_regular), + currentSelectedValue: _drawerIndex, + onSelectionChanged: _changeIndex, + ), CustomDrawerItem<_DrawerIndex>( itemValue: _DrawerIndex.generalSettings, itemTitle: S.of(context).generalSettings,