Simplify code, improve test coverage.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 18 Jun 2017 12:57:08 +0000 (08:57 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 18 Jun 2017 12:57:08 +0000 (08:57 -0400)
actions.c
tests/illformed.chk
tests/illformed.log
tests/weirdbird.chk
tests/weirdbird.log

index 70d5acd127db9945dcae2ec010605085b04cd420..49988ecec4bc9f02e5cf58aeb5d8b843d0c8d9f3 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -21,9 +21,8 @@ static int attack(FILE *input, long verb, token_t obj)
  *  enemies, or no enemies but 2 others. */
 {
     int spk = ACTSPK[verb];
  *  enemies, or no enemies but 2 others. */
 {
     int spk = ACTSPK[verb];
-    int d = ATDWRF(game.loc);
-    if (obj == 0) {
-        if (d > 0)
+    if (obj == 0 || obj == INTRANSITIVE) {
+        if (ATDWRF(game.loc) > 0)
             obj = DWARF;
         if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE;
         if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON;
             obj = DWARF;
         if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE;
         if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON;
@@ -65,7 +64,7 @@ static int attack(FILE *input, long verb, token_t obj)
     if (obj == DRAGON)spk = ALREADY_DEAD;
     if (obj == TROLL)spk = ROCKY_TROLL;
     if (obj == OGRE)spk = OGRE_DODGE;
     if (obj == DRAGON)spk = ALREADY_DEAD;
     if (obj == TROLL)spk = ROCKY_TROLL;
     if (obj == OGRE)spk = OGRE_DODGE;
-    if (obj == OGRE && d > 0) {
+    if (obj == OGRE && ATDWRF(game.loc) > 0) {
         RSPEAK(spk);
         RSPEAK(KNIFE_THROWN);
         DESTROY(OGRE);
         RSPEAK(spk);
         RSPEAK(KNIFE_THROWN);
         DESTROY(OGRE);
index aa4e77ad2e0dfc5a5cd4902d394d3cecee568cc0..79b6cd74db05ee511235244da5d95a9be48ab06c 100644 (file)
@@ -31,17 +31,30 @@ Seed set to 1801426495
 
 You're in front of building.
 
 
 You're in front of building.
 
+> stream
+
+You are in a valley in the forest beside a stream tumbling along a
+rocky bed.
+
+> take water
+
+You have nothing in which to carry it.
+
 > cave
 
 I don't know where the cave is, but hereabouts no stream can run on
 the surface for long.  I would try the stream.
 
 > cave
 
 I don't know where the cave is, but hereabouts no stream can run on
 the surface for long.  I would try the stream.
 
-You're in front of building.
+You're in valley.
 
 > enter stream
 
 Your feet are now wet.
 
 
 > enter stream
 
 Your feet are now wet.
 
+> try three words
+
+Please stick to 1- and 2-word commands.
+
 > listen
 
 The stream is gurgling placidly.
 > listen
 
 The stream is gurgling placidly.
@@ -54,7 +67,7 @@ Carry what?
 
 I am unsure how you are facing.  Use compass points or nearby objects.
 
 
 I am unsure how you are facing.  Use compass points or nearby objects.
 
-You're in front of building.
+You're in valley.
 
 > eat
 
 
 > eat
 
@@ -85,15 +98,10 @@ OK
 
 > in
 
 
 > in
 
-You are inside a building, a well house for a large spring.
-
-There are some keys on the ground here.
+I don't know in from out here.  Use compass points or name something
+in the general direction you want to go.
 
 
-There is a shiny brass lamp nearby.
-
-There is food here.
-
-There is a bottle of water here.
+You're in valley.
 
 > listen
 
 
 > listen
 
@@ -101,15 +109,16 @@ The stream is gurgling placidly.
 
 > keys
 
 
 > keys
 
-What do you want to do with the keys?
+I see no keys here.
 
 > find keys
 
 
 > find keys
 
-I believe what you want is right here with you.
+I can only tell you what you see as you move about and manipulate
+things.  I cannot tell you where remote things are.
 
 > unlock keys
 
 
 > unlock keys
 
-You can't unlock the keys.
+I see no keys here.
 
 > find foo
 
 
 > find foo
 
@@ -129,11 +138,12 @@ Blasting requires dynamite.
 
 > take bottle
 
 
 > take bottle
 
-OK
+I see no bottl here.
 
 > drink water
 
 
 > drink water
 
-The bottle of water is now empty.
+You have taken a drink from the stream.  The water tastes strongly of
+minerals, but is not unpleasant.  It is extremely cold.
 
 > throw axe
 
 
 > throw axe
 
@@ -169,47 +179,47 @@ I see no urn here.
 
 > eat keys
 
 
 > eat keys
 
-Don't be ridiculous!
+I see no keys here.
 
 > discard keys
 
 
 > discard keys
 
-You aren't carrying it!
+I see no keys here.
 
 > drink keys
 
 
 > drink keys
 
-Don't be ridiculous!
+I see no keys here.
 
 > off keys
 
 
 > off keys
 
-I'm afraid I don't understand.
+I see no keys here.
 
 > break keys
 
 
 > break keys
 
-It is beyond your power to do that.
+I see no keys here.
 
 > wake keys
 
 
 > wake keys
 
-Don't be ridiculous!
+I see no keys here.
 
 > take keys
 
 
 > take keys
 
-OK
+I see no keys here.
 
 > feed keys
 
 
 > feed keys
 
-I'm game.  Would you care to explain how?
+I see no keys here.
 
 > fly keys
 
 
 > fly keys
 
-I'm game.  Would you care to explain how?
+I see no keys here.
 
 > throw keys
 
 
 > throw keys
 
-OK
+I see no keys here.
 
 > eat food
 
 
 > eat food
 
-Thank you, it was delicious!
+I see no food here.
 
 > drink blood
 
 
 > drink blood
 
@@ -217,11 +227,11 @@ I see no blood here.
 
 > drink keys
 
 
 > drink keys
 
-Don't be ridiculous!
+I see no keys here.
 
 > light keys
 
 
 > light keys
 
-I'm afraid I don't understand.
+I see no keys here.
 
 > brief
 
 
 > brief
 
@@ -234,43 +244,37 @@ Sorry, I don't know the word "FROB".
 
 > read grate
 
 
 > read grate
 
-I'm afraid I don't understand.
+You're in valley.
 
 > grate
 
 
 > grate
 
-What do you want to do with the grate?
+You're in valley.
 
 > building
 
 
 > building
 
-I don't know how to apply that word here.
-
-You're inside building.
-
-There are some keys on the ground here.
-
-There is a shiny brass lamp nearby.
+You're in front of building.
 
 > on
 
 
 > on
 
-Your lamp is now on.
+On what?
 
 > xyzzy
 
 
 > xyzzy
 
->>Foof!<<
+Nothing happens.
 
 
-It is now pitch dark.  If you proceed you will likely fall into a pit.
+You're in front of building.
 
 > take rod
 
 
 > take rod
 
-OK
+I see no rod here.
 
 > wave rod
 
 
 > wave rod
 
-Nothing happens.
+I see no rod here.
 
 > listen
 
 
 > listen
 
-All is silent.
+The stream is gurgling placidly.
 
 > quit
 
 
 > quit
 
@@ -286,7 +290,9 @@ Read what?
 
 > look
 
 
 > look
 
-It is now pitch dark.  If you proceed you will likely fall into a pit.
+You are standing at the end of a road before a small brick building.
+Around you is a forest.  A small stream flows out of the building and
+down a gully.
 
 > news
 
 
 > news
 
@@ -302,13 +308,9 @@ game.  Saved games are now stored in much smaller files than before.
 
 > go back
 
 
 > go back
 
->>Foof!<<
-
-You're inside building.
+Sorry, but I no longer seem to remember how it was you got here.
 
 
-There are some keys on the ground here.
-
-There is a lamp shining nearby.
+You're in front of building.
 
 > fuck
 
 
 > fuck
 
@@ -328,11 +330,11 @@ Okay, "BOO".
 
 > score
 
 
 > score
 
-You have garnered 27 out of a possible 430 points, using 64 turns.
+You have garnered 27 out of a possible 430 points, using 66 turns.
 
 > quit keys
 
 
 > quit keys
 
-Huh?
+I see no keys here.
 
 > quit
 
 
 > quit
 
@@ -342,7 +344,7 @@ Do you really want to quit now?
 
 OK
 
 
 OK
 
-You scored 27 out of a possible 430, using 66 turns.
+You scored 27 out of a possible 430, using 68 turns.
 
 You are obviously a rank amateur.  Better luck next time.
 
 
 You are obviously a rank amateur.  Better luck next time.
 
index 102ecda3b04755436dd14fc127c6fead770104cc..8f1591e81ddc7e18f28ac705c809aeaeb5d09a08 100644 (file)
@@ -2,8 +2,11 @@
 foo
 y
 seed 1801426495
 foo
 y
 seed 1801426495
+stream
+take water
 cave
 enter stream
 cave
 enter stream
+try three words
 listen
 carry
 forward
 listen
 carry
 forward
index b2b74d8d26d2f8835c572b8d1ee15b030b52b28b..3f7e44608449c259e1284974688c6127303d472d 100644 (file)
@@ -140,12 +140,16 @@ I think I just lost my appetite.
 It's not hungry (it's merely pinin' for the fjords).  Besides, you
 have no bird seed.
 
 It's not hungry (it's merely pinin' for the fjords).  Besides, you
 have no bird seed.
 
+> take bird
+
+OK
+
 > attack bird
 
 The little bird is now dead.  Its body disappears.
 
 
 > attack bird
 
 The little bird is now dead.  Its body disappears.
 
 
-You scored 32 out of a possible 430, using 25 turns.
+You scored 32 out of a possible 430, using 26 turns.
 
 You are obviously a rank amateur.  Better luck next time.
 
 
 You are obviously a rank amateur.  Better luck next time.
 
index 168067d8824b78b4d943e18b41212a0c75f55b01..fe9f9677359aaead37ed2b89fa3698d8251e9001 100644 (file)
@@ -25,4 +25,5 @@ w
 listen bird
 eat bird
 feed bird
 listen bird
 eat bird
 feed bird
+take bird
 attack bird
 attack bird