From ff7db8b0c8d61c332cfde95530e8ebb2bb1a0c58 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 18 Jun 2017 06:41:16 -0400 Subject: [PATCH] Improve test coverage, simplify code. --- actions.c | 20 +++++++------------- tests/drown.log | 2 +- tests/illformed.chk | 8 ++++++-- tests/illformed.log | 1 + tests/vending.chk | 6 +++++- tests/vending.log | 1 + 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/actions.c b/actions.c index 58d808b..59f9942 100644 --- a/actions.c +++ b/actions.c @@ -925,19 +925,13 @@ static int throw (FILE *cmdin, long verb, token_t obj) return (discard(verb, obj, false)); int i = ATDWRF(game.loc); if (i <= 0) { - if (AT(DRAGON) && game.prop[DRAGON] == 0) { - spk = DRAGON_SCALES; - return throw_support(spk); - } - if (AT(TROLL)) { - spk = TROLL_RETURNS; - return throw_support(spk); - } - if (AT(OGRE)) { - spk = OGRE_DODGE; - return throw_support(spk); - } - if (HERE(BEAR) && game.prop[BEAR] == 0) { + if (AT(DRAGON) && game.prop[DRAGON] == 0) + return throw_support(DRAGON_SCALES); + if (AT(TROLL)) + return throw_support(TROLL_RETURNS); + else if (AT(OGRE)) + return throw_support(OGRE_DODGE); + else if (HERE(BEAR) && game.prop[BEAR] == 0) { /* This'll teach him to throw the axe at the bear! */ DROP(AXE, game.loc); game.fixed[AXE] = -1; diff --git a/tests/drown.log b/tests/drown.log index 7e417be..784c102 100644 --- a/tests/drown.log +++ b/tests/drown.log @@ -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 n seed 1838473132 diff --git a/tests/illformed.chk b/tests/illformed.chk index 52ff492..5459984 100644 --- a/tests/illformed.chk +++ b/tests/illformed.chk @@ -61,6 +61,10 @@ Eat what? You have taken a drink from the stream. The water tastes strongly of minerals, but is not unpleasant. It is extremely cold. +> throw keys + +I see no keys here. + > find keys I can only tell you what you see as you move about and manipulate @@ -308,7 +312,7 @@ Okay, "BOO". > 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 @@ -322,7 +326,7 @@ Do you really want to quit now? 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. diff --git a/tests/illformed.log b/tests/illformed.log index 11ab726..af281b2 100644 --- a/tests/illformed.log +++ b/tests/illformed.log @@ -8,6 +8,7 @@ listen forward eat drink +throw keys find keys inven keys nothing diff --git a/tests/vending.chk b/tests/vending.chk index 5404e94..b74c081 100644 --- a/tests/vending.chk +++ b/tests/vending.chk @@ -280,8 +280,12 @@ There are fresh batteries here. 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. diff --git a/tests/vending.log b/tests/vending.log index 528f370..a92dcf2 100644 --- a/tests/vending.log +++ b/tests/vending.log @@ -51,3 +51,4 @@ se s drop coins take batteries +throw batteries -- 2.31.1