src/main.c

changeset 163
2a6d83f4677e
parent 157
07cbfc477b22
--- a/src/main.c	Thu Jul 30 18:34:15 2026 +0200
+++ b/src/main.c	Thu Jul 30 19:17:38 2026 +0200
@@ -355,7 +355,7 @@
     }
 }
 
-static void eval_move_failed_msg(int code) {
+static void eval_move_failed_msg(uint32_t code) {
     switch (code) {
     case AMBIGUOUS_MOVE:
         printw("Ambiguous move - please specify the piece to move.");
@@ -381,6 +381,18 @@
     case KING_MOVES_INTO_CHECK:
         printw("Can't move the king into a check position.");
         break;
+    case MISSING_CHECK:
+        printw("Move does not indicate check.");
+        break;
+    case MISSING_CHECKMATE:
+        printw("Move does not indicate checkmate.");
+        break;
+    case INVALID_CHECK:
+        printw("Move incorrectly indicates check.");
+        break;
+    case INVALID_CHECKMATE:
+        printw("Move incorrectly indicates checkmate.");
+        break;
     default:
         printw("Unknown move parser error.");
     }
@@ -461,7 +473,8 @@
                 /* ignore empty move strings and ask again */
             } else {
                 Move move;
-                int result = eval_move(gamestate, movestr, &move, curcolor);
+                int result = eval_move_lazy(gamestate,
+                    movestr, curcolor, &move);
                 if (result == VALID_MOVE_SYNTAX) {
                     result = validate_move(gamestate, &move);
                     if (result == VALID_MOVE_SEMANTICS) {
@@ -596,13 +609,14 @@
                 /* ignore empty move strings and ask again */
             } else {
                 Move move;
-                int eval_result = eval_move(gamestate, movestr, &move, mycolor);
+                int eval_result = eval_move_lazy(gamestate,
+                    movestr, mycolor, &move);
                 switch (eval_result) {
                 case VALID_MOVE_SYNTAX:
                     net_send_data(opponent, NETCODE_MOVE, &move, sizeof(Move));
                     code = net_recieve_code(opponent);
-                    move.check = code == NETCODE_CHECK ||
-                        code == NETCODE_CHECKMATE;
+                    /* we could validate the move's check/checkmate flag with
+                     * the network response code, but we choose not to do it */
                     gamestate->checkmate = code == NETCODE_CHECKMATE;
                     gamestate->stalemate = code == NETCODE_STALEMATE;
                     if (code == NETCODE_DECLINE) {

mercurial