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
36 static char sccsid[] = "@(#)cypher.c 8.1 (Berkeley) 5/31/93";
38 static const char rcsid[] =
39 "$FreeBSD: src/games/battlestar/cypher.c,v 1.7.2.1 2001/03/05 11:45:36 kris Exp $";
52 while (wordtype[wordnumber] == ADJS)
54 while (wordnumber <= wordcount) {
55 switch(wordvalue[wordnumber]) {
58 if (location[position].access || wiz || tempwiz) {
59 if (!location[position].access)
60 puts("Zap! A gust of wind lifts you up.");
61 if (!battlestar_move(location[position].up, AHEAD))
64 puts("There is no way up");
71 if (!battlestar_move(location[position].down,
78 if (!battlestar_move(left, LEFT))
84 if (!battlestar_move(right, RIGHT))
90 if (!battlestar_move(ahead, AHEAD))
96 if (!battlestar_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) = ",gtime);
293 fgets(buffer,10,stdin);
295 sscanf(buffer,"%d", >ime);
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) = ",gclock);
313 fgets(buffer,10,stdin);
315 sscanf(buffer,"%d",&gclock);
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(),gtime);
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++] == ',')