Magic-number elimination.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 2 Jul 2017 02:50:08 +0000 (22:50 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 2 Jul 2017 02:50:08 +0000 (22:50 -0400)
actions.c
adventure.yaml

index 33c445cc0c13f7cfd92d33c717257b68bb60ee0f..b236cbf13b11e5b3accdd7b8b4f1dd21750515bb 100644 (file)
--- a/actions.c
+++ b/actions.c
@@ -123,7 +123,7 @@ static int attack(struct command_t *command)
         }
         state_change(DRAGON, DRAGON_DEAD);
         game.prop[RUG] = RUG_FLOOR;
-        /* FIXME: Arithmentic on location values */
+        /* FIXME: Arithmetic on location values */
         int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
         move(DRAGON + NOBJECTS, -1);
         move(RUG + NOBJECTS, 0);
@@ -172,11 +172,11 @@ static int bigwords(token_t foo)
              *  crossing. */
             if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID)
                 game.prop[TROLL] = TROLL_PAIDONCE;
-            k = 2;
+            k = EGGS_DONE;
             if (HERE(EGGS))
-                k = 1;
+                k = EGGS_VANISHED;
             if (game.loc == objects[EGGS].plac)
-                k = 0;
+                k = EGGS_HERE;
             move(EGGS, objects[EGGS].plac);
             pspeak(EGGS, look, k);
             return GO_CLEAROBJ;
@@ -444,15 +444,15 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
             move(TROLL2, objects[TROLL].plac);
             move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
             juggle(CHASM);
-            game.prop[TROLL] = 2;
+            game.prop[TROLL] = TROLL_GONE;
         } else if (obj != VASE || game.loc == objects[PILLOW].plac) {
             rspeak(OK_MAN);
         } else {
-            game.prop[VASE] = 2;
+            game.prop[VASE] = VASE_BROKEN;
             if (AT(PILLOW))
-                game.prop[VASE] = 0;
+                game.prop[VASE] = VASE_WHOLE;
             pspeak(VASE, look, game.prop[VASE] + 1);
-            if (game.prop[VASE] != 0)
+            if (game.prop[VASE] != VASE_WHOLE)
                 game.fixed[VASE] = -1;
         }
     }
@@ -605,7 +605,7 @@ int fill(token_t verb, token_t obj)
             return GO_CLEAROBJ;
         }
         rspeak(SHATTER_VASE);
-        game.prop[VASE] = 2;
+        game.prop[VASE] = VASE_BROKEN;
         game.fixed[VASE] = -1;
         return (discard(verb, obj, true));
     } else if (obj == URN) {
index c529b9806cc055821869b67ca4a9ce64ac2db286..60a148de79b1c5458ec0e686310c367896c68b03 100644 (file)
@@ -3330,6 +3330,7 @@ objects: !!omap
     - [TROLL_GONE, ''] # chased away
     sounds:
     - 'The troll sounds quite adamant in his demand for a treasure.'
+    - 'The troll sounds quite adamant in his demand for a treasure.'
 - TROLL2:
     words: ['troll']
     inventory: '*phony troll'
@@ -3514,9 +3515,9 @@ objects: !!omap
     locations: LOC_GIANTROOM
     treasure: true
     descriptions:
-    - 'There is a large nest here, full of golden eggs!'
-    - 'The nest of golden eggs has vanished!'
-    - 'Done!'
+    - [EGGS_HERE, 'There is a large nest here, full of golden eggs!']
+    - [EGGS_VANISHED, 'The nest of golden eggs has vanished!']
+    - [EGGS_DONE, 'Done!']
 - TRIDENT:
     words: ['tride']
     inventory: 'Jeweled trident'