Magic-number elimination for dragon and rug.

This commit is contained in:
Eric S. Raymond 2017-07-01 09:58:45 -04:00
parent 45820bc8cd
commit f47f3a4603
2 changed files with 26 additions and 21 deletions

View file

@ -121,9 +121,9 @@ static int attack(struct command_t *command)
command->wd1 = token_to_packed("N"); command->wd1 = token_to_packed("N");
return GO_CHECKFOO; return GO_CHECKFOO;
} }
pspeak(DRAGON, look, 3); state_change(DRAGON, DRAGON_DEAD);
game.prop[DRAGON] = 1; game.prop[RUG] = RUG_FLOOR;
game.prop[RUG] = 0; /* FIXME: Arithmentic on location values */
int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2; int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
move(DRAGON + NOBJECTS, -1); move(DRAGON + NOBJECTS, -1);
move(RUG + NOBJECTS, 0); move(RUG + NOBJECTS, 0);
@ -284,7 +284,7 @@ static int vcarry(token_t verb, token_t obj)
spk = DOUGHNUT_HOLES; spk = DOUGHNUT_HOLES;
if (obj == BLOOD) if (obj == BLOOD)
spk = FEW_DROPS; spk = FEW_DROPS;
if (obj == RUG && game.prop[RUG] == 2) if (obj == RUG && game.prop[RUG] == RUG_HOVER)
spk = RUG_HOVERS; spk = RUG_HOVERS;
if (obj == SIGN) if (obj == SIGN)
spk = HAND_PASSTHROUGH; spk = HAND_PASSTHROUGH;
@ -410,8 +410,8 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
rspeak(GEM_FITS); rspeak(GEM_FITS);
game.prop[obj] = 1; game.prop[obj] = 1;
game.prop[CAVITY] = CAVITY_FULL; game.prop[CAVITY] = CAVITY_FULL;
if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != 2) || (obj == RUBY && if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY &&
game.prop[RUG] == 2))) { game.prop[RUG] == RUG_HOVER))) {
spk = RUG_RISES; spk = RUG_RISES;
if (TOTING(RUG)) if (TOTING(RUG))
spk = RUG_WIGGLES; spk = RUG_WIGGLES;
@ -419,6 +419,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
spk = RUG_SETTLES; spk = RUG_SETTLES;
rspeak(spk); rspeak(spk);
if (spk != RUG_WIGGLES) { if (spk != RUG_WIGGLES) {
/* FIXME: Arithmetic on state numbers */
int k = 2 - game.prop[RUG]; int k = 2 - game.prop[RUG];
game.prop[RUG] = k; game.prop[RUG] = k;
if (k == 2) if (k == 2)
@ -485,13 +486,12 @@ static int drink(token_t verb, token_t obj)
game.place[WATER] = LOC_NOWHERE; game.place[WATER] = LOC_NOWHERE;
spk = BOTTLE_EMPTY; spk = BOTTLE_EMPTY;
} }
rspeak(spk);
} else { } else {
DESTROY(BLOOD); DESTROY(BLOOD);
game.prop[DRAGON] = 2; state_change(DRAGON, DRAGON_BLOODLESS);
game.blooded = true; game.blooded = true;
spk = HEAD_BUZZES;
} }
rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -673,7 +673,7 @@ static int fly(token_t verb, token_t obj)
{ {
int spk = actions[verb].message; int spk = actions[verb].message;
if (obj == INTRANSITIVE) { if (obj == INTRANSITIVE) {
if (game.prop[RUG] != 2) if (game.prop[RUG] != RUG_HOVER)
spk = RUG_NOTHING2; spk = RUG_NOTHING2;
if (!HERE(RUG)) if (!HERE(RUG))
spk = FLAP_ARMS; spk = FLAP_ARMS;
@ -689,12 +689,13 @@ static int fly(token_t verb, token_t obj)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
spk = RUG_NOTHING1; spk = RUG_NOTHING1;
if (game.prop[RUG] != 2) { if (game.prop[RUG] != RUG_HOVER) {
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.oldlc2 = game.oldloc; game.oldlc2 = game.oldloc;
game.oldloc = game.loc; game.oldloc = game.loc;
/* FIXME: Arithmetic on location values */
game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc; game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc;
spk = RUG_GOES; spk = RUG_GOES;
if (game.prop[SAPPH] >= 0) if (game.prop[SAPPH] >= 0)

View file

@ -1425,7 +1425,7 @@ locations: !!omap
conditions: {DEEP: true} conditions: {DEEP: true}
travel: [ travel: [
{verbs: ['D', 'SLAB'], action: [goto, LOC_SLAB]}, {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]}, action: [goto, LOC_SECRET5]},
{verbs: ['SOUTH'], action: [goto, LOC_SECRET4]}, {verbs: ['SOUTH'], action: [goto, LOC_SECRET4]},
{verbs: ['NORTH'], action: [goto, LOC_MIRRORCANYON]}, {verbs: ['NORTH'], action: [goto, LOC_MIRRORCANYON]},
@ -1483,7 +1483,7 @@ locations: !!omap
conditions: {DEEP: true} conditions: {DEEP: true}
travel: [ travel: [
{verbs: ['EAST'], action: [goto, LOC_KINGHALL]}, {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: ['WEST'], action: [goto, LOC_SECRET6]},
{verbs: ['D'], action: [goto, LOC_WIDEPLACE]}, {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.' - 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.' - 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.' - 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.)' - NOT_BRIGHT: '(Uh, y''know, that wasn''t very bright.)'
- TOOK_LONG: 'It''s a pity you took so long about it.' - TOOK_LONG: 'It''s a pity you took so long about it.'
- UPSTREAM_DOWNSTREAM: 'Upstream or downstream?' - UPSTREAM_DOWNSTREAM: 'Upstream or downstream?'
@ -3443,10 +3442,15 @@ objects: !!omap
locations: [LOC_SECRET4, LOC_SECRET6] locations: [LOC_SECRET4, LOC_SECRET6]
immovable: true immovable: true
descriptions: descriptions:
- [DRAGON_BLOCKS, 'A huge green fierce dragon bars the way!'] - [DRAGON_BARS, 'A huge green fierce dragon bars the way!']
- 'The blood-specked body of a huge green dead dragon lies to one side.' - [DRAGON_DEAD, '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.' - [DRAGON_BLOODLESS, '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?)' changes:
- ''
- |-
Congratulations! You have just vanquished a dragon with your bare
hands! (Unbelievable, isn't it?)
- 'Your head buzzes strangely for a moment.'
sounds: sounds:
- 'The dragon''s ominous hissing does not bode well for you.' - 'The dragon''s ominous hissing does not bode well for you.'
- 'The dragon is, not surprisingly, silent.' - 'The dragon is, not surprisingly, silent.'
@ -3703,9 +3707,9 @@ objects: !!omap
immovable: true immovable: true
treasure: true treasure: true
descriptions: descriptions:
- 'There is a persian rug spread out on the floor!' - [RUG_FLOOR, 'There is a persian rug spread out on the floor!']
- 'The dragon is sprawled out on a persian rug!!' - [RUG_DRAGON, 'The dragon is sprawled out on a persian rug!!']
- 'There is a persian rug here, hovering in mid-air!' - [RUG_HOVER, 'There is a persian rug here, hovering in mid-air!']
- OBJ_63: - OBJ_63:
words: ['spice'] words: ['spice']
inventory: 'Rare spices' inventory: 'Rare spices'