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