]> git.cworth.org Git - mnemon/blobdiff - mnemon.c
Prevent any item count from being 0 after being asked.
[mnemon] / mnemon.c
index 67b5889dcfa1040d56c17a33bad250906bd94420..6600798c77d9f29429e6f1bc18633008e0d3452f 100644 (file)
--- a/mnemon.c
+++ b/mnemon.c
@@ -637,8 +637,10 @@ mnemon_do_challenges (mnemon_t *mnemon)
        printf ("%s\n", item->challenge);
 
        response = readline ("> ");
-       if (response == NULL)
+       if (response == NULL) {
+           printf ("\n");
            break;
+       }
 
        correct = (strcmp (response, item->response) == 0);
 
@@ -647,18 +649,22 @@ mnemon_do_challenges (mnemon_t *mnemon)
            mnemon_remove_bin (mnemon, bin);
 
        if (correct) {
-           printf ("Correct!\n\n");
-           if (item->count < 0)
+           printf ("Correct! (Moving from %d to ", item->count);
+           item->count++;
+           /* We reserve an item count of 0 for an item that has
+            * never been asked. */
+           if (item->count == 0)
                item->count = 1;
-           else
-               item->count++;
+           printf ("%d)\n\n", item->count);
        } else {
-           printf ("  %s is the correct answer.\n\n",
-                   item->response);
-           if (item->count > 0)
+           printf ("  %s is the correct answer. (Moving from %d to ",
+                   item->response, item->count);
+           item->count--;
+           /* Penalize an incorrect response by forcing the count
+            * negative. */
+           if (item->count >= 0)
                item->count = -1;
-           else
-               item->count--;
+           printf ("%d)\n\n", item->count);
        }
 
        bin = mnemon_get_bin (mnemon, item->count);