IMPORT openssh-9.8p1
[dragonfly.git] / games / adventure / done.c
blob872ade787948c62d9d8fa935760681794cb1f437
1 /* @(#)done.c 8.1 (Berkeley) 5/31/93 */
2 /* $NetBSD: done.c,v 1.10 2009/08/25 06:56:52 dholland Exp $ */
4 /*-
5 * Copyright (c) 1991, 1993
6 * The Regents of the University of California. All rights reserved.
8 * The game adventure was originally written in Fortran by Will Crowther
9 * and Don Woods. It was later translated to C and enhanced by Jim
10 * Gillogly. This code is derived from software contributed to Berkeley
11 * by Jim Gillogly at The Rand Corporation.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
38 /* Re-coding of advent in C: termination routines */
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include "hdr.h"
43 #include "extern.h"
45 int
46 score(void)
47 { /* sort of like 20000 */
48 int myscore, i;
50 maxscore = myscore = 0;
51 for (i = 50; i <= maxtrs; i++) {
52 if (ptext[i].txtlen == 0)
53 continue;
54 k = 12;
55 if (i == chest)
56 k = 14;
57 if (i > chest)
58 k = 16;
59 if (prop[i] >= 0)
60 myscore += 2;
61 if (place[i] == 3 && prop[i] == 0)
62 myscore += k - 2;
63 maxscore += k;
65 myscore += (maxdie - numdie) * 10;
66 maxscore += maxdie * 10;
67 if (!(scoring || gaveup))
68 myscore += 4;
69 maxscore += 4;
70 if (dflag != 0)
71 myscore += 25;
72 maxscore += 25;
73 if (isclosing)
74 myscore += 25;
75 maxscore += 25;
76 if (closed) {
77 if (bonus == 0)
78 myscore += 10;
79 if (bonus == 135)
80 myscore += 25;
81 if (bonus == 134)
82 myscore += 30;
83 if (bonus == 133)
84 myscore += 45;
86 maxscore += 45;
87 if (place[magazine] == 108)
88 myscore++;
89 maxscore++;
90 myscore += 2;
91 maxscore += 2;
92 for (i = 1; i <= hintmax; i++)
93 if (hinted[i])
94 myscore -= hints[i][2];
95 return myscore;
98 /* entry=1 means goto 13000 */ /* game is over */
99 /* entry=2 means goto 20000 */ /* 3=19000 */
100 void
101 done(int entry)
103 int i, sc;
104 if (entry == 1)
105 mspeak(1);
106 if (entry == 3)
107 rspeak(136);
108 printf("\n\n\nYou scored %d out of a ", (sc = score()));
109 printf("possible %d using %d turns.\n", maxscore, turns);
110 for (i = 1; i <= classes; i++)
111 if (cval[i] >= sc) {
112 speak(&ctext[i]);
113 if (i == classes - 1) {
114 printf("To achieve the next higher rating");
115 printf(" would be a neat trick!\n\n");
116 printf("Congratulations!!\n");
117 exit(0);
119 k = cval[i] + 1 - sc;
120 printf("To achieve the next higher rating, you need");
121 printf(" %d more point", k);
122 if (k == 1)
123 printf(".\n");
124 else
125 printf("s.\n");
126 exit(0);
128 printf("You just went off my scale!!!\n");
129 exit(0);
132 /* label 90 */
133 void
134 die(int entry)
136 int i;
137 if (entry != 99) {
138 rspeak(23);
139 oldloc2 = loc;
141 if (isclosing) { /* 99 */
142 rspeak(131);
143 numdie++;
144 done(2);
146 yea = yes(81 + numdie * 2, 82 + numdie * 2, 54);
147 numdie++;
148 if (numdie == maxdie || !yea)
149 done(2);
150 place[water] = 0;
151 place[oil] = 0;
152 if (toting(lamp))
153 prop[lamp] = 0;
154 for (i = 100; i >= 1; i--) {
155 if (!toting(i))
156 continue;
157 k = oldloc2;
158 if (i == lamp)
159 k = 1;
160 drop(i, k);
162 loc = 3;
163 oldloc = loc;