xref: /dflybsd-src/games/hack/hack.rip.c (revision 4318c66eac379e15105fe145d406dfef81b795f6)
1*4318c66eSSascha Wildner /*	$NetBSD: hack.rip.c,v 1.12 2009/08/12 07:28:41 dholland Exp $	*/
2*4318c66eSSascha Wildner 
3*4318c66eSSascha Wildner /*
4*4318c66eSSascha Wildner  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
5*4318c66eSSascha Wildner  * Amsterdam
6*4318c66eSSascha Wildner  * All rights reserved.
7*4318c66eSSascha Wildner  *
8*4318c66eSSascha Wildner  * Redistribution and use in source and binary forms, with or without
9*4318c66eSSascha Wildner  * modification, are permitted provided that the following conditions are
10*4318c66eSSascha Wildner  * met:
11*4318c66eSSascha Wildner  *
12*4318c66eSSascha Wildner  * - Redistributions of source code must retain the above copyright notice,
13*4318c66eSSascha Wildner  * this list of conditions and the following disclaimer.
14*4318c66eSSascha Wildner  *
15*4318c66eSSascha Wildner  * - Redistributions in binary form must reproduce the above copyright
16*4318c66eSSascha Wildner  * notice, this list of conditions and the following disclaimer in the
17*4318c66eSSascha Wildner  * documentation and/or other materials provided with the distribution.
18*4318c66eSSascha Wildner  *
19*4318c66eSSascha Wildner  * - Neither the name of the Stichting Centrum voor Wiskunde en
20*4318c66eSSascha Wildner  * Informatica, nor the names of its contributors may be used to endorse or
21*4318c66eSSascha Wildner  * promote products derived from this software without specific prior
22*4318c66eSSascha Wildner  * written permission.
23*4318c66eSSascha Wildner  *
24*4318c66eSSascha Wildner  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25*4318c66eSSascha Wildner  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26*4318c66eSSascha Wildner  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27*4318c66eSSascha Wildner  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28*4318c66eSSascha Wildner  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29*4318c66eSSascha Wildner  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30*4318c66eSSascha Wildner  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31*4318c66eSSascha Wildner  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32*4318c66eSSascha Wildner  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33*4318c66eSSascha Wildner  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34*4318c66eSSascha Wildner  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35*4318c66eSSascha Wildner  */
36*4318c66eSSascha Wildner 
37*4318c66eSSascha Wildner /*
38*4318c66eSSascha Wildner  * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
39*4318c66eSSascha Wildner  * All rights reserved.
40*4318c66eSSascha Wildner  *
41*4318c66eSSascha Wildner  * Redistribution and use in source and binary forms, with or without
42*4318c66eSSascha Wildner  * modification, are permitted provided that the following conditions
43*4318c66eSSascha Wildner  * are met:
44*4318c66eSSascha Wildner  * 1. Redistributions of source code must retain the above copyright
45*4318c66eSSascha Wildner  *    notice, this list of conditions and the following disclaimer.
46*4318c66eSSascha Wildner  * 2. Redistributions in binary form must reproduce the above copyright
47*4318c66eSSascha Wildner  *    notice, this list of conditions and the following disclaimer in the
48*4318c66eSSascha Wildner  *    documentation and/or other materials provided with the distribution.
49*4318c66eSSascha Wildner  * 3. The name of the author may not be used to endorse or promote products
50*4318c66eSSascha Wildner  *    derived from this software without specific prior written permission.
51*4318c66eSSascha Wildner  *
52*4318c66eSSascha Wildner  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
53*4318c66eSSascha Wildner  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
54*4318c66eSSascha Wildner  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
55*4318c66eSSascha Wildner  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56*4318c66eSSascha Wildner  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57*4318c66eSSascha Wildner  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
58*4318c66eSSascha Wildner  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
59*4318c66eSSascha Wildner  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
60*4318c66eSSascha Wildner  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
61*4318c66eSSascha Wildner  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62*4318c66eSSascha Wildner  */
63984263bcSMatthew Dillon 
64984263bcSMatthew Dillon #include "hack.h"
65*4318c66eSSascha Wildner #include "extern.h"
66984263bcSMatthew Dillon 
67*4318c66eSSascha Wildner static const char    *riptop = "\
68*4318c66eSSascha Wildner                        ----------\n\
69*4318c66eSSascha Wildner                       /          \\\n\
70*4318c66eSSascha Wildner                      /    REST    \\\n\
71*4318c66eSSascha Wildner                     /      IN      \\\n\
72*4318c66eSSascha Wildner                    /     PEACE      \\\n\
73*4318c66eSSascha Wildner                   /                  \\";
74984263bcSMatthew Dillon 
75*4318c66eSSascha Wildner static const char    *ripmid = "                  | %*s%*s |\n";
76*4318c66eSSascha Wildner 
77*4318c66eSSascha Wildner static const char    *ripbot = "\
78*4318c66eSSascha Wildner                  *|     *  *  *      | *\n\
79*4318c66eSSascha Wildner         _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______";
80*4318c66eSSascha Wildner 
81*4318c66eSSascha Wildner static void center(int, char *);
82984263bcSMatthew Dillon 
83c7106d58SPeter Avalos void
outrip(void)84c7106d58SPeter Avalos outrip(void)
85c7106d58SPeter Avalos {
86984263bcSMatthew Dillon 	char            buf[BUFSZ];
87984263bcSMatthew Dillon 
88984263bcSMatthew Dillon 	cls();
89*4318c66eSSascha Wildner 	curs(1, 8);
90*4318c66eSSascha Wildner 	puts(riptop);
91*4318c66eSSascha Wildner 	(void) strcpy(buf, plname);
92984263bcSMatthew Dillon 	buf[16] = 0;
93984263bcSMatthew Dillon 	center(6, buf);
94*4318c66eSSascha Wildner 	(void) snprintf(buf, sizeof(buf), "%ld AU", u.ugold);
95984263bcSMatthew Dillon 	center(7, buf);
96*4318c66eSSascha Wildner 	(void) snprintf(buf, sizeof(buf), "killed by%s",
97984263bcSMatthew Dillon 		       !strncmp(killer, "the ", 4) ? "" :
98984263bcSMatthew Dillon 		       !strcmp(killer, "starvation") ? "" :
996693db17SSascha Wildner 		       strchr(vowels, *killer) ? " an" : " a");
100984263bcSMatthew Dillon 	center(8, buf);
101*4318c66eSSascha Wildner 	(void) strlcpy(buf, killer, sizeof(buf));
102*4318c66eSSascha Wildner 	{
103*4318c66eSSascha Wildner 		int             i1;
104*4318c66eSSascha Wildner 		if ((i1 = strlen(buf)) > 16) {
105*4318c66eSSascha Wildner 			int             i, i0;
106984263bcSMatthew Dillon 			i0 = i1 = 0;
107984263bcSMatthew Dillon 			for (i = 0; i <= 16; i++)
1086693db17SSascha Wildner 				if (buf[i] == ' ')
1096693db17SSascha Wildner 					i0 = i, i1 = i + 1;
1106693db17SSascha Wildner 			if (!i0)
1116693db17SSascha Wildner 				i0 = i1 = 16;
112984263bcSMatthew Dillon 			buf[i1 + 16] = 0;
113984263bcSMatthew Dillon 			buf[i0] = 0;
114984263bcSMatthew Dillon 		}
115984263bcSMatthew Dillon 		center(9, buf);
116*4318c66eSSascha Wildner 		center(10, buf + i1);
117*4318c66eSSascha Wildner 	}
118*4318c66eSSascha Wildner 	(void) snprintf(buf, sizeof(buf), "%4d", getyear());
119984263bcSMatthew Dillon 	center(11, buf);
120*4318c66eSSascha Wildner 	puts(ripbot);
121984263bcSMatthew Dillon 	getret();
122984263bcSMatthew Dillon }
123984263bcSMatthew Dillon 
124fd2d026fSYONETANI Tomokazu static void
center(int line __unused,char * text)125*4318c66eSSascha Wildner center(int line __unused, char *text)
126fd2d026fSYONETANI Tomokazu {
127*4318c66eSSascha Wildner 	int             n = strlen(text) / 2;
128*4318c66eSSascha Wildner 	printf(ripmid, 8 + n, text, 8 - n, "");
129984263bcSMatthew Dillon }
130