-/* $NetBSD: cypher.c,v 1.18 2000/09/24 09:41:53 jsm Exp $ */
+/* $NetBSD: cypher.c,v 1.23 2005/07/01 06:04:54 jmc Exp $ */
/*
* Copyright (c) 1983, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: cypher.c,v 1.18 2000/09/24 09:41:53 jsm Exp $");
+__RCSID("$NetBSD: cypher.c,v 1.23 2005/07/01 06:04:54 jmc Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
-cypher()
+cypher(void)
{
int n;
int junk;
size_t filename_len;
while (wordnumber <= wordcount) {
+ if (wordtype[wordnumber] != VERB &&
+ !(wordtype[wordnumber] == OBJECT &&
+ wordvalue[wordnumber] == KNIFE)) {
+ printf("%s: How's that?\n",
+ (wordnumber == wordcount) ? words[0] :
+ words[wordnumber]);
+ return (-1);
+ }
+
switch (wordvalue[wordnumber]) {
+ case AUXVERB:
+ /*
+ * Take the following word as the verb (e.g.
+ * "make love", "climb up").
+ */
+ wordnumber++;
+ continue;
+
case UP:
if (location[position].access || wiz || tempwiz) {
- if (!location[position].access)
- puts("Zap! A gust of wind lifts you up.");
+ if (!location[position].access) {
+ printf("Zap! A gust of wind lifts ");
+ puts("you up.");
+ }
if (!moveplayer(location[position].up, AHEAD))
return (-1);
} else {
break;
case SHOOT:
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
- if (testbit(location[position].objects, n) && objsht[n]) {
+ if (testbit(location[position].objects,
+ n) && objsht[n]) {
things++;
wordvalue[wordnumber + 1] = n;
wordnumber = shoot();
break;
case TAKE:
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
- if (testbit(location[position].objects, n) && objsht[n]) {
+ if (testbit(location[position].objects,
+ n) && objsht[n]) {
things++;
wordvalue[wordnumber + 1] = n;
/* Some objects (type NOUNS)
break;
case DROP:
-
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
drop("Dropped");
break;
-
case KICK:
case THROW:
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things, wv;
things = 0;
wv = wordvalue[wordnumber];
}
wordnumber += 2;
if (!things)
- printf("Nothing to %s!\n", wv == KICK ? "kick" : "throw");
+ printf("Nothing to %s!\n",
+ wv == KICK ? "kick" : "throw");
} else
- throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
+ throw(wordvalue[wordnumber] ==
+ KICK ? "Kicked" : "Thrown");
break;
case TAKEOFF:
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
takeoff();
break;
-
case DRAW:
-
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
draw();
break;
-
case PUTON:
-
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
- if (testbit(location[position].objects, n) && objsht[n]) {
+ if (testbit(location[position].objects,
+ n) && objsht[n]) {
things++;
wordvalue[wordnumber + 1] = n;
wordnumber = puton();
break;
case WEARIT:
-
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
wearit();
break;
-
case EAT:
-
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
eat();
break;
-
case PUT:
put();
break;
-
case INVEN:
if (ucard(inven)) {
puts("You are holding:\n");
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n))
printf("\t%s\n", objsht[n]);
- printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), (WEIGHT ? carrying * 100 / WEIGHT : -1));
- printf("Your arms are %d%% full.\n",
- (CUMBER ? encumber * 100 / CUMBER : -1));
+ if (WEIGHT == 0) {
+ printf("\n= %d kilogram%s",
+ carrying,
+ (carrying == 1 ? "." : "s."));
+ printf(" (can't lift any weight%s)\n",
+ (carrying ?
+ " or move with what you have" :
+ ""));
+ } else
+ printf("\n= %d kilogram%s (%d%%)\n",
+ carrying,
+ (carrying == 1 ? "." : "s."),
+ carrying * 100 / WEIGHT);
+ if (CUMBER == 0) {
+ printf("Your arms can't pick ");
+ printf("anything up.\n");
+ } else
+ printf("Your arms are %d%% full.\n",
+ encumber * 100 / CUMBER);
} else
puts("You aren't carrying anything.");
for (n = 0; n < NUMOFINJURIES; n++)
if (injuries[n])
printf("\t%s\n", ouch[n]);
- printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s."));
+ printf("\nYou can still carry up to ");
+ printf("%d kilogram%s\n", WEIGHT,
+ (WEIGHT == 1 ? "." : "s."));
} else
puts("\nYou are in perfect health.");
wordnumber++;
break;
case OPEN:
- if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
+ if (wordnumber < wordcount &&
+ wordvalue[wordnumber + 1] == EVERYTHING) {
int things;
things = 0;
for (n = 0; n < NUMOFOBJECTS; n++)
case SCORE:
printf("\tPLEASURE\tPOWER\t\tEGO\n");
printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure, power, ego);
- printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime);
- printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere, NUMOFROOMS), NUMOFROOMS, card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS);
+ printf("This gives you the rating of ");
+ printf("%s in %d turns.\n", rate(), ourtime);
+ printf("You have visited %d out of %d rooms ",
+ card(beenthere, NUMOFROOMS), NUMOFROOMS);
+ printf("this run (%d%%).\n",
+ card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS);
break;
case KNIFE:
return (-1);
break;
-
}
if (wordnumber < wordcount && *words[wordnumber++] == ',')
continue;