lichess-org / chessground

Mobile/Web chess UI for lichess.org
https://lichess.org
GNU General Public License v3.0
1.04k stars 261 forks source link

en passant capture isn't handled correctly #23

Closed StillLearnin closed 8 years ago

StillLearnin commented 8 years ago

When capturing an enemy pawn that has passed your pawn by moving two places, clicking your pawn shows that you can either move straight ahead or capture the enemy pawn.

image

After capturing the enemy pawn, the enemy pawn remains on the board but can't be moved.

image

ornicar commented 8 years ago

as the readme states, there's no chess logic inside chessground. I.E. chessground does not know the rules of chess. They have to be provided by a third party. You have to tell chessground to remove the taken pawn.

clementvp commented 7 years ago

Hey, i know this issue is closed since a long time, but for the people who use chessJs as a third party this is a simple and dirty workaround: use the .move() method of chessJS. This method return a object with 'flags' property. If the flag is : e that's a en passant standard capture. If you watch this flag, just load Chessground with the correct fen who is returned by ChessJS under the .fen() method. In my class called Engine:

var move = this.chess.move({ from: orig, to: dest, promotion: 'q' })
if (move.flags === 'e') {
        this.cg.set({ fen: this.chess.fen() })
 }

That's better than working with the .setPieces() method of Chessground.