Undid unspeaking of wave, fixed test again.
authorNHOrus <jy6x2b32pie9@yahoo.com>
Sun, 2 Jul 2017 21:47:17 +0000 (00:47 +0300)
committerNHOrus <jy6x2b32pie9@yahoo.com>
Sun, 2 Jul 2017 21:47:17 +0000 (00:47 +0300)
Changed property math to helper function.

actions.c
tests/weirdbird.chk
tests/weirdbird.log

index 51ad0ef5d432d9d020c6279df161179e9f32e775..d9802f627143051a568c6b42302401cdbf87921e 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -1086,45 +1086,51 @@ static int wake(token_t verb, token_t obj)
     }
 }
 
+static token_t birdspeak(void)
+{
+    switch (game.prop[BIRD]) {
+    case BIRD_UNCAGED:
+    case BIRD_FOREST_UNCAGED:
+        return FREE_FLY;
+    case BIRD_CAGED:
+        return CAGE_FLY;
+    }
+}
+
 static int wave(token_t verb, token_t obj)
 /* Wave.  No effect unless waving rod at fissure or at bird. */
 {
-    if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) {
-        rspeak(ARENT_CARRYING);
-        return GO_CLEAROBJ;
-    }
+    int spk = actions[verb].message;
+    if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2)))
+        spk = ARENT_CARRYING;
     if (obj != ROD ||
         !TOTING(obj) ||
         (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) {
-        rspeak(actions[verb].message);
+        rspeak(spk);
         return GO_CLEAROBJ;
     }
-    if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
+
+    if (HERE(BIRD))
+        spk = birdspeak();
+    if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
         drop(JADE, game.loc);
         game.prop[JADE] = 0;
         --game.tally;
-        rspeak(NECKLACE_FLY);
+        spk = NECKLACE_FLY;
+        rspeak(spk);
         return GO_CLEAROBJ;
     } else {
         if (game.closed) {
-            rspeak(actions[verb].message);
+            rspeak(spk);
             return GO_DWARFWAKE;
         }
         if (game.closng || !AT(FISSURE)) {
-            rspeak(actions[verb].message);
+            rspeak(spk);
             return GO_CLEAROBJ;
         }
-        if (HERE(BIRD)) {
-            switch (game.prop[BIRD]) {
-            case BIRD_UNCAGED:
-            case BIRD_FOREST_UNCAGED:
-                rspeak(FREE_FLY);
-                break;
-            case BIRD_CAGED:
-                rspeak(CAGE_FLY);
-                break;
-            }
-        }
+        if (HERE(BIRD))
+            rspeak(spk);
+
         /* FIXME: Arithemetic on property values */
         game.prop[FISSURE] = 1 - game.prop[FISSURE];
         pspeak(FISSURE, look, 2 - game.prop[FISSURE], true);
@@ -1132,6 +1138,8 @@ static int wave(token_t verb, token_t obj)
     }
 }
 
+
+
 int action(struct command_t *command)
 /*  Analyse a verb.  Remember what it was, go back for object if second word
  *  unless verb is "say", which snarfs arbitrary second word.
index ce4c8b8bef5b54d79084e05f9d780c6b6afb4b43..38cfa49b5a58e70e3ff85fede3b7ca0f34861669 100644 (file)
@@ -179,12 +179,20 @@ OK
 
 OK
 
+> get rod
+
+OK
+
+> wave rod
+
+The bird flies agitatedly about the cage.
+
 > attack bird
 
 The little bird is now dead.  Its body disappears.
 
 
-You scored 30 out of a possible 430, using 30 turns.
+You scored 30 out of a possible 430, using 32 turns.
 
 You are obviously a rank amateur.  Better luck next time.
 
index 8e03ef8254dc9f5cf7e42437ae37e4f3603ce64b..bb8a4913fe1615aa447b46ae53f23576d4c1f288 100644 (file)
@@ -33,4 +33,6 @@ y
 y
 drop rod
 take bird
+get rod
+wave rod
 attack bird