xref: /original-bsd/games/hangman/endgame.c (revision 5f03794f)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)endgame.c	5.3 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 # include	"hangman.h"
13 
14 /*
15  * endgame:
16  *	Do what's necessary at the end of the game
17  */
18 endgame()
19 {
20 	register char	ch;
21 
22 	prman();
23 	if (Errors >= MAXERRS)
24 		Errors = MAXERRS + 2;
25 	prword();
26 	prdata();
27 	move(MESGY, MESGX);
28 	if (Errors > MAXERRS)
29 		printw("Sorry, the word was \"%s\"\n", Word);
30 	else
31 		printw("You got it!\n");
32 
33 	for (;;) {
34 		mvaddstr(MESGY + 1, MESGX, "Another word? ");
35 		leaveok(stdscr, FALSE);
36 		refresh();
37 		if ((ch = readch()) == 'n')
38 			die();
39 		else if (ch == 'y')
40 			break;
41 		mvaddstr(MESGY + 2, MESGX, "Please type 'y' or 'n'");
42 	}
43 
44 	leaveok(stdscr, TRUE);
45 	move(MESGY, MESGX);
46 	addstr("\n\n\n");
47 }
48