Skip to content

Handle en passant capture in baseMove - #402

Open
Untitled-Master wants to merge 4 commits into
lichess-org:masterfrom
Untitled-Master:fix-en-passant
Open

Untitled-Master wants to merge 4 commits into
lichess-org:masterfrom
Untitled-Master:fix-en-passant

Conversation

@Untitled-Master

Copy link
Copy Markdown

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.

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
Copilot AI lite review requested due to automatic review settings September 16, 2026 02:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.

Comment thread src/board.ts
if (!origPiece || origPiece.role !== 'pawn') return undefined;
const origPos = key2pos(orig);
const destPos = key2pos(dest);
if (origPos[0] === destPos[0]) return undefined;
@fitztrev

Copy link
Copy Markdown
Member

I added a demo board for testing and functionality seems good

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.

Cosmetic: en passant animation too quick

3 participants