]> git.cworth.org Git - wordgame/commitdiff
Fix games wiithout time limit. Don't add empty repsonse to history. Don't expect...
authorCarl Worth <cworth@raht.cworth.org>
Sat, 23 Sep 2006 08:31:48 +0000 (01:31 -0700)
committerCarl Worth <cworth@raht.cworth.org>
Sat, 23 Sep 2006 08:31:48 +0000 (01:31 -0700)
grid.c
word-game.c

diff --git a/grid.c b/grid.c
index ed88df309b45cbddb8b63c5e0f5d359cbb9b65b5..76428d98bad2b6275c635f635bbef7fdc0d4b852 100644 (file)
--- a/grid.c
+++ b/grid.c
@@ -97,7 +97,8 @@ board_to_string (board_t      *board,
            else
                *s++ = ' ';
        }
-       *s++ = '\n';
+       if (y != 3)
+           *s++ = '\n';
     }
     *s = '\0';
 }
index 29cf01bdd9fcb0ed1d109d2662e9b8d754cf5ee9..8c9af9a59071feda5567f90cfecea9f014f32083 100644 (file)
@@ -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);