src/chess/rules.c

changeset 151
f1b6a0388d85
parent 147
7e3f2d462bb6
--- a/src/chess/rules.c	Sun Jul 19 19:17:04 2026 +0200
+++ b/src/chess/rules.c	Tue Jul 21 14:09:55 2026 +0200
@@ -358,10 +358,15 @@
         return RULES_VIOLATED;
     }
     
-    /* must capture, if and only if destination is occupied */
+    /* must capture, if and only if destination is occupied... */
     if ((mdst(gamestate->board, move) == 0 && move->capture) ||
             (mdst(gamestate->board, move) != 0 && !move->capture)) {
-        return INVALID_MOVE_SYNTAX;
+        /* ... or the capture happens en passant */
+        if (!move->capture || (move->piece & PIECE_MASK) != PAWN ||
+                !(gamestate->board[move->fromrow][move->tofile]
+                  & ENPASSANT_THREAT)) {
+            return INVALID_MOVE_SYNTAX;
+        }
     }
     
     /* validate individual rules */

mercurial