date and time created 88/10/19 15:27:18 by bostic
[unix-history] / usr / src / games / hangman / endgame.c
CommitLineData
81ded2d3 1/*
b8c620d6 2 * Copyright (c) 1983 Regents of the University of California.
81ded2d3
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
b8c620d6
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
81ded2d3
KB
16 */
17
18#ifndef lint
b8c620d6 19static char sccsid[] = "@(#)endgame.c 5.2 (Berkeley) %G%";
81ded2d3
KB
20#endif /* not lint */
21
22# include "hangman.h"
23
24/*
25 * endgame:
26 * Do what's necessary at the end of the game
27 */
28endgame()
29{
30 register char ch;
31
32 prman();
33 if (Errors >= MAXERRS)
34 Errors = MAXERRS + 2;
35 prword();
36 prdata();
37 move(MESGY, MESGX);
38 if (Errors > MAXERRS)
39 printw("Sorry, the word was \"%s\"\n", Word);
40 else
41 printw("You got it!\n");
42
43 for (;;) {
44 mvaddstr(MESGY + 1, MESGX, "Another word? ");
45 leaveok(stdscr, FALSE);
46 refresh();
47 if ((ch = readch()) == 'n')
48 die();
49 else if (ch == 'y')
50 break;
51 mvaddstr(MESGY + 2, MESGX, "Please type 'y' or 'n'");
52 }
53
54 leaveok(stdscr, TRUE);
55 move(MESGY, MESGX);
56 addstr("\n\n\n");
57}