X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=word-game.c;h=8c9af9a59071feda5567f90cfecea9f014f32083;hb=4af5ce4dd24d24df0909f75106c06514f565954d;hp=29cf01bdd9fcb0ed1d109d2662e9b8d754cf5ee9;hpb=352e7bb836a852c4df6810e6be58990f602cf7a1;p=wordgame diff --git a/word-game.c b/word-game.c index 29cf01b..8c9af9a 100644 --- a/word-game.c +++ b/word-game.c @@ -82,7 +82,7 @@ word_game_play (const char *puzzle, for (i=0; i < 17; i++) possible_total += possible[i]; - printf ("%s\n", puzzle); + printf ("%s\n\n", puzzle); just_saw_puzzle = TRUE; remaining = time_limit_seconds; @@ -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,10 +101,11 @@ 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); + printf ("%s\n\n", puzzle); just_saw_puzzle = TRUE; } else { for (i = 2; i <= 17; i++) @@ -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); @@ -143,7 +146,7 @@ word_game_play (const char *puzzle, } } while (remaining > 0); - printf ("%s\n", puzzle); + printf ("%s\n\n", puzzle); printf ("Words you found:\n"); dict_print_by_length_if (answers, seen_predicate);