Skip to content

Commit

Permalink
More renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jul 23, 2024
1 parent 7406d5c commit 3c76af0
Show file tree
Hide file tree
Showing 20 changed files with 316 additions and 314 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
## 4.0.0

- Add a `ChessBoardEditor` widget, intended to be used as the basis for a board editor like lichess.org/editor
- Add a `ChessboardEditor` widget, intended to be used as the basis for a board editor like lichess.org/editor
- Chessground is now dependant on `dartchess`. It is only used to share
common types: `Role`, `Side` and `Piece`. It is not used for any chess logic.
- `SquareId` is now an extension type on String.
- `Board` was renamed to `ChessBoard`.
- `Move` was renamed to `BoardMove`.
- Add the `writeFen` helper function.
- Add the `legalMovesOf` helper function to convert a dartchess `Position` to a
set of valid moves compatible with Chessground.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ chess logic so you can use it with different chess variants.

## Getting started

This package exports a `ChessBoard` widget which can be interactable or not. It is
This package exports a `Chessboard` widget which can be interactable or not. It is
entirely configurable with a `BoardSettings` object.

## Usage
Expand Down Expand Up @@ -54,9 +54,9 @@ class _MyHomePageState extends State<MyHomePage> {
title: const Text('Chessground demo'),
),
body: Center(
child: ChessBoard(
child: Chessboard(
size: screenWidth,
data: BoardData(
state: ChessboardState(
interactableSide: InteractableSide.none,
orientation: Side.white,
fen: fen,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/board_editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _BoardEditorPageState extends State<BoardEditorPage> {
colorScheme: BoardTheme.blue.colors,
enableCoordinates: true,
);
final boardEditor = ChessBoardEditor(
final boardEditor = ChessboardEditor(
size: screenWidth,
orientation: dc.Side.white,
pieces: pieces,
Expand Down
48 changes: 24 additions & 24 deletions example/lib/board_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@ import 'package:chessground/chessground.dart';

/// The chessboard theme.
enum BoardTheme {
blue('Blue', BoardColorScheme.blue),
blue2('Blue2', BoardColorScheme.blue2),
blue3('Blue3', BoardColorScheme.blue3),
blueMarble('Blue Marble', BoardColorScheme.blueMarble),
canvas('Canvas', BoardColorScheme.canvas),
wood('Wood', BoardColorScheme.wood),
wood2('Wood2', BoardColorScheme.wood2),
wood3('Wood3', BoardColorScheme.wood3),
wood4('Wood4', BoardColorScheme.wood4),
maple('Maple', BoardColorScheme.maple),
maple2('Maple 2', BoardColorScheme.maple2),
brown('Brown', BoardColorScheme.brown),
leather('Leather', BoardColorScheme.leather),
green('Green', BoardColorScheme.green),
marble('Marble', BoardColorScheme.marble),
greenPlastic('Green Plastic', BoardColorScheme.greenPlastic),
grey('Grey', BoardColorScheme.grey),
metal('Metal', BoardColorScheme.metal),
olive('Olive', BoardColorScheme.olive),
newspaper('Newspaper', BoardColorScheme.newspaper),
purpleDiag('Purple-Diag', BoardColorScheme.purpleDiag),
pinkPyramid('Pink', BoardColorScheme.pinkPyramid),
horsey('Horsey', BoardColorScheme.horsey);
blue('Blue', ChessboardColorScheme.blue),
blue2('Blue2', ChessboardColorScheme.blue2),
blue3('Blue3', ChessboardColorScheme.blue3),
blueMarble('Blue Marble', ChessboardColorScheme.blueMarble),
canvas('Canvas', ChessboardColorScheme.canvas),
wood('Wood', ChessboardColorScheme.wood),
wood2('Wood2', ChessboardColorScheme.wood2),
wood3('Wood3', ChessboardColorScheme.wood3),
wood4('Wood4', ChessboardColorScheme.wood4),
maple('Maple', ChessboardColorScheme.maple),
maple2('Maple 2', ChessboardColorScheme.maple2),
brown('Brown', ChessboardColorScheme.brown),
leather('Leather', ChessboardColorScheme.leather),
green('Green', ChessboardColorScheme.green),
marble('Marble', ChessboardColorScheme.marble),
greenPlastic('Green Plastic', ChessboardColorScheme.greenPlastic),
grey('Grey', ChessboardColorScheme.grey),
metal('Metal', ChessboardColorScheme.metal),
olive('Olive', ChessboardColorScheme.olive),
newspaper('Newspaper', ChessboardColorScheme.newspaper),
purpleDiag('Purple-Diag', ChessboardColorScheme.purpleDiag),
pinkPyramid('Pink', ChessboardColorScheme.pinkPyramid),
horsey('Horsey', ChessboardColorScheme.horsey);

final String label;

final BoardColorScheme colors;
final ChessboardColorScheme colors;

const BoardTheme(this.label, this.colors);
}
6 changes: 3 additions & 3 deletions example/lib/board_thumbnails.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class BoardThumbnailsPage extends StatelessWidget {
children: [
for (final fen in positions)
LayoutBuilder(builder: (context, constraints) {
return ChessBoard(
return Chessboard(
size: constraints.biggest.width,
settings: BoardSettings(
settings: ChessboardSettings(
enableCoordinates: false,
borderRadius: BorderRadius.circular(5),
boxShadow: [
Expand All @@ -43,7 +43,7 @@ class BoardThumbnailsPage extends StatelessWidget {
),
],
),
data: BoardData(
state: ChessboardState(
interactableSide: InteractableSide.none,
orientation: Side.white,
fen: fen,
Expand Down
19 changes: 9 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class _HomePageState extends State<HomePage> {
dc.Position<dc.Chess> position = dc.Chess.initial;
dc.Side orientation = dc.Side.white;
String fen = dc.kInitialBoardFEN;
BoardMove? lastMove;
BoardMove? premove;
Move? lastMove;
Move? premove;
ValidMoves validMoves = IMap(const {});
dc.Side sideToMove = dc.Side.white;
PieceSet pieceSet = PieceSet.merida;
Expand Down Expand Up @@ -134,9 +134,9 @@ class _HomePageState extends State<HomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ChessBoard(
Chessboard(
size: screenWidth,
settings: BoardSettings(
settings: ChessboardSettings(
pieceAssets: pieceSet.assets,
colorScheme: boardTheme.colors,
enableCoordinates: true,
Expand All @@ -155,7 +155,7 @@ class _HomePageState extends State<HomePage> {
),
pieceShiftMethod: pieceShiftMethod,
),
data: BoardData(
state: ChessboardState(
interactableSide: playMode == Mode.botPlay
? InteractableSide.white
: (position.turn == dc.Side.white
Expand Down Expand Up @@ -369,13 +369,13 @@ class _HomePageState extends State<HomePage> {
super.initState();
}

void _onSetPremove(BoardMove? move) {
void _onSetPremove(Move? move) {
setState(() {
premove = move;
});
}

void _onUserMoveFreePlay(BoardMove move, {bool? isDrop, bool? isPremove}) {
void _onUserMoveFreePlay(Move move, {bool? isDrop, bool? isPremove}) {
lastPos = position;
final m = dc.Move.fromUci(move.uci)!;
setState(() {
Expand All @@ -386,8 +386,7 @@ class _HomePageState extends State<HomePage> {
});
}

void _onUserMoveAgainstBot(BoardMove move,
{bool? isDrop, bool? isPremove}) async {
void _onUserMoveAgainstBot(Move move, {bool? isDrop, bool? isPremove}) async {
lastPos = position;
final m = dc.Move.fromUci(move.uci)!;
setState(() {
Expand Down Expand Up @@ -415,7 +414,7 @@ class _HomePageState extends State<HomePage> {
final mv = (allMoves..shuffle()).first;
setState(() {
position = position.playUnchecked(mv);
lastMove = BoardMove(
lastMove = Move(
from: SquareId(dc.toAlgebraic(mv.from)),
to: SquareId(dc.toAlgebraic(mv.to)));
fen = position.fen;
Expand Down
2 changes: 1 addition & 1 deletion lib/chessground.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ library chessground;

export 'src/board_color_scheme.dart';
export 'src/draw_shape_options.dart';
export 'src/board_data.dart';
export 'src/board_editor_settings.dart';
export 'src/board_settings.dart';
export 'src/board_state.dart';
export 'src/fen.dart';
export 'src/models.dart';
export 'src/piece_set.dart';
Expand Down
Loading

0 comments on commit 3c76af0

Please sign in to comment.