From 5c2b76f762552228e43d4ab5b91be2dae0286898 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 1 Jul 2017 22:50:08 -0400 Subject: [PATCH] Magic-number elimination. --- actions.c | 18 +++++++++--------- adventure.yaml | 7 ++++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/actions.c b/actions.c index 33c445c..b236cbf 100644 --- 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) { diff --git a/adventure.yaml b/adventure.yaml index c529b98..60a148d 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -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' -- 2.31.1