]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.16 2000/09/22 08:19:21 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.16 2000/09/22 08:19:21 jsm Exp $");
54 char *filename
, *rfilename
;
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 (!moveplayer(location
[position
].up
, AHEAD
))
67 puts("There is no way up.");
74 if (!moveplayer(location
[position
].down
, AHEAD
))
80 if (!moveplayer(left
, LEFT
))
86 if (!moveplayer(right
, RIGHT
))
92 if (!moveplayer(ahead
, AHEAD
))
98 if (!moveplayer(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 /* Some objects (type NOUNS)
122 * have special treatment in
123 * take(). For these we
124 * must set the type to NOUNS.
125 * However for SWORD and BODY
126 * all it does is find which
127 * of many objects is meant,
128 * so we need do nothing here.
129 * BATHGOD must become
130 * NORMGOD as well. NOUNS
131 * with no special case
132 * must be included here to
133 * get the right error. DOOR
134 * cannot occur as an object
135 * so need not be included. */
138 wordvalue
[wordnumber
+ 1] = NORMGOD
;
147 wordtype
[wordnumber
+ 1] = NOUNS
;
150 wordtype
[wordnumber
+ 1] = OBJECT
;
152 wordnumber
= take(location
[position
].objects
);
157 take(location
[position
].objects
);
162 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
163 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
164 if (testbit(inven
, n
)) {
165 wordvalue
[wordnumber
+ 1] = n
;
166 wordnumber
= drop("Dropped");
177 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
178 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
179 if (testbit(inven
, n
) ||
180 (testbit(location
[position
].objects
, n
) && objsht
[n
])) {
181 wordvalue
[wordnumber
+ 1] = n
;
182 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
186 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
190 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
191 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
192 if (testbit(wear
, n
)) {
193 wordvalue
[wordnumber
+ 1] = n
;
194 wordnumber
= takeoff();
204 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
205 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
206 if (testbit(wear
, n
)) {
207 wordvalue
[wordnumber
+ 1] = n
;
218 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
219 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
220 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
221 wordvalue
[wordnumber
+ 1] = n
;
222 wordnumber
= puton();
231 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
232 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
233 if (testbit(inven
, n
)) {
234 wordvalue
[wordnumber
+ 1] = n
;
235 wordnumber
= wearit();
245 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
246 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
247 if (testbit(inven
, n
)) {
248 wordvalue
[wordnumber
+ 1] = n
;
264 puts("You are holding:\n");
265 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
266 if (testbit(inven
, n
))
267 printf("\t%s\n", objsht
[n
]);
268 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."), (WEIGHT
? carrying
* 100 / WEIGHT
: -1));
269 printf("Your arms are %d%% full.\n", encumber
* 100 / CUMBER
);
271 puts("You aren't carrying anything.");
274 puts("\nYou are wearing:\n");
275 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
276 if (testbit(wear
, n
))
277 printf("\t%s\n", objsht
[n
]);
279 puts("\nYou are stark naked.");
280 if (card(injuries
, NUMOFINJURIES
)) {
281 puts("\nYou have suffered:\n");
282 for (n
= 0; n
< NUMOFINJURIES
; n
++)
284 printf("\t%s\n", ouch
[n
]);
285 printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT
, (WEIGHT
== 1 ? "." : "s."));
287 puts("\nYou are in perfect health.");
296 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
299 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
300 if (testbit(inven
, n
)) {
302 wordvalue
[wordnumber
+ 1] = n
;
307 puts("Nothing to open!");
313 if (!notes
[CANTSEE
] || testbit(inven
, LAMPON
) ||
314 testbit(location
[position
].objects
, LAMPON
)
316 beenthere
[position
] = 2;
320 puts("\nYour match splutters out.");
324 puts("I can't see anything.");
329 if (wiz
|| tempwiz
) {
330 printf("\nRoom (was %d) = ", position
);
331 fgets(buffer
, 10, stdin
);
333 sscanf(buffer
, "%d", &position
);
334 printf("Time (was %d) = ", ourtime
);
335 fgets(buffer
, 10, stdin
);
337 sscanf(buffer
, "%d", &ourtime
);
338 printf("Fuel (was %d) = ", fuel
);
339 fgets(buffer
, 10, stdin
);
341 sscanf(buffer
, "%d", &fuel
);
342 printf("Torps (was %d) = ", torps
);
343 fgets(buffer
, 10, stdin
);
345 sscanf(buffer
, "%d", &torps
);
346 printf("CUMBER (was %d) = ", CUMBER
);
347 fgets(buffer
, 10, stdin
);
349 sscanf(buffer
, "%d", &CUMBER
);
350 printf("WEIGHT (was %d) = ", WEIGHT
);
351 fgets(buffer
, 10, stdin
);
353 sscanf(buffer
, "%d", &WEIGHT
);
354 printf("Clock (was %d) = ", ourclock
);
355 fgets(buffer
, 10, stdin
);
357 sscanf(buffer
, "%d", &ourclock
);
358 printf("Wizard (was %d, %d) = ", wiz
, tempwiz
);
359 fgets(buffer
, 10, stdin
);
360 if (*buffer
!= '\n') {
361 sscanf(buffer
, "%d", &junk
);
368 puts("You aren't a wizard.");
372 printf("\tPLEASURE\tPOWER\t\tEGO\n");
373 printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure
, power
, ego
);
374 printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime
);
375 printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere
, NUMOFROOMS
), NUMOFROOMS
, card(beenthere
, NUMOFROOMS
) * 100 / NUMOFROOMS
);
389 printf("\nSave file name (default %s): ",
391 filename
= fgetln(stdin
, &filename_len
);
392 if (filename_len
== 0
393 || (filename_len
== 1 && filename
[0] == '\n'))
394 rfilename
= save_file_name(DEFAULT_SAVE_FILE
,
395 strlen(DEFAULT_SAVE_FILE
));
397 if (filename
[filename_len
- 1] == '\n')
399 rfilename
= save_file_name(filename
,
408 printf("[Maximum verbosity]\n");
413 printf("[Standard verbosity]\n");
496 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')