From: Eric S. Raymond Date: Sat, 1 Jul 2017 13:58:45 +0000 (-0400) Subject: Magic-number elimination for dragon and rug. X-Git-Tag: takebird~153 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;ds=sidebyside;h=f47f3a460338cd46faa2c2ee76762abdb1b36acb;p=open-adventure.git Magic-number elimination for dragon and rug. --- diff --git a/actions.c b/actions.c index e3768d9..567d67a 100644 --- a/actions.c +++ b/actions.c @@ -121,9 +121,9 @@ static int attack(struct command_t *command) command->wd1 = token_to_packed("N"); return GO_CHECKFOO; } - pspeak(DRAGON, look, 3); - game.prop[DRAGON] = 1; - game.prop[RUG] = 0; + state_change(DRAGON, DRAGON_DEAD); + game.prop[RUG] = RUG_FLOOR; + /* FIXME: Arithmentic on location values */ int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2; move(DRAGON + NOBJECTS, -1); move(RUG + NOBJECTS, 0); @@ -284,7 +284,7 @@ static int vcarry(token_t verb, token_t obj) spk = DOUGHNUT_HOLES; if (obj == BLOOD) spk = FEW_DROPS; - if (obj == RUG && game.prop[RUG] == 2) + if (obj == RUG && game.prop[RUG] == RUG_HOVER) spk = RUG_HOVERS; if (obj == SIGN) spk = HAND_PASSTHROUGH; @@ -410,8 +410,8 @@ static int discard(token_t verb, token_t obj, bool just_do_it) rspeak(GEM_FITS); game.prop[obj] = 1; game.prop[CAVITY] = CAVITY_FULL; - if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY && - game.prop[RUG] == 2))) { + if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY && + game.prop[RUG] == RUG_HOVER))) { spk = RUG_RISES; if (TOTING(RUG)) spk = RUG_WIGGLES; @@ -419,6 +419,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) spk = RUG_SETTLES; rspeak(spk); if (spk != RUG_WIGGLES) { + /* FIXME: Arithmetic on state numbers */ int k = 2 - game.prop[RUG]; game.prop[RUG] = k; if (k == 2) @@ -485,13 +486,12 @@ static int drink(token_t verb, token_t obj) game.place[WATER] = LOC_NOWHERE; spk = BOTTLE_EMPTY; } + rspeak(spk); } else { DESTROY(BLOOD); - game.prop[DRAGON] = 2; + state_change(DRAGON, DRAGON_BLOODLESS); game.blooded = true; - spk = HEAD_BUZZES; } - rspeak(spk); return GO_CLEAROBJ; } @@ -673,7 +673,7 @@ static int fly(token_t verb, token_t obj) { int spk = actions[verb].message; if (obj == INTRANSITIVE) { - if (game.prop[RUG] != 2) + if (game.prop[RUG] != RUG_HOVER) spk = RUG_NOTHING2; if (!HERE(RUG)) spk = FLAP_ARMS; @@ -689,12 +689,13 @@ static int fly(token_t verb, token_t obj) return GO_CLEAROBJ; } spk = RUG_NOTHING1; - if (game.prop[RUG] != 2) { + if (game.prop[RUG] != RUG_HOVER) { rspeak(spk); return GO_CLEAROBJ; } game.oldlc2 = game.oldloc; game.oldloc = game.loc; + /* FIXME: Arithmetic on location values */ game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc; spk = RUG_GOES; if (game.prop[SAPPH] >= 0) diff --git a/adventure.yaml b/adventure.yaml index ed482e2..943b78f 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -1425,7 +1425,7 @@ locations: !!omap conditions: {DEEP: true} travel: [ {verbs: ['D', 'SLAB'], action: [goto, LOC_SLAB]}, - {verbs: ['SOUTH'], cond: [not, DRAGON, DRAGON_BLOCKS], + {verbs: ['SOUTH'], cond: [not, DRAGON, DRAGON_BARS], action: [goto, LOC_SECRET5]}, {verbs: ['SOUTH'], action: [goto, LOC_SECRET4]}, {verbs: ['NORTH'], action: [goto, LOC_MIRRORCANYON]}, @@ -1483,7 +1483,7 @@ locations: !!omap conditions: {DEEP: true} travel: [ {verbs: ['EAST'], action: [goto, LOC_KINGHALL]}, - {verbs: ['WEST'], cond: [not, DRAGON, DRAGON_BLOCKS], action: [goto, LOC_SECRET5]}, + {verbs: ['WEST'], cond: [not, DRAGON, DRAGON_BARS], action: [goto, LOC_SECRET5]}, {verbs: ['WEST'], action: [goto, LOC_SECRET6]}, {verbs: ['D'], action: [goto, LOC_WIDEPLACE]}, ] @@ -3125,7 +3125,6 @@ arbitrary_messages: !!omap - TOTAL_ROAR: 'The roaring is so loud that it drowns out all other sound.' - BIRD_CRAP: 'The bird eyes you suspiciously and flutters away. A moment later you\nfeel something wet land on your head, but upon looking up you can see\nno sign of the culprit.' - FEW_DROPS: 'There are only a few drops--not enough to carry.' -- HEAD_BUZZES: 'Your head buzzes strangely for a moment.' - NOT_BRIGHT: '(Uh, y''know, that wasn''t very bright.)' - TOOK_LONG: 'It''s a pity you took so long about it.' - UPSTREAM_DOWNSTREAM: 'Upstream or downstream?' @@ -3443,10 +3442,15 @@ objects: !!omap locations: [LOC_SECRET4, LOC_SECRET6] immovable: true descriptions: - - [DRAGON_BLOCKS, 'A huge green fierce dragon bars the way!'] - - 'The blood-specked body of a huge green dead dragon lies to one side.' - - 'The body of a huge green dead dragon is lying off to one side.' - - 'Congratulations! You have just vanquished a dragon with your bare\nhands! (Unbelievable, isn''t it?)' + - [DRAGON_BARS, 'A huge green fierce dragon bars the way!'] + - [DRAGON_DEAD, 'The blood-specked body of a huge green dead dragon lies to one side.'] + - [DRAGON_BLOODLESS, 'The body of a huge green dead dragon is lying off to one side.'] + changes: + - '' + - |- + Congratulations! You have just vanquished a dragon with your bare + hands! (Unbelievable, isn't it?) + - 'Your head buzzes strangely for a moment.' sounds: - 'The dragon''s ominous hissing does not bode well for you.' - 'The dragon is, not surprisingly, silent.' @@ -3703,9 +3707,9 @@ objects: !!omap immovable: true treasure: true descriptions: - - 'There is a persian rug spread out on the floor!' - - 'The dragon is sprawled out on a persian rug!!' - - 'There is a persian rug here, hovering in mid-air!' + - [RUG_FLOOR, 'There is a persian rug spread out on the floor!'] + - [RUG_DRAGON, 'The dragon is sprawled out on a persian rug!!'] + - [RUG_HOVER, 'There is a persian rug here, hovering in mid-air!'] - OBJ_63: words: ['spice'] inventory: 'Rare spices'