]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.9 1999/07/28 01:45:42 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.9 1999/07/28 01:45:42 hubertf Exp $");
54 char *filename
, *rfilename
;
57 while (wordtype
[wordnumber
] == ADJS
)
59 while (wordnumber
<= wordcount
) {
60 switch (wordvalue
[wordnumber
]) {
63 if (location
[position
].access
|| wiz
|| tempwiz
) {
64 if (!location
[position
].access
)
65 puts("Zap! A gust of wind lifts you up.");
66 if (!move(location
[position
].up
, AHEAD
))
69 puts("There is no way up");
76 if (!move(location
[position
].down
, AHEAD
))
82 if (!move(left
, LEFT
))
88 if (!move(right
, RIGHT
))
94 if (!move(ahead
, AHEAD
))
100 if (!move(back
, BACK
))
106 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
107 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
108 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
109 wordvalue
[wordnumber
+ 1] = n
;
110 wordnumber
= shoot();
119 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
120 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
121 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
122 wordvalue
[wordnumber
+ 1] = n
;
123 /* Some objects (type NOUNS)
124 * have special treatment in
125 * take(). For these we
126 * must set the type to NOUNS.
127 * However for SWORD and BODY
128 * all it does is find which
129 * of many objects is meant,
130 * so we need do nothing here.
131 * BATHGOD must become
132 * NORMGOD as well. NOUNS
133 * with no special case
134 * must be included here to
135 * get the right error. DOOR
136 * cannot occur as an object
137 * so need not be included. */
140 wordvalue
[wordnumber
+ 1] = NORMGOD
;
148 wordtype
[wordnumber
+ 1] = NOUNS
;
151 wordtype
[wordnumber
+ 1] = OBJECT
;
153 wordnumber
= take(location
[position
].objects
);
158 take(location
[position
].objects
);
163 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
164 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
165 if (testbit(inven
, n
)) {
166 wordvalue
[wordnumber
+ 1] = n
;
167 wordnumber
= drop("Dropped");
178 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
179 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
180 if (testbit(inven
, n
) ||
181 (testbit(location
[position
].objects
, n
) && objsht
[n
])) {
182 wordvalue
[wordnumber
+ 1] = n
;
183 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
187 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
191 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
192 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
193 if (testbit(wear
, n
)) {
194 wordvalue
[wordnumber
+ 1] = n
;
195 wordnumber
= takeoff();
205 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
206 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
207 if (testbit(wear
, n
)) {
208 wordvalue
[wordnumber
+ 1] = n
;
219 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
220 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
221 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
222 wordvalue
[wordnumber
+ 1] = n
;
223 wordnumber
= puton();
232 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
233 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
234 if (testbit(inven
, n
)) {
235 wordvalue
[wordnumber
+ 1] = n
;
236 wordnumber
= wearit();
246 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
247 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
248 if (testbit(inven
, n
)) {
249 wordvalue
[wordnumber
+ 1] = n
;
265 puts("You are holding:\n");
266 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
267 if (testbit(inven
, n
))
268 printf("\t%s\n", objsht
[n
]);
269 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."), (WEIGHT
? carrying
* 100 / WEIGHT
: -1));
270 printf("Your arms are %d%% full.\n", encumber
* 100 / CUMBER
);
272 puts("You aren't carrying anything.");
275 puts("\nYou are wearing:\n");
276 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
277 if (testbit(wear
, n
))
278 printf("\t%s\n", objsht
[n
]);
280 puts("\nYou are stark naked.");
281 if (card(injuries
, NUMOFINJURIES
)) {
282 puts("\nYou have suffered:\n");
283 for (n
= 0; n
< NUMOFINJURIES
; n
++)
285 printf("\t%s\n", ouch
[n
]);
286 printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT
, (WEIGHT
== 1 ? "." : "s."));
288 puts("\nYou are in perfect health.");
296 if (!notes
[CANTSEE
] || testbit(inven
, LAMPON
) ||
297 testbit(location
[position
].objects
, LAMPON
)
299 beenthere
[position
] = 2;
303 puts("\nYour match splutters out.");
307 puts("I can't see anything.");
312 if (wiz
|| tempwiz
) {
313 printf("\nRoom (was %d) = ", position
);
314 fgets(buffer
, 10, stdin
);
316 sscanf(buffer
, "%d", &position
);
317 printf("Time (was %d) = ", ourtime
);
318 fgets(buffer
, 10, stdin
);
320 sscanf(buffer
, "%d", &ourtime
);
321 printf("Fuel (was %d) = ", fuel
);
322 fgets(buffer
, 10, stdin
);
324 sscanf(buffer
, "%d", &fuel
);
325 printf("Torps (was %d) = ", torps
);
326 fgets(buffer
, 10, stdin
);
328 sscanf(buffer
, "%d", &torps
);
329 printf("CUMBER (was %d) = ", CUMBER
);
330 fgets(buffer
, 10, stdin
);
332 sscanf(buffer
, "%d", &CUMBER
);
333 printf("WEIGHT (was %d) = ", WEIGHT
);
334 fgets(buffer
, 10, stdin
);
336 sscanf(buffer
, "%d", &WEIGHT
);
337 printf("Clock (was %d) = ", ourclock
);
338 fgets(buffer
, 10, stdin
);
340 sscanf(buffer
, "%d", &ourclock
);
341 printf("Wizard (was %d, %d) = ", wiz
, tempwiz
);
342 fgets(buffer
, 10, stdin
);
343 if (*buffer
!= '\n') {
344 sscanf(buffer
, "%d", &junk
);
351 puts("You aren't a wizard.");
355 printf("\tPLEASURE\tPOWER\t\tEGO\n");
356 printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure
, power
, ego
);
357 printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime
);
358 printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere
, NUMOFROOMS
), NUMOFROOMS
, card(beenthere
, NUMOFROOMS
) * 100 / NUMOFROOMS
);
372 printf("\nSave file name (default %s) ",
374 filename
= fgetln(stdin
, &filename_len
);
375 if (filename_len
== 0
376 || (filename_len
== 1 && filename
[0] == '\n'))
377 rfilename
= save_file_name(DEFAULT_SAVE_FILE
,
378 strlen(DEFAULT_SAVE_FILE
));
380 if (filename
[filename_len
- 1] == '\n')
382 rfilename
= save_file_name(filename
,
469 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')