summaryrefslogtreecommitdiffstats
path: root/battlestar
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2000-09-25 19:37:58 +0000
committerjsm <jsm@NetBSD.org>2000-09-25 19:37:58 +0000
commit4b57f3f1a523d33412704f3a5180f921002809b1 (patch)
tree3c2201e5d0147af39bdbf29e214b320ea2bfef2e /battlestar
parent671eb498250e6a38918c75f1c5dfb75e3212c305 (diff)
downloadbsdgames-darwin-4b57f3f1a523d33412704f3a5180f921002809b1.tar.gz
bsdgames-darwin-4b57f3f1a523d33412704f3a5180f921002809b1.tar.zst
bsdgames-darwin-4b57f3f1a523d33412704f3a5180f921002809b1.zip
In cypher(), don't attempt to make sense of words other than VERBs or
KNIFE when a verb is required. Add AUXVERB for "make", "move", "climb" (as in "make love", "climb up") and ignore AUXVERB as a verb, going on to the next word, instead of treating these words as adjectives. When creating new verbs from "put on", "put down", "take off", mark them as type VERB. Mostly from Paul Janzen <pjanzen@foatdi.harvard.edu>.
Diffstat (limited to 'battlestar')
-rw-r--r--battlestar/com2.c6
-rw-r--r--battlestar/com4.c5
-rw-r--r--battlestar/cypher.c19
-rw-r--r--battlestar/extern.h3
-rw-r--r--battlestar/words.c10
5 files changed, 31 insertions, 12 deletions
diff --git a/battlestar/com2.c b/battlestar/com2.c
index ce8b21a7..69334568 100644
--- a/battlestar/com2.c
+++ b/battlestar/com2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com2.c,v 1.20 2000/09/25 14:08:08 jsm Exp $ */
+/* $NetBSD: com2.c,v 1.21 2000/09/25 19:37:58 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.20 2000/09/25 14:08:08 jsm Exp $");
+__RCSID("$NetBSD: com2.c,v 1.21 2000/09/25 19:37:58 jsm Exp $");
#endif
#endif /* not lint */
@@ -117,10 +117,12 @@ put()
{ /* synonyms = {buckle, strap, tie} */
if (wordvalue[wordnumber + 1] == ON) {
wordvalue[++wordnumber] = PUTON;
+ wordtype[wordnumber] = VERB;
return (cypher());
}
if (wordvalue[wordnumber + 1] == DOWN) {
wordvalue[++wordnumber] = DROP;
+ wordtype[wordnumber] = VERB;
return (cypher());
}
puts("I don't understand what you want to put.");
diff --git a/battlestar/com4.c b/battlestar/com4.c
index 467e2906..537fa065 100644
--- a/battlestar/com4.c
+++ b/battlestar/com4.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com4.c,v 1.18 2000/09/25 14:08:08 jsm Exp $ */
+/* $NetBSD: com4.c,v 1.19 2000/09/25 19:37:58 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.18 2000/09/25 14:08:08 jsm Exp $");
+__RCSID("$NetBSD: com4.c,v 1.19 2000/09/25 19:37:58 jsm Exp $");
#endif
#endif /* not lint */
@@ -54,6 +54,7 @@ take(from)
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == OFF) {
wordnumber++;
wordvalue[wordnumber] = TAKEOFF;
+ wordtype[wordnumber] = VERB;
return (cypher());
} else {
wordnumber++;
diff --git a/battlestar/cypher.c b/battlestar/cypher.c
index a0642aec..caf4139d 100644
--- a/battlestar/cypher.c
+++ b/battlestar/cypher.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cypher.c,v 1.20 2000/09/25 14:06:20 jsm Exp $ */
+/* $NetBSD: cypher.c,v 1.21 2000/09/25 19:37:58 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: cypher.c,v 1.20 2000/09/25 14:06:20 jsm Exp $");
+__RCSID("$NetBSD: cypher.c,v 1.21 2000/09/25 19:37:58 jsm Exp $");
#endif
#endif /* not lint */
@@ -55,8 +55,23 @@ 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)
diff --git a/battlestar/extern.h b/battlestar/extern.h
index edc3c2cf..ef8e3910 100644
--- a/battlestar/extern.h
+++ b/battlestar/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.27 2000/09/25 14:44:59 jsm Exp $ */
+/* $NetBSD: extern.h,v 1.28 2000/09/25 19:37:59 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -190,6 +190,7 @@
#define OPEN 1053
#define VERBOSE 1054
#define BRIEF 1055
+#define AUXVERB 1056
/* injuries */
#define ARM 6 /* broken arm */
diff --git a/battlestar/words.c b/battlestar/words.c
index 86365a87..6bcc5414 100644
--- a/battlestar/words.c
+++ b/battlestar/words.c
@@ -1,4 +1,4 @@
-/* $NetBSD: words.c,v 1.9 2000/09/21 17:44:34 jsm Exp $ */
+/* $NetBSD: words.c,v 1.10 2000/09/25 19:37:59 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: words.c,v 1.9 2000/09/21 17:44:34 jsm Exp $");
+__RCSID("$NetBSD: words.c,v 1.10 2000/09/25 19:37:59 jsm Exp $");
#endif
#endif /* not lint */
@@ -212,9 +212,9 @@ struct wlist wlist[] = {
{ "purple", 0, ADJS, NULL },
{ "kingly", 0, ADJS, NULL },
{ "the", 0, ADJS, NULL },
- { "climb", 0, ADJS, NULL },
- { "move", 0, ADJS, NULL },
- { "make", 0, ADJS, NULL },
+ { "climb", AUXVERB, VERB, NULL },
+ { "move", AUXVERB, VERB, NULL },
+ { "make", AUXVERB, VERB, NULL },
{ "to", 0, ADJS, NULL },
{ NULL, 0, 0, NULL }
};