]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.5 1997/10/10 11:39:38 lukem 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.5 1997/10/10 11:39:38 lukem 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();
118 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
119 for (n
=0; n
< NUMOFOBJECTS
; n
++)
120 if (testbit(location
[position
].objects
,n
) && *objsht
[n
]){
121 wordvalue
[wordnumber
+1] = n
;
122 wordnumber
= take(location
[position
].objects
);
128 take(location
[position
].objects
);
133 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
134 for (n
=0; n
< NUMOFOBJECTS
; n
++)
135 if (testbit(inven
,n
)){
136 wordvalue
[wordnumber
+1] = n
;
137 wordnumber
= drop("Dropped");
149 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
150 for (n
=0; n
< NUMOFOBJECTS
; n
++)
151 if (testbit(inven
,n
) ||
152 (testbit(location
[position
].objects
, n
) && *objsht
[n
])){
153 wordvalue
[wordnumber
+1] = n
;
154 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
158 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
162 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
163 for (n
=0; n
< NUMOFOBJECTS
; n
++)
164 if (testbit(wear
,n
)){
165 wordvalue
[wordnumber
+1] = n
;
166 wordnumber
= takeoff();
177 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
178 for (n
=0; n
< NUMOFOBJECTS
; n
++)
179 if (testbit(wear
,n
)){
180 wordvalue
[wordnumber
+1] = n
;
192 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
193 for (n
=0; n
< NUMOFOBJECTS
; n
++)
194 if (testbit(location
[position
].objects
,n
) && *objsht
[n
]){
195 wordvalue
[wordnumber
+1] = n
;
196 wordnumber
= puton();
206 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
207 for (n
=0; n
< NUMOFOBJECTS
; n
++)
208 if (testbit(inven
,n
)){
209 wordvalue
[wordnumber
+1] = n
;
210 wordnumber
= wearit();
221 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
222 for (n
=0; n
< NUMOFOBJECTS
; n
++)
223 if (testbit(inven
,n
)){
224 wordvalue
[wordnumber
+1] = n
;
241 puts("You are holding:\n");
242 for (n
=0; n
< NUMOFOBJECTS
; n
++)
243 if (testbit(inven
,n
))
244 printf("\t%s\n", objsht
[n
]);
245 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."),(WEIGHT
? carrying
*100/WEIGHT
: -1));
246 printf("Your arms are %d%% full.\n",encumber
*100/CUMBER
);
249 puts("You aren't carrying anything.");
252 puts("\nYou are wearing:\n");
253 for (n
=0; n
< NUMOFOBJECTS
; n
++)
255 printf("\t%s\n", objsht
[n
]);
258 puts("\nYou are stark naked.");
259 if (card(injuries
,NUMOFINJURIES
)){
260 puts("\nYou have suffered:\n");
261 for (n
=0; n
< NUMOFINJURIES
; n
++)
263 printf("\t%s\n",ouch
[n
]);
264 printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT
,(WEIGHT
== 1 ? "." : "s."));
267 puts("\nYou are in perfect health.");
275 if (!notes
[CANTSEE
] || testbit(inven
,LAMPON
) ||
276 testbit(location
[position
].objects
,LAMPON
)
278 beenthere
[position
] = 2;
282 puts("\nYour match splutters out.");
286 puts("I can't see anything.");
292 printf("\nRoom (was %d) = ", position
);
293 fgets(buffer
,10,stdin
);
295 sscanf(buffer
,"%d", &position
);
296 printf("Time (was %d) = ", ourtime
);
297 fgets(buffer
,10,stdin
);
299 sscanf(buffer
,"%d", &ourtime
);
300 printf("Fuel (was %d) = ",fuel
);
301 fgets(buffer
,10,stdin
);
303 sscanf(buffer
,"%d", &fuel
);
304 printf("Torps (was %d) = ",torps
);
305 fgets(buffer
,10,stdin
);
307 sscanf(buffer
,"%d", &torps
);
308 printf("CUMBER (was %d) = ",CUMBER
);
309 fgets(buffer
,10,stdin
);
311 sscanf(buffer
,"%d", &CUMBER
);
312 printf("WEIGHT (was %d) = ",WEIGHT
);
313 fgets(buffer
,10,stdin
);
315 sscanf(buffer
,"%d",&WEIGHT
);
316 printf("Clock (was %d) = ", ourclock
);
317 fgets(buffer
,10,stdin
);
319 sscanf(buffer
,"%d", &ourclock
);
320 printf("Wizard (was %d, %d) = ",wiz
, tempwiz
);
321 fgets(buffer
,10,stdin
);
322 if (*buffer
!= '\n'){
323 sscanf(buffer
,"%d",&junk
);
331 puts("You aren't a wizard.");
335 printf("\tPLEASURE\tPOWER\t\tEGO\n");
336 printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure
,power
,ego
);
337 printf("This gives you the rating of %s in %d turns.\n",rate(),ourtime
);
338 printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere
,NUMOFROOMS
),NUMOFROOMS
,card(beenthere
,NUMOFROOMS
)*100/NUMOFROOMS
);
435 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')