xref: /netbsd-src/games/hack/hack.rip.c (revision 5e4c038a45edbc7d63b7c2daa76e29f88b64a4e3)
1 /*	$NetBSD: hack.rip.c,v 1.6 2001/03/25 20:44:02 jsm Exp $	*/
2 
3 /*
4  * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
5  */
6 
7 #include <sys/cdefs.h>
8 #ifndef lint
9 __RCSID("$NetBSD: hack.rip.c,v 1.6 2001/03/25 20:44:02 jsm Exp $");
10 #endif				/* not lint */
11 
12 #include "hack.h"
13 #include "extern.h"
14 
15 static const char    *riptop = "\
16                        ----------\n\
17                       /          \\\n\
18                      /    REST    \\\n\
19                     /      IN      \\\n\
20                    /     PEACE      \\\n\
21                   /                  \\";
22 
23 static const char    *ripmid = "                  | %*s%*s |\n";
24 
25 static const char    *ripbot = "\
26                  *|     *  *  *      | *\n\
27         _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______";
28 
29 void
30 outrip()
31 {
32 	char            buf[BUFSZ];
33 
34 	cls();
35 	curs(1, 8);
36 	puts(riptop);
37 	(void) strcpy(buf, plname);
38 	buf[16] = 0;
39 	center(6, buf);
40 	(void) sprintf(buf, "%ld AU", u.ugold);
41 	center(7, buf);
42 	(void) sprintf(buf, "killed by%s",
43 		       !strncmp(killer, "the ", 4) ? "" :
44 		       !strcmp(killer, "starvation") ? "" :
45 		       strchr(vowels, *killer) ? " an" : " a");
46 	center(8, buf);
47 	(void) strcpy(buf, killer);
48 	{
49 		int             i1;
50 		if ((i1 = strlen(buf)) > 16) {
51 			int             i, i0;
52 			i0 = i1 = 0;
53 			for (i = 0; i <= 16; i++)
54 				if (buf[i] == ' ')
55 					i0 = i, i1 = i + 1;
56 			if (!i0)
57 				i0 = i1 = 16;
58 			buf[i1 + 16] = 0;
59 			buf[i0] = 0;
60 		}
61 		center(9, buf);
62 		center(10, buf + i1);
63 	}
64 	(void) sprintf(buf, "%4d", getyear());
65 	center(11, buf);
66 	puts(ripbot);
67 	getret();
68 }
69 
70 void
71 center(line, text)
72 	int             line __attribute__((__unused__));
73 	char           *text;
74 {
75 	int             n = strlen(text) / 2;
76 	printf(ripmid, 8 + n, text, 8 - n, "");
77 }
78