Improve test coverage, simplify code.

This commit is contained in:
Eric S. Raymond 2017-06-18 06:41:16 -04:00
parent b3057f038b
commit ff7db8b0c8
6 changed files with 21 additions and 17 deletions

View file

@ -925,19 +925,13 @@ static int throw (FILE *cmdin, long verb, token_t obj)
return (discard(verb, obj, false)); return (discard(verb, obj, false));
int i = ATDWRF(game.loc); int i = ATDWRF(game.loc);
if (i <= 0) { if (i <= 0) {
if (AT(DRAGON) && game.prop[DRAGON] == 0) { if (AT(DRAGON) && game.prop[DRAGON] == 0)
spk = DRAGON_SCALES; return throw_support(DRAGON_SCALES);
return throw_support(spk); if (AT(TROLL))
} return throw_support(TROLL_RETURNS);
if (AT(TROLL)) { else if (AT(OGRE))
spk = TROLL_RETURNS; return throw_support(OGRE_DODGE);
return throw_support(spk); else if (HERE(BEAR) && game.prop[BEAR] == 0) {
}
if (AT(OGRE)) {
spk = OGRE_DODGE;
return throw_support(spk);
}
if (HERE(BEAR) && game.prop[BEAR] == 0) {
/* This'll teach him to throw the axe at the bear! */ /* This'll teach him to throw the axe at the bear! */
DROP(AXE, game.loc); DROP(AXE, game.loc);
game.fixed[AXE] = -1; game.fixed[AXE] = -1;

View file

@ -1,4 +1,4 @@
## Speak a magic word artan inopportune time and drown. ## Speak a magic word at an inopportune time and drown.
# Based on walkthrough at http://www.ecsoftwareconsulting.com/node/56 # Based on walkthrough at http://www.ecsoftwareconsulting.com/node/56
n n
seed 1838473132 seed 1838473132

View file

@ -61,6 +61,10 @@ Eat what?
You have taken a drink from the stream. The water tastes strongly of You have taken a drink from the stream. The water tastes strongly of
minerals, but is not unpleasant. It is extremely cold. minerals, but is not unpleasant. It is extremely cold.
> throw keys
I see no keys here.
> find keys > find keys
I can only tell you what you see as you move about and manipulate I can only tell you what you see as you move about and manipulate
@ -308,7 +312,7 @@ Okay, "BOO".
> score > score
You have garnered 27 out of a possible 430 points, using 58 turns. You have garnered 27 out of a possible 430 points, using 59 turns.
> quit bottle > quit bottle
@ -322,7 +326,7 @@ Do you really want to quit now?
OK OK
You scored 27 out of a possible 430, using 60 turns. You scored 27 out of a possible 430, using 61 turns.
You are obviously a rank amateur. Better luck next time. You are obviously a rank amateur. Better luck next time.

View file

@ -8,6 +8,7 @@ listen
forward forward
eat eat
drink drink
throw keys
find keys find keys
inven keys inven keys
nothing nothing

View file

@ -280,8 +280,12 @@ There are fresh batteries here.
OK OK
> throw batteries
You scored 75 out of a possible 430, using 49 turns. OK
You scored 75 out of a possible 430, using 50 turns.
Your score qualifies you as a novice class adventurer. Your score qualifies you as a novice class adventurer.

View file

@ -51,3 +51,4 @@ se
s s
drop coins drop coins
take batteries take batteries
throw batteries