xref: /netbsd-src/games/hack/hack.rip.c (revision 9b92b18917b4c29b1cbe6d1f767f22032b69993a)
1*9b92b189Sdholland /*	$NetBSD: hack.rip.c,v 1.12 2009/08/12 07:28:41 dholland Exp $	*/
23ea4a95cSchristos 
3210cab45Smycroft /*
41c7f94e5Sjsm  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
51c7f94e5Sjsm  * Amsterdam
61c7f94e5Sjsm  * All rights reserved.
71c7f94e5Sjsm  *
81c7f94e5Sjsm  * Redistribution and use in source and binary forms, with or without
91c7f94e5Sjsm  * modification, are permitted provided that the following conditions are
101c7f94e5Sjsm  * met:
111c7f94e5Sjsm  *
121c7f94e5Sjsm  * - Redistributions of source code must retain the above copyright notice,
131c7f94e5Sjsm  * this list of conditions and the following disclaimer.
141c7f94e5Sjsm  *
151c7f94e5Sjsm  * - Redistributions in binary form must reproduce the above copyright
161c7f94e5Sjsm  * notice, this list of conditions and the following disclaimer in the
171c7f94e5Sjsm  * documentation and/or other materials provided with the distribution.
181c7f94e5Sjsm  *
191c7f94e5Sjsm  * - Neither the name of the Stichting Centrum voor Wiskunde en
201c7f94e5Sjsm  * Informatica, nor the names of its contributors may be used to endorse or
211c7f94e5Sjsm  * promote products derived from this software without specific prior
221c7f94e5Sjsm  * written permission.
231c7f94e5Sjsm  *
241c7f94e5Sjsm  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
251c7f94e5Sjsm  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
261c7f94e5Sjsm  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
271c7f94e5Sjsm  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
281c7f94e5Sjsm  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
291c7f94e5Sjsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
301c7f94e5Sjsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
311c7f94e5Sjsm  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
321c7f94e5Sjsm  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
331c7f94e5Sjsm  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
341c7f94e5Sjsm  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
351c7f94e5Sjsm  */
361c7f94e5Sjsm 
371c7f94e5Sjsm /*
381c7f94e5Sjsm  * Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
391c7f94e5Sjsm  * All rights reserved.
401c7f94e5Sjsm  *
411c7f94e5Sjsm  * Redistribution and use in source and binary forms, with or without
421c7f94e5Sjsm  * modification, are permitted provided that the following conditions
431c7f94e5Sjsm  * are met:
441c7f94e5Sjsm  * 1. Redistributions of source code must retain the above copyright
451c7f94e5Sjsm  *    notice, this list of conditions and the following disclaimer.
461c7f94e5Sjsm  * 2. Redistributions in binary form must reproduce the above copyright
471c7f94e5Sjsm  *    notice, this list of conditions and the following disclaimer in the
481c7f94e5Sjsm  *    documentation and/or other materials provided with the distribution.
491c7f94e5Sjsm  * 3. The name of the author may not be used to endorse or promote products
501c7f94e5Sjsm  *    derived from this software without specific prior written permission.
511c7f94e5Sjsm  *
521c7f94e5Sjsm  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
531c7f94e5Sjsm  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
541c7f94e5Sjsm  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
551c7f94e5Sjsm  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
561c7f94e5Sjsm  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
571c7f94e5Sjsm  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
581c7f94e5Sjsm  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
591c7f94e5Sjsm  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
601c7f94e5Sjsm  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
611c7f94e5Sjsm  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62210cab45Smycroft  */
63210cab45Smycroft 
643ea4a95cSchristos #include <sys/cdefs.h>
65210cab45Smycroft #ifndef lint
66*9b92b189Sdholland __RCSID("$NetBSD: hack.rip.c,v 1.12 2009/08/12 07:28:41 dholland Exp $");
67210cab45Smycroft #endif				/* not lint */
6861f28255Scgd 
6961f28255Scgd #include "hack.h"
703ea4a95cSchristos #include "extern.h"
7161f28255Scgd 
72ab8b6343Sjsm static const char    *riptop = "\
73047e0042Smycroft                        ----------\n\
74047e0042Smycroft                       /          \\\n\
75047e0042Smycroft                      /    REST    \\\n\
76047e0042Smycroft                     /      IN      \\\n\
77047e0042Smycroft                    /     PEACE      \\\n\
78047e0042Smycroft                   /                  \\";
79047e0042Smycroft 
80ab8b6343Sjsm static const char    *ripmid = "                  | %*s%*s |\n";
81047e0042Smycroft 
82ab8b6343Sjsm static const char    *ripbot = "\
83047e0042Smycroft                  *|     *  *  *      | *\n\
84047e0042Smycroft         _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______";
8561f28255Scgd 
86*9b92b189Sdholland static void center(int, char *);
87*9b92b189Sdholland 
883ea4a95cSchristos void
outrip(void)891fa8a9a6Sdholland outrip(void)
903ea4a95cSchristos {
9161f28255Scgd 	char            buf[BUFSZ];
9261f28255Scgd 
9361f28255Scgd 	cls();
94047e0042Smycroft 	curs(1, 8);
95047e0042Smycroft 	puts(riptop);
9661f28255Scgd 	(void) strcpy(buf, plname);
9761f28255Scgd 	buf[16] = 0;
9861f28255Scgd 	center(6, buf);
99907fca1bSdholland 	(void) snprintf(buf, sizeof(buf), "%ld AU", u.ugold);
10061f28255Scgd 	center(7, buf);
101907fca1bSdholland 	(void) snprintf(buf, sizeof(buf), "killed by%s",
10261f28255Scgd 		       !strncmp(killer, "the ", 4) ? "" :
10361f28255Scgd 		       !strcmp(killer, "starvation") ? "" :
1043ea4a95cSchristos 		       strchr(vowels, *killer) ? " an" : " a");
10561f28255Scgd 	center(8, buf);
106165c915bSdholland 	(void) strlcpy(buf, killer, sizeof(buf));
107047e0042Smycroft 	{
1083ea4a95cSchristos 		int             i1;
109047e0042Smycroft 		if ((i1 = strlen(buf)) > 16) {
1103ea4a95cSchristos 			int             i, i0;
11161f28255Scgd 			i0 = i1 = 0;
11261f28255Scgd 			for (i = 0; i <= 16; i++)
1133ea4a95cSchristos 				if (buf[i] == ' ')
1143ea4a95cSchristos 					i0 = i, i1 = i + 1;
1153ea4a95cSchristos 			if (!i0)
1163ea4a95cSchristos 				i0 = i1 = 16;
11761f28255Scgd 			buf[i1 + 16] = 0;
11861f28255Scgd 			buf[i0] = 0;
11961f28255Scgd 		}
12061f28255Scgd 		center(9, buf);
121047e0042Smycroft 		center(10, buf + i1);
122047e0042Smycroft 	}
123907fca1bSdholland 	(void) snprintf(buf, sizeof(buf), "%4d", getyear());
12461f28255Scgd 	center(11, buf);
125047e0042Smycroft 	puts(ripbot);
12661f28255Scgd 	getret();
12761f28255Scgd }
12861f28255Scgd 
129*9b92b189Sdholland static void
center(int line __unused,char * text)1301fa8a9a6Sdholland center(int line __unused, char *text)
1313ea4a95cSchristos {
1323ea4a95cSchristos 	int             n = strlen(text) / 2;
133047e0042Smycroft 	printf(ripmid, 8 + n, text, 8 - n, "");
13461f28255Scgd }
135