2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)cypher.c 8.1 (Berkeley) 5/31/93
34 * $FreeBSD: src/games/battlestar/cypher.c,v 1.7.2.1 2001/03/05 11:45:36 kris Exp $
35 * $DragonFly: src/games/battlestar/cypher.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $
48 while (wordtype
[wordnumber
] == ADJS
)
50 while (wordnumber
<= wordcount
) {
51 switch(wordvalue
[wordnumber
]) {
54 if (location
[position
].access
|| wiz
|| tempwiz
) {
55 if (!location
[position
].access
)
56 puts("Zap! A gust of wind lifts you up.");
57 if (!battlestar_move(location
[position
].up
, AHEAD
))
60 puts("There is no way up");
67 if (!battlestar_move(location
[position
].down
,
74 if (!battlestar_move(left
, LEFT
))
80 if (!battlestar_move(right
, RIGHT
))
86 if (!battlestar_move(ahead
, AHEAD
))
92 if (!battlestar_move(back
, BACK
))
98 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
99 for (n
=0; n
< NUMOFOBJECTS
; n
++)
100 if (testbit(location
[position
].objects
,n
) && objsht
[n
]){
101 wordvalue
[wordnumber
+1] = n
;
102 wordnumber
= shoot();
112 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
113 for (n
=0; n
< NUMOFOBJECTS
; n
++)
114 if (testbit(location
[position
].objects
,n
) && objsht
[n
]){
115 wordvalue
[wordnumber
+1] = n
;
116 wordnumber
= take(location
[position
].objects
);
122 take(location
[position
].objects
);
127 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
128 for (n
=0; n
< NUMOFOBJECTS
; n
++)
129 if (testbit(inven
,n
)){
130 wordvalue
[wordnumber
+1] = n
;
131 wordnumber
= drop("Dropped");
143 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
144 for (n
=0; n
< NUMOFOBJECTS
; n
++)
145 if ((testbit(inven
,n
) ||
146 testbit(location
[position
].objects
, n
)) && objsht
[n
]){
147 wordvalue
[wordnumber
+1] = n
;
148 wordnumber
= throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
152 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
156 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
157 for (n
=0; n
< NUMOFOBJECTS
; n
++)
158 if (testbit(wear
,n
)){
159 wordvalue
[wordnumber
+1] = n
;
160 wordnumber
= takeoff();
171 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
172 for (n
=0; n
< NUMOFOBJECTS
; n
++)
173 if (testbit(wear
,n
)){
174 wordvalue
[wordnumber
+1] = n
;
186 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
187 for (n
=0; n
< NUMOFOBJECTS
; n
++)
188 if (testbit(location
[position
].objects
,n
) && objsht
[n
]){
189 wordvalue
[wordnumber
+1] = n
;
190 wordnumber
= puton();
200 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
201 for (n
=0; n
< NUMOFOBJECTS
; n
++)
202 if (testbit(inven
,n
)){
203 wordvalue
[wordnumber
+1] = n
;
204 wordnumber
= wearit();
215 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == EVERYTHING
){
216 for (n
=0; n
< NUMOFOBJECTS
; n
++)
217 if (testbit(inven
,n
)){
218 wordvalue
[wordnumber
+1] = n
;
235 puts("You are holding:\n");
236 for (n
=0; n
< NUMOFOBJECTS
; n
++)
237 if (testbit(inven
,n
))
238 printf("\t%s\n", objsht
[n
]);
239 printf("\n= %d kilogram%s (%d%%)\n", carrying
, (carrying
== 1 ? "." : "s."),(WEIGHT
? carrying
*100/WEIGHT
: -1));
240 printf("Your arms are %d%% full.\n",encumber
*100/CUMBER
);
243 puts("You aren't carrying anything.");
246 puts("\nYou are wearing:\n");
247 for (n
=0; n
< NUMOFOBJECTS
; n
++)
249 printf("\t%s\n", objsht
[n
]);
252 puts("\nYou are stark naked.");
253 if (card(injuries
,NUMOFINJURIES
)){
254 puts("\nYou have suffered:\n");
255 for (n
=0; n
< NUMOFINJURIES
; n
++)
257 printf("\t%s\n",ouch
[n
]);
258 printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT
,(WEIGHT
== 1 ? "." : "s."));
261 puts("\nYou are in perfect health.");
269 if (!notes
[CANTSEE
] || testbit(inven
,LAMPON
) || testbit(location
[position
].objects
,LAMPON
) || matchlight
){
270 beenthere
[position
] = 2;
274 puts("\nYour match splutters out.");
278 puts("I can't see anything.");
284 printf("\nRoom (was %d) = ", position
);
285 fgets(buffer
,10,stdin
);
287 sscanf(buffer
,"%d", &position
);
288 printf("Time (was %d) = ",gtime
);
289 fgets(buffer
,10,stdin
);
291 sscanf(buffer
,"%d", >ime
);
292 printf("Fuel (was %d) = ",fuel
);
293 fgets(buffer
,10,stdin
);
295 sscanf(buffer
,"%d", &fuel
);
296 printf("Torps (was %d) = ",torps
);
297 fgets(buffer
,10,stdin
);
299 sscanf(buffer
,"%d", &torps
);
300 printf("CUMBER (was %d) = ",CUMBER
);
301 fgets(buffer
,10,stdin
);
303 sscanf(buffer
,"%d", &CUMBER
);
304 printf("WEIGHT (was %d) = ",WEIGHT
);
305 fgets(buffer
,10,stdin
);
307 sscanf(buffer
,"%d",&WEIGHT
);
308 printf("Clock (was %d) = ",gclock
);
309 fgets(buffer
,10,stdin
);
311 sscanf(buffer
,"%d",&gclock
);
312 printf("Wizard (was %d, %d) = ",wiz
, tempwiz
);
313 fgets(buffer
,10,stdin
);
314 if (*buffer
!= '\n'){
315 sscanf(buffer
,"%d",&junk
);
323 puts("You aren't a wizard.");
327 printf("\tPLEASURE\tPOWER\t\tEGO\n");
328 printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure
,power
,ego
);
329 printf("This gives you the rating of %s in %d turns.\n",rate(),gtime
);
330 printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere
,NUMOFROOMS
),NUMOFROOMS
,card(beenthere
,NUMOFROOMS
)*100/NUMOFROOMS
);
427 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')