]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/cypher.c
1 /* $NetBSD: cypher.c,v 1.4 1997/01/07 11:56:39 tls 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
38 static char sccsid
[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
40 static char rcsid
[] = "$NetBSD: cypher.c,v 1.4 1997/01/07 11:56:39 tls Exp $";
53 while (wordtype
[wordnumber
] == ADJS
)
55 while (wordnumber
<= wordcount
) {
56 switch(wordvalue
[wordnumber
]) {
59 if (location
[position
].access
|| wiz
|| tempwiz
) {
60 if (!location
[position
].access
)
61 puts("Zap! A gust of wind lifts you up.");
62 if (!move(location
[position
].up
, AHEAD
))
65 puts("There is no way up");
72 if (!move(location
[position
].down
, AHEAD
))
78 if (!move(left
, LEFT
))
84 if (!move(right
, RIGHT
))
90 if (!move(ahead
, AHEAD
))
96 if (!move(back
, BACK
))
102 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
103 for (n
=0; n
< NUMOFOBJECTS
; n
++)
104 if (testbit(location
[position
].objects
,n
) && *objsht
[n
]){
105 wordvalue
[wordnumber
+1] = n
;
106 wordnumber
= shoot();
116 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
117 for (n
=0; n
< NUMOFOBJECTS
; n
++)
118 if (testbit(location
[position
].objects
,n
) && *objsht
[n
]){
119 wordvalue
[wordnumber
+1] = n
;
120 wordnumber
= take(location
[position
].objects
);
126 take(location
[position
].objects
);
131 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
132 for (n
=0; n
< NUMOFOBJECTS
; n
++)
133 if (testbit(inven
,n
)){
134 wordvalue
[wordnumber
+1] = n
;
135 wordnumber
= drop("Dropped");
147 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
148 for (n
=0; n
< NUMOFOBJECTS
; n
++)
149 if (testbit(inven
,n
) ||
150 testbit(location
[position
].objects
, n
) && *objsht
[n
]){
151 wordvalue
[wordnumber
+1] = n
;
152 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
156 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
160 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
161 for (n
=0; n
< NUMOFOBJECTS
; n
++)
162 if (testbit(wear
,n
)){
163 wordvalue
[wordnumber
+1] = n
;
164 wordnumber
= takeoff();
175 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
176 for (n
=0; n
< NUMOFOBJECTS
; n
++)
177 if (testbit(wear
,n
)){
178 wordvalue
[wordnumber
+1] = n
;
190 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
191 for (n
=0; n
< NUMOFOBJECTS
; n
++)
192 if (testbit(location
[position
].objects
,n
) && *objsht
[n
]){
193 wordvalue
[wordnumber
+1] = n
;
194 wordnumber
= puton();
204 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
205 for (n
=0; n
< NUMOFOBJECTS
; n
++)
206 if (testbit(inven
,n
)){
207 wordvalue
[wordnumber
+1] = n
;
208 wordnumber
= wearit();
219 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
220 for (n
=0; n
< NUMOFOBJECTS
; n
++)
221 if (testbit(inven
,n
)){
222 wordvalue
[wordnumber
+1] = n
;
239 puts("You are holding:\n");
240 for (n
=0; n
< NUMOFOBJECTS
; n
++)
241 if (testbit(inven
,n
))
242 printf("\t%s\n", objsht
[n
]);
243 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."),(WEIGHT
? carrying
*100/WEIGHT
: -1));
244 printf("Your arms are %d%% full.\n",encumber
*100/CUMBER
);
247 puts("You aren't carrying anything.");
250 puts("\nYou are wearing:\n");
251 for (n
=0; n
< NUMOFOBJECTS
; n
++)
253 printf("\t%s\n", objsht
[n
]);
256 puts("\nYou are stark naked.");
257 if (card(injuries
,NUMOFINJURIES
)){
258 puts("\nYou have suffered:\n");
259 for (n
=0; n
< NUMOFINJURIES
; n
++)
261 printf("\t%s\n",ouch
[n
]);
262 printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT
,(WEIGHT
== 1 ? "." : "s."));
265 puts("\nYou are in perfect health.");
273 if (!notes
[CANTSEE
] || testbit(inven
,LAMPON
) || testbit(location
[position
].objects
,LAMPON
) || matchlight
){
274 beenthere
[position
] = 2;
278 puts("\nYour match splutters out.");
282 puts("I can't see anything.");
288 printf("\nRoom (was %d) = ", position
);
289 fgets(buffer
,10,stdin
);
291 sscanf(buffer
,"%d", &position
);
292 printf("Time (was %d) = ",time
);
293 fgets(buffer
,10,stdin
);
295 sscanf(buffer
,"%d", &time
);
296 printf("Fuel (was %d) = ",fuel
);
297 fgets(buffer
,10,stdin
);
299 sscanf(buffer
,"%d", &fuel
);
300 printf("Torps (was %d) = ",torps
);
301 fgets(buffer
,10,stdin
);
303 sscanf(buffer
,"%d", &torps
);
304 printf("CUMBER (was %d) = ",CUMBER
);
305 fgets(buffer
,10,stdin
);
307 sscanf(buffer
,"%d", &CUMBER
);
308 printf("WEIGHT (was %d) = ",WEIGHT
);
309 fgets(buffer
,10,stdin
);
311 sscanf(buffer
,"%d",&WEIGHT
);
312 printf("Clock (was %d) = ",clock
);
313 fgets(buffer
,10,stdin
);
315 sscanf(buffer
,"%d",&clock
);
316 printf("Wizard (was %d, %d) = ",wiz
, tempwiz
);
317 fgets(buffer
,10,stdin
);
318 if (*buffer
!= '\n'){
319 sscanf(buffer
,"%d",&junk
);
327 puts("You aren't a wizard.");
331 printf("\tPLEASURE\tPOWER\t\tEGO\n");
332 printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure
,power
,ego
);
333 printf("This gives you the rating of %s in %d turns.\n",rate(),time
);
334 printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere
,NUMOFROOMS
),NUMOFROOMS
,card(beenthere
,NUMOFROOMS
)*100/NUMOFROOMS
);
431 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')