]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.21 2000/09/25 19:37:58 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.21 2000/09/25 19:37:58 jsm Exp $");
54 char *filename
, *rfilename
;
57 while (wordnumber
<= wordcount
) {
58 if (wordtype
[wordnumber
] != VERB
&&
59 !(wordtype
[wordnumber
] == OBJECT
&& wordvalue
[wordnumber
] == KNIFE
)) {
60 printf("%s: How's that?\n",
61 (wordnumber
== wordcount
) ? words
[0] : words
[wordnumber
]);
65 switch (wordvalue
[wordnumber
]) {
69 * Take the following word as the verb (e.g.
70 * "make love", "climb up").
76 if (location
[position
].access
|| wiz
|| tempwiz
) {
77 if (!location
[position
].access
)
78 puts("Zap! A gust of wind lifts you up.");
79 if (!moveplayer(location
[position
].up
, AHEAD
))
82 puts("There is no way up.");
89 if (!moveplayer(location
[position
].down
, AHEAD
))
95 if (!moveplayer(left
, LEFT
))
101 if (!moveplayer(right
, RIGHT
))
107 if (!moveplayer(ahead
, AHEAD
))
113 if (!moveplayer(back
, BACK
))
119 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
122 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
123 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
125 wordvalue
[wordnumber
+ 1] = n
;
126 wordnumber
= shoot();
129 puts("Nothing to shoot at!");
137 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
140 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
141 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
143 wordvalue
[wordnumber
+ 1] = n
;
144 /* Some objects (type NOUNS)
145 * have special treatment in
146 * take(). For these we
147 * must set the type to NOUNS.
148 * However for SWORD and BODY
149 * all it does is find which
150 * of many objects is meant,
151 * so we need do nothing here.
152 * BATHGOD must become
153 * NORMGOD as well. NOUNS
154 * with no special case
155 * must be included here to
156 * get the right error. DOOR
157 * cannot occur as an object
158 * so need not be included. */
161 wordvalue
[wordnumber
+ 1] = NORMGOD
;
170 wordtype
[wordnumber
+ 1] = NOUNS
;
173 wordtype
[wordnumber
+ 1] = OBJECT
;
175 wordnumber
= take(location
[position
].objects
);
180 puts("Nothing to take!");
182 take(location
[position
].objects
);
186 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
189 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
190 if (testbit(inven
, n
)) {
192 wordvalue
[wordnumber
+ 1] = n
;
193 wordnumber
= drop("Dropped");
198 puts("Nothing to drop!");
205 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
208 wv
= wordvalue
[wordnumber
];
209 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
210 if (testbit(inven
, n
) ||
211 (testbit(location
[position
].objects
, n
) && objsht
[n
])) {
213 wordvalue
[wordnumber
+ 1] = n
;
214 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
218 printf("Nothing to %s!\n", wv
== KICK
? "kick" : "throw");
220 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
224 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
227 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
228 if (testbit(wear
, n
)) {
230 wordvalue
[wordnumber
+ 1] = n
;
231 wordnumber
= takeoff();
235 puts("Nothing to take off!");
241 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
244 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
245 if (testbit(wear
, n
)) {
247 wordvalue
[wordnumber
+ 1] = n
;
252 puts("Nothing to draw!");
258 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
261 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
262 if (testbit(location
[position
].objects
, n
) && objsht
[n
]) {
264 wordvalue
[wordnumber
+ 1] = n
;
265 wordnumber
= puton();
269 puts("Nothing to put on!");
275 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
278 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
279 if (testbit(inven
, n
)) {
281 wordvalue
[wordnumber
+ 1] = n
;
282 wordnumber
= wearit();
286 puts("Nothing to wear!");
292 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
295 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
296 if (testbit(inven
, n
)) {
298 wordvalue
[wordnumber
+ 1] = n
;
303 puts("Nothing to eat!");
314 puts("You are holding:\n");
315 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
316 if (testbit(inven
, n
))
317 printf("\t%s\n", objsht
[n
]);
319 printf("\n= %d kilogram%s (can't lift any weight%s)\n",
321 (carrying
== 1 ? "." : "s."),
322 (carrying
? " or move with what you have" : ""));
324 printf("\n= %d kilogram%s (%d%%)\n",
326 (carrying
== 1 ? "." : "s."),
327 carrying
* 100 / WEIGHT
);
329 printf("Your arms can't pick anything up.\n");
331 printf("Your arms are %d%% full.\n",
332 encumber
* 100 / CUMBER
);
334 puts("You aren't carrying anything.");
337 puts("\nYou are wearing:\n");
338 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
339 if (testbit(wear
, n
))
340 printf("\t%s\n", objsht
[n
]);
342 puts("\nYou are stark naked.");
343 if (card(injuries
, NUMOFINJURIES
)) {
344 puts("\nYou have suffered:\n");
345 for (n
= 0; n
< NUMOFINJURIES
; n
++)
347 printf("\t%s\n", ouch
[n
]);
348 printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT
, (WEIGHT
== 1 ? "." : "s."));
350 puts("\nYou are in perfect health.");
359 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
362 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
363 if (testbit(inven
, n
)) {
365 wordvalue
[wordnumber
+ 1] = n
;
370 puts("Nothing to open!");
376 if (!notes
[CANTSEE
] || testbit(inven
, LAMPON
) ||
377 testbit(location
[position
].objects
, LAMPON
)
379 beenthere
[position
] = 2;
383 puts("\nYour match splutters out.");
387 puts("I can't see anything.");
392 if (wiz
|| tempwiz
) {
393 printf("\nRoom (was %d) = ", position
);
394 fgets(buffer
, 10, stdin
);
396 sscanf(buffer
, "%d", &position
);
397 printf("Time (was %d) = ", ourtime
);
398 fgets(buffer
, 10, stdin
);
400 sscanf(buffer
, "%d", &ourtime
);
401 printf("Fuel (was %d) = ", fuel
);
402 fgets(buffer
, 10, stdin
);
404 sscanf(buffer
, "%d", &fuel
);
405 printf("Torps (was %d) = ", torps
);
406 fgets(buffer
, 10, stdin
);
408 sscanf(buffer
, "%d", &torps
);
409 printf("CUMBER (was %d) = ", CUMBER
);
410 fgets(buffer
, 10, stdin
);
412 sscanf(buffer
, "%d", &CUMBER
);
413 printf("WEIGHT (was %d) = ", WEIGHT
);
414 fgets(buffer
, 10, stdin
);
416 sscanf(buffer
, "%d", &WEIGHT
);
417 printf("Clock (was %d) = ", ourclock
);
418 fgets(buffer
, 10, stdin
);
420 sscanf(buffer
, "%d", &ourclock
);
421 printf("Wizard (was %d, %d) = ", wiz
, tempwiz
);
422 fgets(buffer
, 10, stdin
);
423 if (*buffer
!= '\n') {
424 sscanf(buffer
, "%d", &junk
);
431 puts("You aren't a wizard.");
435 printf("\tPLEASURE\tPOWER\t\tEGO\n");
436 printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure
, power
, ego
);
437 printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime
);
438 printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere
, NUMOFROOMS
), NUMOFROOMS
, card(beenthere
, NUMOFROOMS
) * 100 / NUMOFROOMS
);
452 printf("\nSave file name (default %s): ",
454 filename
= fgetln(stdin
, &filename_len
);
455 if (filename_len
== 0
456 || (filename_len
== 1 && filename
[0] == '\n'))
457 rfilename
= save_file_name(DEFAULT_SAVE_FILE
,
458 strlen(DEFAULT_SAVE_FILE
));
460 if (filename
[filename_len
- 1] == '\n')
462 rfilename
= save_file_name(filename
,
471 printf("[Maximum verbosity]\n");
476 printf("[Standard verbosity]\n");
558 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')