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[] =
51 while (wordtype[wordnumber] == ADJS)
53 while (wordnumber <= wordcount) {
54 switch(wordvalue[wordnumber]) {
57 if (location[position].access || wiz || tempwiz) {
58 if (!location[position].access)
59 puts("Zap! A gust of wind lifts you up.");
60 if (!move(location[position].up, AHEAD))
63 puts("There is no way up");
70 if (!move(location[position].down, AHEAD))
76 if (!move(left, LEFT))
82 if (!move(right, RIGHT))
88 if (!move(ahead, AHEAD))
94 if (!move(back, BACK))
100 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
101 for (n=0; n < NUMOFOBJECTS; n++)
102 if (testbit(location[position].objects,n) && objsht[n]){
103 wordvalue[wordnumber+1] = n;
104 wordnumber = shoot();
114 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
115 for (n=0; n < NUMOFOBJECTS; n++)
116 if (testbit(location[position].objects,n) && objsht[n]){
117 wordvalue[wordnumber+1] = n;
118 wordnumber = take(location[position].objects);
124 take(location[position].objects);
129 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
130 for (n=0; n < NUMOFOBJECTS; n++)
131 if (testbit(inven,n)){
132 wordvalue[wordnumber+1] = n;
133 wordnumber = drop("Dropped");
145 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
146 for (n=0; n < NUMOFOBJECTS; n++)
147 if (testbit(inven,n) ||
148 testbit(location[position].objects, n) && objsht[n]){
149 wordvalue[wordnumber+1] = n;
150 wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
154 throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
158 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
159 for (n=0; n < NUMOFOBJECTS; n++)
160 if (testbit(wear,n)){
161 wordvalue[wordnumber+1] = n;
162 wordnumber = takeoff();
173 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
174 for (n=0; n < NUMOFOBJECTS; n++)
175 if (testbit(wear,n)){
176 wordvalue[wordnumber+1] = n;
188 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
189 for (n=0; n < NUMOFOBJECTS; n++)
190 if (testbit(location[position].objects,n) && objsht[n]){
191 wordvalue[wordnumber+1] = n;
192 wordnumber = puton();
202 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
203 for (n=0; n < NUMOFOBJECTS; n++)
204 if (testbit(inven,n)){
205 wordvalue[wordnumber+1] = n;
206 wordnumber = wearit();
217 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
218 for (n=0; n < NUMOFOBJECTS; n++)
219 if (testbit(inven,n)){
220 wordvalue[wordnumber+1] = n;
237 puts("You are holding:\n");
238 for (n=0; n < NUMOFOBJECTS; n++)
239 if (testbit(inven,n))
240 printf("\t%s\n", objsht[n]);
241 printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."),(WEIGHT ? carrying*100/WEIGHT : -1));
242 printf("Your arms are %d%% full.\n",encumber*100/CUMBER);
245 puts("You aren't carrying anything.");
248 puts("\nYou are wearing:\n");
249 for (n=0; n < NUMOFOBJECTS; n++)
251 printf("\t%s\n", objsht[n]);
254 puts("\nYou are stark naked.");
255 if (card(injuries,NUMOFINJURIES)){
256 puts("\nYou have suffered:\n");
257 for (n=0; n < NUMOFINJURIES; n++)
259 printf("\t%s\n",ouch[n]);
260 printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT,(WEIGHT == 1 ? "." : "s."));
263 puts("\nYou are in perfect health.");
271 if (!notes[CANTSEE] || testbit(inven,LAMPON) || testbit(location[position].objects,LAMPON) || matchlight){
272 beenthere[position] = 2;
276 puts("\nYour match splutters out.");
280 puts("I can't see anything.");
286 printf("\nRoom (was %d) = ", position);
287 fgets(buffer,10,stdin);
289 sscanf(buffer,"%d", &position);
290 printf("Time (was %d) = ",gtime);
291 fgets(buffer,10,stdin);
293 sscanf(buffer,"%d", >ime);
294 printf("Fuel (was %d) = ",fuel);
295 fgets(buffer,10,stdin);
297 sscanf(buffer,"%d", &fuel);
298 printf("Torps (was %d) = ",torps);
299 fgets(buffer,10,stdin);
301 sscanf(buffer,"%d", &torps);
302 printf("CUMBER (was %d) = ",CUMBER);
303 fgets(buffer,10,stdin);
305 sscanf(buffer,"%d", &CUMBER);
306 printf("WEIGHT (was %d) = ",WEIGHT);
307 fgets(buffer,10,stdin);
309 sscanf(buffer,"%d",&WEIGHT);
310 printf("Clock (was %d) = ",gclock);
311 fgets(buffer,10,stdin);
313 sscanf(buffer,"%d",&gclock);
314 printf("Wizard (was %d, %d) = ",wiz, tempwiz);
315 fgets(buffer,10,stdin);
316 if (*buffer != '\n'){
317 sscanf(buffer,"%d",&junk);
325 puts("You aren't a wizard.");
329 printf("\tPLEASURE\tPOWER\t\tEGO\n");
330 printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure,power,ego);
331 printf("This gives you the rating of %s in %d turns.\n",rate(),gtime);
332 printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere,NUMOFROOMS),NUMOFROOMS,card(beenthere,NUMOFROOMS)*100/NUMOFROOMS);
429 if (wordnumber < wordcount && *words[wordnumber++] == ',')