Skip to content

feat: teach Chessboard to support DropMoves#84

Merged
veloce merged 3 commits intolichess-org:mainfrom
tom-anders:crazyhouse
Feb 13, 2026
Merged

feat: teach Chessboard to support DropMoves#84
veloce merged 3 commits intolichess-org:mainfrom
tom-anders:crazyhouse

Conversation

@tom-anders
Copy link
Contributor

dropmoves.webm

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for DropMoves to the Chessboard widget, enabling pieces to be dragged from outside the board (e.g., from a piece pocket in Crazyhouse) and dropped onto board squares. The implementation broadens the type system from NormalMove to the more general Move type to accommodate both regular moves and drop moves.

Changes:

  • Expanded type signatures from NormalMove to Move throughout the codebase to support both normal moves and drop moves
  • Added enableDropMoves setting to ChessboardSettings to enable/disable the feature
  • Implemented drag target overlays for all board squares when drop moves are enabled
  • Added validation for back-rank pawn drops and empty square requirements

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
lib/src/models.dart Updated onMove callback and Premovable type definitions to accept Move instead of NormalMove
lib/src/board_settings.dart Added enableDropMoves boolean setting with default value of false
lib/src/widgets/board.dart Added 64 DragTarget widgets for drop move acceptance, updated _lastDrop type, and added pattern matching for NormalMove checks
lib/src/widgets/animation.dart Updated preparePieceAnimations to handle both NormalMove and DropMove in the lastDrop parameter
test/widgets/board_test.dart Added tests for drop moves and drop premoves, updated test app to support Move type, added unsafe type cast for premove promotion
example/lib/main.dart Added Crazyhouse demonstration with drag-and-drop piece pockets, duplicated ChessboardSettings creation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -56,7 +56,7 @@ class GameData {
/// Callback called after a move has been made.
///
/// If the move has been made with drag and drop, `isDrop` will be true.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation comment states "If the move has been made with drag and drop, isDrop will be true." However, this is now ambiguous. The isDrop parameter could mean either:

  1. A drag-and-drop interaction (vs tap-to-select)
  2. A DropMove (vs NormalMove)

Consider updating the documentation to clarify this distinction, especially since the code at line 420 in board.dart sets isDrop: true specifically for DropMoves (pieces dragged from outside the board), not for all drag-and-drop moves.

Suggested change
/// If the move has been made with drag and drop, `isDrop` will be true.
/// The optional [isDrop] flag is `true` when the move is a drop move,
/// i.e. a piece is placed onto the board from outside (as opposed to a
/// normal move of a piece already on the board). It does not indicate
/// whether the user interaction was performed via drag-and-drop or
/// tap-to-select.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veloce I also thought about this, do we want to rename to viaDragAndDrop maybe?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not even used by the app... But we should leave it in case other folks use it. In any case it is BC so major version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC I added that because the old app was using this metadata to send to server (don't remember why).

@veloce veloce merged commit 2a00569 into lichess-org:main Feb 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants