diff options
author | June McEnroe <june@causal.agency> | 2021-04-18 23:25:41 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-04-18 23:35:45 -0400 |
commit | 7a928a34cd2baceead4e4d4a1390cd14059ee314 (patch) | |
tree | 03663b1c8f9aea9cb9b04611a91a8049cdf3037b /play.c | |
parent | Allow cumulative score games (diff) | |
download | play-7a928a34cd2baceead4e4d4a1390cd14059ee314.tar.gz play-7a928a34cd2baceead4e4d4a1390cd14059ee314.zip |
Add freecell
Diffstat (limited to '')
-rw-r--r-- | play.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/play.c b/play.c index 3c5f418..b895e9e 100644 --- a/play.c +++ b/play.c @@ -17,6 +17,7 @@ #include <curses.h> #include <err.h> #include <fcntl.h> +#include <locale.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -195,6 +196,7 @@ static void draw(const char *title, size_t new) { typedef uint Play(void); uint play2048(void); uint playSnake(void); +uint playFreeCell(void); static const struct Game { const char *name; @@ -211,6 +213,10 @@ static const struct Game { "snake", "Snake", "Eat food before it spoils to become long", playSnake, false, }, + { + "freecell", "FreeCell", "Sort cards like it's 1995", + playFreeCell, true, + }, }; static const struct Game *menu(void) { @@ -251,11 +257,20 @@ static const struct Game *menu(void) { } } +static void info(void) { + endwin(); + printf( + "This program is AGPLv3 Free Software!\n" + "Code is available from <https://git.causal.agency/play>.\n" + ); +} + int main(int argc, char *argv[]) { - const char *path = NULL; + setlocale(LC_CTYPE, ""); + atexit(info); - int opt; - while (0 < (opt = getopt(argc, argv, "t:"))) { + const char *path = NULL; + for (int opt; 0 < (opt = getopt(argc, argv, "t:"));) { switch (opt) { break; case 't': path = optarg; break; default: return EX_USAGE; @@ -281,7 +296,7 @@ int main(int argc, char *argv[]) { curse(); const struct Game *game = menu(); - if (!game) goto done; + if (!game) return 0; erase(); #ifdef __FreeBSD__ setproctitle("%s", game->name); @@ -373,10 +388,4 @@ int main(int argc, char *argv[]) { } getch(); -done: - endwin(); - printf( - "This program is AGPLv3 Free Software!\n" - "Code is available from <https://git.causal.agency/play>.\n" - ); } |