]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.7 1998/08/24 00:25:32 hubertf Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/cdefs.h>
39 static char sccsid
[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
41 __RCSID("$NetBSD: cypher.c,v 1.7 1998/08/24 00:25:32 hubertf Exp $");
55 while (wordtype
[wordnumber
] == ADJS
)
57 while (wordnumber
<= wordcount
) {
58 switch (wordvalue
[wordnumber
]) {
61 if (location
[position
].access
|| wiz
|| tempwiz
) {
62 if (!location
[position
].access
)
63 puts("Zap! A gust of wind lifts you up.");
64 if (!move(location
[position
].up
, AHEAD
))
67 puts("There is no way up");
74 if (!move(location
[position
].down
, AHEAD
))
80 if (!move(left
, LEFT
))
86 if (!move(right
, RIGHT
))
92 if (!move(ahead
, AHEAD
))
98 if (!move(back
, BACK
))
104 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
105 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
106 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
107 wordvalue
[wordnumber
+ 1] = n
;
108 wordnumber
= shoot();
117 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
118 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
119 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
120 wordvalue
[wordnumber
+ 1] = n
;
121 wordnumber
= take(location
[position
].objects
);
126 take(location
[position
].objects
);
131 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
132 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
133 if (testbit(inven
, n
)) {
134 wordvalue
[wordnumber
+ 1] = n
;
135 wordnumber
= drop("Dropped");
146 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
147 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
148 if (testbit(inven
, n
) ||
149 (testbit(location
[position
].objects
, n
) && objsht
[n
])) {
150 wordvalue
[wordnumber
+ 1] = n
;
151 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
155 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
159 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
160 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
161 if (testbit(wear
, n
)) {
162 wordvalue
[wordnumber
+ 1] = n
;
163 wordnumber
= takeoff();
173 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
174 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
175 if (testbit(wear
, n
)) {
176 wordvalue
[wordnumber
+ 1] = n
;
187 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
188 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
189 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
190 wordvalue
[wordnumber
+ 1] = n
;
191 wordnumber
= puton();
200 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
201 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
202 if (testbit(inven
, n
)) {
203 wordvalue
[wordnumber
+ 1] = n
;
204 wordnumber
= wearit();
214 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
215 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
216 if (testbit(inven
, n
)) {
217 wordvalue
[wordnumber
+ 1] = n
;
233 puts("You are holding:\n");
234 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
235 if (testbit(inven
, n
))
236 printf("\t%s\n", objsht
[n
]);
237 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."), (WEIGHT
? carrying
* 100 / WEIGHT
: -1));
238 printf("Your arms are %d%% full.\n", encumber
* 100 / CUMBER
);
240 puts("You aren't carrying anything.");
243 puts("\nYou are wearing:\n");
244 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
245 if (testbit(wear
, n
))
246 printf("\t%s\n", objsht
[n
]);
248 puts("\nYou are stark naked.");
249 if (card(injuries
, NUMOFINJURIES
)) {
250 puts("\nYou have suffered:\n");
251 for (n
= 0; n
< NUMOFINJURIES
; n
++)
253 printf("\t%s\n", ouch
[n
]);
254 printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT
, (WEIGHT
== 1 ? "." : "s."));
256 puts("\nYou are in perfect health.");
264 if (!notes
[CANTSEE
] || testbit(inven
, LAMPON
) ||
265 testbit(location
[position
].objects
, LAMPON
)
267 beenthere
[position
] = 2;
271 puts("\nYour match splutters out.");
275 puts("I can't see anything.");
280 if (wiz
|| tempwiz
) {
281 printf("\nRoom (was %d) = ", position
);
282 fgets(buffer
, 10, stdin
);
284 sscanf(buffer
, "%d", &position
);
285 printf("Time (was %d) = ", ourtime
);
286 fgets(buffer
, 10, stdin
);
288 sscanf(buffer
, "%d", &ourtime
);
289 printf("Fuel (was %d) = ", fuel
);
290 fgets(buffer
, 10, stdin
);
292 sscanf(buffer
, "%d", &fuel
);
293 printf("Torps (was %d) = ", torps
);
294 fgets(buffer
, 10, stdin
);
296 sscanf(buffer
, "%d", &torps
);
297 printf("CUMBER (was %d) = ", CUMBER
);
298 fgets(buffer
, 10, stdin
);
300 sscanf(buffer
, "%d", &CUMBER
);
301 printf("WEIGHT (was %d) = ", WEIGHT
);
302 fgets(buffer
, 10, stdin
);
304 sscanf(buffer
, "%d", &WEIGHT
);
305 printf("Clock (was %d) = ", ourclock
);
306 fgets(buffer
, 10, stdin
);
308 sscanf(buffer
, "%d", &ourclock
);
309 printf("Wizard (was %d, %d) = ", wiz
, tempwiz
);
310 fgets(buffer
, 10, stdin
);
311 if (*buffer
!= '\n') {
312 sscanf(buffer
, "%d", &junk
);
319 puts("You aren't a wizard.");
323 printf("\tPLEASURE\tPOWER\t\tEGO\n");
324 printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure
, power
, ego
);
325 printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime
);
326 printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere
, NUMOFROOMS
), NUMOFROOMS
, card(beenthere
, NUMOFROOMS
) * 100 / NUMOFROOMS
);
423 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')