]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - battlestar/com2.c
Use a lookup table to identify whether objects are plural or singular,
[bsdgames-darwin.git] / battlestar / com2.c
index 0de73532d9a12b5d4da2d05e4293563e34f1ec9d..07634da4b6bace12a5c5135fb10334c4854b13f7 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: com2.c,v 1.13 2000/09/22 08:18:20 jsm Exp $    */
+/*     $NetBSD: com2.c,v 1.15 2000/09/23 19:23:57 jsm Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)com2.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: com2.c,v 1.13 2000/09/22 08:18:20 jsm Exp $");
+__RCSID("$NetBSD: com2.c,v 1.15 2000/09/23 19:23:57 jsm Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -47,17 +47,15 @@ __RCSID("$NetBSD: com2.c,v 1.13 2000/09/22 08:18:20 jsm Exp $");
 int
 wearit()
 {                              /* synonyms = {sheathe, sheath} */
-       int     n;
        int     firstnumber, value;
 
        firstnumber = wordnumber;
-       while (wordtype[++wordnumber] == ADJS);
+       wordnumber++;
        while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT ||
            wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) {
                value = wordvalue[wordnumber];
                if (objsht[value] == NULL)
                        break;
-               for (n = 0; objsht[value][n]; n++);
                switch (value) {
 
                case -1:
@@ -65,7 +63,7 @@ wearit()
                        return (firstnumber);
 
                default:
-                       printf("You can't wear%s%s!\n", (objsht[value][n - 1] == 's' ? " " : " a "), objsht[value]);
+                       printf("You can't wear%s%s!\n", (is_plural_object(value) ? " " : " a "), objsht[value]);
                        return (firstnumber);
 
                case KNIFE:
@@ -94,7 +92,7 @@ wearit()
                                encumber -= objcumber[value];
                                ourtime++;
                                printf("You are now wearing %s %s.\n",
-                                   (objsht[value][n - 1] == 's' ? "the"
+                                   (is_plural_object(value) ? "the"
                                        : "a"), objsht[value]);
                        } else
                                if (testbit(wear, value))
@@ -139,7 +137,7 @@ draw()
 int
 use()
 {
-       while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
+       wordnumber++;
        if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
            position != FINAL) {
                puts("The amulet begins to glow.");
@@ -184,9 +182,7 @@ murder()
        if (n == NUMOFOBJECTS) {
                if (testbit(inven, LASER)) {
                        printf("Your laser should do the trick.\n");
-                       n = wordnumber;
-                       while (wordtype[++n] == ADJS)
-                               ;
+                       n = wordnumber + 1;
                        switch(wordvalue[n]) {
                        case NORMGOD:
                        case TIMER:
@@ -211,7 +207,7 @@ murder()
                        puts("You don't have suitable weapons to kill.");
        } else {
                printf("Your %s should do the trick.\n", objsht[n]);
-               while (wordtype[++wordnumber] == ADJS);
+               wordnumber++;
                switch (wordvalue[wordnumber]) {
 
                case NORMGOD: