Handle en passant capture in baseMove - #402
Open
Untitled-Master wants to merge 4 commits into
Open
Untitled-Master wants to merge 4 commits into
Untitled-Master wants to merge 4 commits into
Conversation
Pawn diagonal to empty square now removes the enemy pawn at [dest file, orig rank], so move() animates slide+fade in one step instead of requiring move()+setPieces(). Fixes lichess-org#316
There was a problem hiding this comment.
🟡 Changes recommended
Invalid diagonal moves can currently remove an adjacent pawn.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds en passant handling to baseMove, including captured-pawn removal and animation integration.
Changes:
- Detects diagonal moves to empty squares as en passant.
- Integrates captured pieces into callbacks and animations.
File summaries
| File | Summary | Finding |
|---|---|---|
src/board.ts |
Adds en passant detection and capture removal. | Moderate issue: the check must restrict captures to the pawn’s valid rank and forward direction. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (!origPiece || origPiece.role !== 'pawn') return undefined; | ||
| const origPos = key2pos(orig); | ||
| const destPos = key2pos(dest); | ||
| if (origPos[0] === destPos[0]) return undefined; |
Member
|
I added a demo board for testing and functionality seems good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #316. Pawn diagonal to empty square removes enemy pawn at [dest file, orig rank]. One anim() does slide+fade, old setPieces() cleanup becomes a no-op. Verified: e5xd6 removes d5, push/capture unchanged, vitest 14 passed, oxlint/oxfmt/tsc clean.