date and time created 87/12/22 13:08:08 by bostic
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 23 Dec 1987 05:08:08 +0000 (21:08 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 23 Dec 1987 05:08:08 +0000 (21:08 -0800)
SCCS-vsn: games/hangman/main.c 5.1
SCCS-vsn: games/hangman/playgame.c 5.1

usr/src/games/hangman/main.c [new file with mode: 0644]
usr/src/games/hangman/playgame.c [new file with mode: 0644]

diff --git a/usr/src/games/hangman/main.c b/usr/src/games/hangman/main.c
new file mode 100644 (file)
index 0000000..4a7c36b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1987 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)main.c     5.1 (Berkeley) %G%";
+#endif /* not lint */
+
+# include      "hangman.h"
+
+/*
+ * This game written by Ken Arnold.
+ */
+main()
+{
+       initscr();
+       signal(SIGINT, die);
+       setup();
+       for (;;) {
+               Wordnum++;
+               playgame();
+               Average = (Average * (Wordnum - 1) + Errors) / Wordnum;
+       }
+       /* NOTREACHED */
+}
+
+/*
+ * die:
+ *     Die properly.
+ */
+die()
+{
+       mvcur(0, COLS - 1, LINES - 1, 0);
+       endwin();
+       putchar('\n');
+       exit(0);
+}
diff --git a/usr/src/games/hangman/playgame.c b/usr/src/games/hangman/playgame.c
new file mode 100644 (file)
index 0000000..eb728a4
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)playgame.c 5.1 (Berkeley) %G%";
+#endif /* not lint */
+
+# include      "hangman.h"
+
+/*
+ * playgame:
+ *     play a game
+ */
+playgame()
+{
+       register bool   *bp;
+
+       getword();
+       Errors = 0;
+       bp = Guessed;
+       while (bp < &Guessed[26])
+               *bp++ = FALSE;
+       while (Errors < MAXERRS && index(Known, '-') != NULL) {
+               prword();
+               prdata();
+               prman();
+               getguess();
+       }
+       endgame();
+}