src/chess/fen.c

changeset 220
04da225a5677
parent 219
24b866230dd4
--- a/src/chess/fen.c	Sat Sep 05 12:36:04 2026 +0200
+++ b/src/chess/fen.c	Sat Sep 05 13:03:09 2026 +0200
@@ -292,5 +292,17 @@
 
     /* only copy the fen string if everything is a success */
     gamestate->fen_start = strdup(fen_start);
+
+    /* check if the FEN describes an already ended game */
+    if (check_checkmate(gamestate)) {
+        gamestate->checkmate = true;
+    } else if (check_no_material(gamestate)) {
+        gamestate->nomaterial = true;
+    } else if (check_threefold_repetition(gamestate)) {
+        gamestate->threefold = true;
+    } else if (check_stalemate(gamestate)) {
+        gamestate->stalemate = true;
+    }
+
     return 0;
 }
\ No newline at end of file

mercurial