]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.10 1999/09/18 16:41:38 jsm 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.10 1999/09/18 16:41:38 jsm 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
;
149 wordtype
[wordnumber
+ 1] = NOUNS
;
152 wordtype
[wordnumber
+ 1] = OBJECT
;
154 wordnumber
= take(location
[position
].objects
);
159 take(location
[position
].objects
);
164 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
165 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
166 if (testbit(inven
, n
)) {
167 wordvalue
[wordnumber
+ 1] = n
;
168 wordnumber
= drop("Dropped");
179 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
180 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
181 if (testbit(inven
, n
) ||
182 (testbit(location
[position
].objects
, n
) && objsht
[n
])) {
183 wordvalue
[wordnumber
+ 1] = n
;
184 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
188 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
192 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
193 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
194 if (testbit(wear
, n
)) {
195 wordvalue
[wordnumber
+ 1] = n
;
196 wordnumber
= takeoff();
206 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
207 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
208 if (testbit(wear
, n
)) {
209 wordvalue
[wordnumber
+ 1] = n
;
220 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
221 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
222 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
223 wordvalue
[wordnumber
+ 1] = n
;
224 wordnumber
= puton();
233 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
234 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
235 if (testbit(inven
, n
)) {
236 wordvalue
[wordnumber
+ 1] = n
;
237 wordnumber
= wearit();
247 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
248 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
249 if (testbit(inven
, n
)) {
250 wordvalue
[wordnumber
+ 1] = n
;
266 puts("You are holding:\n");
267 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
268 if (testbit(inven
, n
))
269 printf("\t%s\n", objsht
[n
]);
270 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."), (WEIGHT
? carrying
* 100 / WEIGHT
: -1));
271 printf("Your arms are %d%% full.\n", encumber
* 100 / CUMBER
);
273 puts("You aren't carrying anything.");
276 puts("\nYou are wearing:\n");
277 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
278 if (testbit(wear
, n
))
279 printf("\t%s\n", objsht
[n
]);
281 puts("\nYou are stark naked.");
282 if (card(injuries
, NUMOFINJURIES
)) {
283 puts("\nYou have suffered:\n");
284 for (n
= 0; n
< NUMOFINJURIES
; n
++)
286 printf("\t%s\n", ouch
[n
]);
287 printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT
, (WEIGHT
== 1 ? "." : "s."));
289 puts("\nYou are in perfect health.");
297 if (!notes
[CANTSEE
] || testbit(inven
, LAMPON
) ||
298 testbit(location
[position
].objects
, LAMPON
)
300 beenthere
[position
] = 2;
304 puts("\nYour match splutters out.");
308 puts("I can't see anything.");
313 if (wiz
|| tempwiz
) {
314 printf("\nRoom (was %d) = ", position
);
315 fgets(buffer
, 10, stdin
);
317 sscanf(buffer
, "%d", &position
);
318 printf("Time (was %d) = ", ourtime
);
319 fgets(buffer
, 10, stdin
);
321 sscanf(buffer
, "%d", &ourtime
);
322 printf("Fuel (was %d) = ", fuel
);
323 fgets(buffer
, 10, stdin
);
325 sscanf(buffer
, "%d", &fuel
);
326 printf("Torps (was %d) = ", torps
);
327 fgets(buffer
, 10, stdin
);
329 sscanf(buffer
, "%d", &torps
);
330 printf("CUMBER (was %d) = ", CUMBER
);
331 fgets(buffer
, 10, stdin
);
333 sscanf(buffer
, "%d", &CUMBER
);
334 printf("WEIGHT (was %d) = ", WEIGHT
);
335 fgets(buffer
, 10, stdin
);
337 sscanf(buffer
, "%d", &WEIGHT
);
338 printf("Clock (was %d) = ", ourclock
);
339 fgets(buffer
, 10, stdin
);
341 sscanf(buffer
, "%d", &ourclock
);
342 printf("Wizard (was %d, %d) = ", wiz
, tempwiz
);
343 fgets(buffer
, 10, stdin
);
344 if (*buffer
!= '\n') {
345 sscanf(buffer
, "%d", &junk
);
352 puts("You aren't a wizard.");
356 printf("\tPLEASURE\tPOWER\t\tEGO\n");
357 printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure
, power
, ego
);
358 printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime
);
359 printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere
, NUMOFROOMS
), NUMOFROOMS
, card(beenthere
, NUMOFROOMS
) * 100 / NUMOFROOMS
);
373 printf("\nSave file name (default %s) ",
375 filename
= fgetln(stdin
, &filename_len
);
376 if (filename_len
== 0
377 || (filename_len
== 1 && filename
[0] == '\n'))
378 rfilename
= save_file_name(DEFAULT_SAVE_FILE
,
379 strlen(DEFAULT_SAVE_FILE
));
381 if (filename
[filename_len
- 1] == '\n')
383 rfilename
= save_file_name(filename
,
470 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')