]> git.cworth.org Git - wordgame/blobdiff - word-game.c
Increase the window size a bit
[wordgame] / word-game.c
index 2b9fa4e1e3df481096778425c9a1092a9d06b41c..48e8692edaf41a0ef8f6d65f3ccf964878bd3c98 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2006 Carl Worth
  *
- * This program is free software; you can redistribute it and\/or modify
+ * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2, or (at your option)
  * any later version.
@@ -112,11 +112,17 @@ word_game_play (const char        *puzzle,
        sprintf (prompt, "> ");
        remaining = 1;
     }
-    do {
+    while (1) {
        if (time_limit_seconds) {
-           minutes = remaining / 60;
-           seconds = remaining % 60;
-           sprintf (prompt, "%02d:%02d ", minutes, seconds);
+           if (remaining > 0) {
+               minutes = remaining / 60;
+               seconds = remaining % 60;
+               sprintf (prompt, "%02d:%02d ", minutes, seconds);
+           } else {
+               printf ("Time's up.\a\n");
+               sprintf (prompt, "> ");
+               time_limit_seconds = 0;
+           }
        }
        response = readline (prompt);
        if (response == NULL)
@@ -157,7 +163,7 @@ word_game_play (const char  *puzzle,
            remaining = floor (0.5 + (tv_stop.tv_sec - tv.tv_sec) + (tv_stop.tv_usec - tv.tv_usec) / 1000000.0);
            minutes = remaining / 60;
        }
-    } while (remaining > 0);
+    }
 
     printf ("\n%s\n", puzzle);