X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=word-game.c;h=d4fa77e822582cc82086fc17779857a9baacaaad;hb=ea2a992111737eccb174f26f71ab5357597d5147;hp=29cf01bdd9fcb0ed1d109d2662e9b8d754cf5ee9;hpb=352e7bb836a852c4df6810e6be58990f602cf7a1;p=wordgame diff --git a/word-game.c b/word-game.c index 29cf01b..d4fa77e 100644 --- a/word-game.c +++ b/word-game.c @@ -92,6 +92,7 @@ word_game_play (const char *puzzle, tv_stop.tv_sec += time_limit_seconds; } else { sprintf (prompt, "> "); + remaining = 1; } do { if (time_limit_seconds) { @@ -100,7 +101,8 @@ word_game_play (const char *puzzle, sprintf (prompt, "%02d:%02d ", minutes, seconds); } response = readline (prompt); - add_history (response); + if (response == NULL) + break; if (strlen (response) == 0) { if (! just_saw_puzzle) { printf ("%s\n", puzzle); @@ -116,6 +118,7 @@ word_game_play (const char *puzzle, } else { dict_entry_t *entry; just_saw_puzzle = FALSE; + add_history (response); if (response[strlen (response) - 1] == '\n') response[strlen (response) - 1] = '\0'; entry = dict_lookup (answers, response); @@ -145,12 +148,17 @@ word_game_play (const char *puzzle, printf ("%s\n", puzzle); - printf ("Words you found:\n"); - dict_print_by_length_if (answers, seen_predicate); + if (found_total) { + printf ("Words you found:\n"); + dict_print_by_length_if (answers, seen_predicate); + printf ("\n"); + } - printf ("\nWords you missed:\n"); - dict_print_by_length_if (answers, unseen_predicate); - printf ("\n"); + if (found_total < possible_total) { + printf ("Words you missed:\n"); + dict_print_by_length_if (answers, unseen_predicate); + printf ("\n"); + } printf ("You found %d of %d words (%.2f%%)\n", found_total, possible_total,