]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - battlestar/cypher.c
fish: remove trailing whitespace
[bsdgames-darwin.git] / battlestar / cypher.c
index 6fd3c7dfc8bd2bc14210346e475762d688339687..fa81192447bd22fa13fd05b37d8bf01822a6bfd9 100644 (file)
@@ -1,4 +1,4 @@
-/*     $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;
@@ -55,12 +51,31 @@ cypher()
        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 {
@@ -101,11 +116,13 @@ cypher()
                        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();
@@ -119,11 +136,13 @@ cypher()
                        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)
@@ -168,8 +187,8 @@ cypher()
                        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++)
@@ -186,10 +205,10 @@ cypher()
                                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];
@@ -202,13 +221,16 @@ cypher()
                                        }
                                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++)
@@ -224,10 +246,9 @@ cypher()
                                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++)
@@ -243,14 +264,14 @@ cypher()
                                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();
@@ -263,8 +284,8 @@ cypher()
                        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++)
@@ -280,10 +301,9 @@ cypher()
                                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++)
@@ -299,21 +319,35 @@ cypher()
                                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.");
 
@@ -329,7 +363,9 @@ cypher()
                                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++;
@@ -340,7 +376,8 @@ cypher()
                        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++)
@@ -418,8 +455,12 @@ cypher()
                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:
@@ -538,7 +579,6 @@ cypher()
                        return (-1);
                        break;
 
-
                }
                if (wordnumber < wordcount && *words[wordnumber++] == ',')
                        continue;