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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)cypher.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/battlestar/cypher.c,v 1.7.2.1 2001/03/05 11:45:36 kris Exp $
31 * $DragonFly: src/games/battlestar/cypher.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $
45 while (wordtype
[wordnumber
] == ADJS
)
47 while (wordnumber
<= wordcount
) {
48 switch (wordvalue
[wordnumber
]) {
50 if (location
[position
].access
|| wiz
|| tempwiz
) {
51 if (!location
[position
].access
)
52 puts("Zap! A gust of wind lifts you up.");
53 if (!battlestar_move(location
[position
].up
, AHEAD
))
56 puts("There is no way up");
63 if (!battlestar_move(location
[position
].down
, AHEAD
))
69 if (!battlestar_move(left
, LEFT
))
75 if (!battlestar_move(right
, RIGHT
))
81 if (!battlestar_move(ahead
, AHEAD
))
87 if (!battlestar_move(back
, BACK
))
93 if (wordnumber
< wordcount
&&
94 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
95 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
96 if (testbit(location
[position
].objects
,
98 wordvalue
[wordnumber
+ 1] = n
;
108 if (wordnumber
< wordcount
&&
109 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
110 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
111 if (testbit(location
[position
].objects
,
113 wordvalue
[wordnumber
+ 1] = n
;
115 take(location
[position
].objects
);
120 take(location
[position
].objects
);
124 if (wordnumber
< wordcount
&&
125 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
126 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
127 if (testbit(inven
, n
)) {
128 wordvalue
[wordnumber
+ 1] = n
;
129 wordnumber
= drop("Dropped");
139 if (wordnumber
< wordcount
&&
140 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
141 for (n
= 0; n
< NUMOFOBJECTS
; n
++) {
142 if ((testbit(inven
, n
) ||
143 testbit(location
[position
].objects
, n
)) && objsht
[n
]) {
144 wordvalue
[wordnumber
+ 1] = n
;
145 wordnumber
= throw(wordvalue
[wordnumber
] ==
146 KICK
? "Kicked" : "Thrown");
151 throw(wordvalue
[wordnumber
] == KICK
? "Kicked" : "Thrown");
155 if (wordnumber
< wordcount
&&
156 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
157 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
158 if (testbit(wear
, n
)) {
159 wordvalue
[wordnumber
+ 1] = n
;
160 wordnumber
= takeoff();
168 if (wordnumber
< wordcount
&&
169 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
170 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
171 if (testbit(wear
, n
)) {
172 wordvalue
[wordnumber
+ 1] = n
;
181 if (wordnumber
< wordcount
&&
182 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
183 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
184 if (testbit(location
[position
].objects
,
186 wordvalue
[wordnumber
+ 1] = n
;
187 wordnumber
= puton();
195 if (wordnumber
< wordcount
&&
196 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
197 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
198 if (testbit(inven
, n
)) {
199 wordvalue
[wordnumber
+ 1] = n
;
200 wordnumber
= wearit();
208 if (wordnumber
< wordcount
&&
209 wordvalue
[wordnumber
+ 1] == EVERYTHING
) {
210 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
211 if (testbit(inven
, n
)) {
212 wordvalue
[wordnumber
+ 1] = n
;
226 puts("You are holding:\n");
227 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
228 if (testbit(inven
, n
))
229 printf("\t%s\n", objsht
[n
]);
230 printf("\n= %d kilogram%s (%d%%)\n", carrying
,
231 (carrying
== 1 ? "." : "s."),
232 (WEIGHT
? carrying
* 100 / WEIGHT
: -1));
233 printf("Your arms are %d%% full.\n",
234 encumber
* 100 / CUMBER
);
236 puts("You aren't carrying anything.");
239 puts("\nYou are wearing:\n");
240 for (n
= 0; n
< NUMOFOBJECTS
; n
++)
241 if (testbit(wear
, n
))
242 printf("\t%s\n", objsht
[n
]);
244 puts("\nYou are stark naked.");
245 if (card(injuries
, NUMOFINJURIES
)) {
246 puts("\nYou have suffered:\n");
247 for (n
= 0; n
< NUMOFINJURIES
; n
++)
249 printf("\t%s\n", ouch
[n
]);
250 printf("\nYou can still carry up to %d kilogram%s\n",
251 WEIGHT
, (WEIGHT
== 1 ? "." : "s."));
253 puts("\nYou are in perfect health.");
261 if (!notes
[CANTSEE
] || testbit(inven
, LAMPON
) ||
262 testbit(location
[position
].objects
, LAMPON
) ||
264 beenthere
[position
] = 2;
268 puts("\nYour match splutters out.");
272 puts("I can't see anything.");
277 if (wiz
|| tempwiz
) {
278 printf("\nRoom (was %d) = ", position
);
279 fgets(buffer
, 10, stdin
);
281 sscanf(buffer
, "%d", &position
);
282 printf("Time (was %d) = ", gtime
);
283 fgets(buffer
, 10, stdin
);
285 sscanf(buffer
, "%d", >ime
);
286 printf("Fuel (was %d) = ", fuel
);
287 fgets(buffer
, 10, stdin
);
289 sscanf(buffer
, "%d", &fuel
);
290 printf("Torps (was %d) = ", torps
);
291 fgets(buffer
, 10, stdin
);
293 sscanf(buffer
, "%d", &torps
);
294 printf("CUMBER (was %d) = ", CUMBER
);
295 fgets(buffer
, 10, stdin
);
297 sscanf(buffer
, "%d", &CUMBER
);
298 printf("WEIGHT (was %d) = ", WEIGHT
);
299 fgets(buffer
, 10, stdin
);
301 sscanf(buffer
, "%d", &WEIGHT
);
302 printf("Clock (was %d) = ", gclock
);
303 fgets(buffer
, 10, stdin
);
305 sscanf(buffer
, "%d", &gclock
);
306 printf("Wizard (was %d, %d) = ", wiz
, tempwiz
);
307 fgets(buffer
, 10, stdin
);
308 if (*buffer
!= '\n') {
309 sscanf(buffer
, "%d", &junk
);
316 puts("You aren't a wizard.");
320 printf("\tPLEASURE\tPOWER\t\tEGO\n");
321 printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure
, power
, ego
);
322 printf("This gives you the rating of %s in %d turns.\n",
324 printf("You have visited %d out of %d rooms this run (%d%%).\n",
325 card(beenthere
, NUMOFROOMS
), NUMOFROOMS
,
326 card(beenthere
, NUMOFROOMS
) * 100 / NUMOFROOMS
);
421 if (wordnumber
< wordcount
&& *words
[wordnumber
++] == ',')