Skip to content

Commit

Permalink
BoardData.sideToMove is now required
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Oct 26, 2023
1 parent 752ada9 commit 666cc53
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.0

- `BoardData.sideToMove` is now a required parameter.

## 1.6.1

- Fix missing blindfoldMode to BoardSettings.copyWith
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class _MyHomePageState extends State<MyHomePage> {
data: BoardData(
interactableSide: InteractableSide.none,
orientation: Side.white,
sideToMove: Side.white,
fen: fen,
),
),
Expand Down
1 change: 1 addition & 0 deletions example/lib/board_thumbnails.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class BoardThumbnailsPage extends StatelessWidget {
data: BoardData(
interactableSide: InteractableSide.none,
orientation: Side.white,
sideToMove: Side.white,
fen: fen,
),
);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.6.0"
version: "2.0.0"
clock:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/board_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BoardData {
required this.interactableSide,
required this.orientation,
required this.fen,
this.sideToMove = Side.white,
required this.sideToMove,
this.premove,
this.lastMove,
this.validMoves,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widgets/board.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class _BoardState extends State<Board> {
details: colorScheme.lastMove,
),
),
if (premove != null)
if (premove != null &&
widget.data.interactableSide != InteractableSide.none)
for (final squareId in premove.squares)
PositionedSquare(
key: ValueKey('$squareId-premove'),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chessground
description: Chess board UI developed for lichess.org. It has no chess logic inside so it can be used for chess variants.
version: 1.6.1
version: 2.0.0
repository: https://github.com/lichess-org/flutter-chessground
funding:
- https://lichess.org/patron
Expand Down
27 changes: 1 addition & 26 deletions test/widgets/board_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void main() {
interactableSide: InteractableSide.none,
orientation: Side.white,
fen: dc.kInitialFEN,
sideToMove: Side.white,
),
),
);
Expand Down Expand Up @@ -398,32 +399,6 @@ void main() {
expect(find.byKey(const Key('c2-premove')), findsOneWidget);
});

testWidgets('cancel premoves if board is made non interactable again',
(WidgetTester tester) async {
await tester.pumpWidget(
buildBoard(
initialFen:
'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1',
initialInteractableSide: InteractableSide.white,
),
);

await makeMove(tester, 'd1', 'f3');
expect(find.byKey(const Key('d1-premove')), findsOneWidget);
expect(find.byKey(const Key('f3-premove')), findsOneWidget);

await tester.pumpWidget(
buildBoard(
initialFen:
'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1',
initialInteractableSide: InteractableSide.none,
),
);

expect(find.byKey(const Key('d1-premove')), findsNothing);
expect(find.byKey(const Key('f3-premove')), findsNothing);
});

testWidgets('play premove', (WidgetTester tester) async {
await tester.pumpWidget(
buildBoard(
Expand Down

0 comments on commit 666cc53

Please sign in to comment.