fix wrong error code when chess rules are violated

Mon, 24 Aug 2026 13:20:19 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 24 Aug 2026 13:20:19 +0200
changeset 185
c0acc89d6c01
parent 184
93c81539b702
child 186
8230904458a7

fix wrong error code when chess rules are violated
+ fix error message for that code

src/chess/rules.c file | annotate | diff | comparison | revisions
src/main.c file | annotate | diff | comparison | revisions
--- a/src/chess/rules.c	Sun Aug 23 12:19:05 2026 +0200
+++ b/src/chess/rules.c	Mon Aug 24 13:20:19 2026 +0200
@@ -645,7 +645,7 @@
 
     /* must move */
     if (move->fromfile == move->tofile && move->fromrow == move->torow) {
-        return INVALID_MOVE_SYNTAX;
+        return RULES_VIOLATED;
     }
 
     /* does piece exist */
@@ -667,7 +667,7 @@
         if (!move->capture || piece_type(move->piece) != PAWN ||
                 !enpassant_threat_exists(gamestate,
                     move->fromrow, move->tofile)) {
-            return INVALID_MOVE_SYNTAX;
+            return RULES_VIOLATED;
         }
     }
 
--- a/src/main.c	Sun Aug 23 12:19:05 2026 +0200
+++ b/src/main.c	Mon Aug 24 13:20:19 2026 +0200
@@ -376,7 +376,7 @@
         printw("Can't interpret move - please use algebraic notation.");
         break;
     case RULES_VIOLATED:
-        printw("Move does not comply chess rules.");
+        printw("Move does not comply with chess rules.");
         break;
     case KING_MOVES_INTO_CHECK:
         printw("Can't move the king into a check position.");

mercurial