386BSD 0.1 development
authorWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Tue, 9 Apr 1991 00:58:26 +0000 (16:58 -0800)
committerWilliam F. Jolitz <wjolitz@soda.berkeley.edu>
Tue, 9 Apr 1991 00:58:26 +0000 (16:58 -0800)
Work on file usr/othersrc/games/hangman/prdata.c
Work on file usr/othersrc/games/hangman/playgame.c
Work on file usr/othersrc/games/hangman/prword.c
Work on file usr/othersrc/games/hangman/setup.c
Work on file usr/othersrc/games/hangman/prman.c

Co-Authored-By: Lynne Greer Jolitz <ljolitz@cardio.ucsf.edu>
Synthesized-from: 386BSD-0.1

usr/othersrc/games/hangman/playgame.c [new file with mode: 0644]
usr/othersrc/games/hangman/prdata.c [new file with mode: 0644]
usr/othersrc/games/hangman/prman.c [new file with mode: 0644]
usr/othersrc/games/hangman/prword.c [new file with mode: 0644]
usr/othersrc/games/hangman/setup.c [new file with mode: 0644]

diff --git a/usr/othersrc/games/hangman/playgame.c b/usr/othersrc/games/hangman/playgame.c
new file mode 100644 (file)
index 0000000..84eb391
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)playgame.c 5.3 (Berkeley) 4/8/91";
+#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();
+}
diff --git a/usr/othersrc/games/hangman/prdata.c b/usr/othersrc/games/hangman/prdata.c
new file mode 100644 (file)
index 0000000..5ac6e0f
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)prdata.c   5.3 (Berkeley) 4/8/91";
+#endif /* not lint */
+
+# include      "hangman.h"
+
+/*
+ * prdata:
+ *     Print out the current guesses
+ */
+prdata()
+{
+       register bool   *bp;
+
+       move(GUESSY, GUESSX + sizeof "Guessed: ");
+       bp = Guessed;
+       while (bp < &Guessed[26])
+               if (*bp++)
+                       addch((bp - Guessed) + 'a' - 1);
+       clrtoeol();
+       mvprintw(NUMBERY, NUMBERX + sizeof "Word #:          ", "%d", Wordnum);
+       mvprintw(AVGY, AVGX + sizeof       "Current Average: ", "%.3f",
+                               (Average * (Wordnum - 1) + Errors) / Wordnum);
+       mvprintw(AVGY + 1, AVGX + sizeof   "Overall Average: ", "%.3f", Average);
+}
diff --git a/usr/othersrc/games/hangman/prman.c b/usr/othersrc/games/hangman/prman.c
new file mode 100644 (file)
index 0000000..a522596
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)prman.c    5.3 (Berkeley) 4/8/91";
+#endif /* not lint */
+
+# include      "hangman.h"
+
+/*
+ * prman:
+ *     Print out the man appropriately for the give number
+ *     of incorrect guesses.
+ */
+prman()
+{
+       register int    i;
+
+       for (i = 0; i < Errors; i++)
+               mvaddch(Err_pos[i].y, Err_pos[i].x, Err_pos[i].ch);
+       while (i < MAXERRS) {
+               mvaddch(Err_pos[i].y, Err_pos[i].x, ' ');
+               i++;
+       }
+}
diff --git a/usr/othersrc/games/hangman/prword.c b/usr/othersrc/games/hangman/prword.c
new file mode 100644 (file)
index 0000000..1136cc8
--- /dev/null
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)prword.c   5.3 (Berkeley) 4/8/91";
+#endif /* not lint */
+
+# include      "hangman.h"
+
+/*
+ * prword:
+ *     Print out the current state of the word
+ */
+prword()
+{
+       move(KNOWNY, KNOWNX + sizeof "Word: ");
+       addstr(Known);
+       clrtoeol();
+}
diff --git a/usr/othersrc/games/hangman/setup.c b/usr/othersrc/games/hangman/setup.c
new file mode 100644 (file)
index 0000000..a72df8e
--- /dev/null
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)setup.c    5.4 (Berkeley) 4/8/91";
+#endif /* not lint */
+
+# include      "hangman.h"
+
+/*
+ * setup:
+ *     Set up the strings on the screen.
+ */
+setup()
+{
+       register char           **sp;
+       static struct stat      sbuf;
+
+       noecho();
+       crmode();
+
+       mvaddstr(PROMPTY, PROMPTX, "Guess:");
+       mvaddstr(GUESSY, GUESSX, "Guessed:");
+       mvaddstr(NUMBERY, NUMBERX, "Word #:");
+       mvaddstr(AVGY, AVGX, "Current Average:");
+       mvaddstr(AVGY + 1, AVGX, "Overall Average:");
+       mvaddstr(KNOWNY, KNOWNX, "Word: ");
+
+       for (sp = Noose_pict; *sp != NULL; sp++) {
+               move(sp - Noose_pict, 0);
+               addstr(*sp);
+       }
+
+       srand(time(NULL) + getpid());
+       if ((Dict = fopen(_PATH_DICT, "r")) == NULL) {
+               perror(_PATH_DICT);
+               endwin();
+               exit(1);
+       }
+       fstat(fileno(Dict), &sbuf);
+       Dict_size = sbuf.st_size;
+}