]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
Give a better message for trying to eat things it doesn't make sense
authorjsm <jsm@NetBSD.org>
Sun, 24 Sep 2000 09:46:03 +0000 (09:46 +0000)
committerjsm <jsm@NetBSD.org>
Sun, 24 Sep 2000 09:46:03 +0000 (09:46 +0000)
to eat.  For something eatable, check first whether you're holding it,
then whether you have a knife, then whether you're stuffed (gives
better message for "eat coconuts" when you don't have any).  From
OpenBSD.

battlestar/com4.c

index fde7872f743116bb5830794d2325654144c0f54b..e4b1e07857e0470ebec922e4c1085f374162ba5c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: com4.c,v 1.15 2000/09/24 09:39:56 jsm Exp $    */
+/*     $NetBSD: com4.c,v 1.16 2000/09/24 09:46:03 jsm Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)com4.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: com4.c,v 1.15 2000/09/24 09:39:56 jsm Exp $");
+__RCSID("$NetBSD: com4.c,v 1.16 2000/09/24 09:46:03 jsm Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -371,10 +371,14 @@ eat()
        wordnumber++;
        while (wordnumber <= wordcount) {
                value = wordvalue[wordnumber];
-               if (wordtype[wordnumber] != OBJECT)
-                       value = -1;
+               if (wordtype[wordnumber] != OBJECT || objsht[value] == NULL)
+                       value = -2;
                switch (value) {
 
+               case -2:
+                       puts("You can't eat that!");
+                       return (firstnumber);
+
                case -1:
                        puts("Eat what?");
                        return (firstnumber);
@@ -402,12 +406,12 @@ eat()
                                snooze += CYCLE / 10;
                                ourtime++;
                                puts("Eaten.  You can explore a little longer now.");
-                       } else if (ourtime < ate - CYCLE)
-                               puts("You're stuffed.");
+                       } else if (!testbit(inven, value))
+                               printf("You aren't holding the %s.\n", objsht[value]);
                        else if (!testbit(inven, KNIFE))
                                puts("You need a knife.");
                        else
-                               printf("You aren't holding the %s.\n", objsht[value]);
+                               puts("You're stuffed.");
                        if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
                                wordnumber++;
                        else