From e46cbdf194bf086ea4d4b091746cb81dd469a443 Mon Sep 17 00:00:00 2001 From: NHOrus Date: Tue, 4 Jul 2017 19:27:00 +0300 Subject: [PATCH] Unspk'd (v)carry. Made logic more visible. And tested some of newly exposed cases. --- actions.c | 75 ++++++++++++++++++++++++---------------- tests/urntest.chk | 87 +++++++++++++++++++++++++++++++---------------- tests/urntest.log | 12 +++++-- 3 files changed, 114 insertions(+), 60 deletions(-) diff --git a/actions.c b/actions.c index 07c55e0..5689ad2 100644 --- a/actions.c +++ b/actions.c @@ -281,7 +281,6 @@ static int vcarry(token_t verb, token_t obj) * take one without the other). Liquids also special, since they depend on * status of bottle. Also various side effects, etc. */ { - int spk; if (obj == INTRANSITIVE) { /* Carry, no object given yet. OK if only one object present. */ if (game.atloc[game.loc] == 0 || @@ -295,46 +294,63 @@ static int vcarry(token_t verb, token_t obj) rspeak(ALREADY_CARRYING); return GO_CLEAROBJ; } - spk = YOU_JOKING; - if (obj == PLANT && game.prop[PLANT] <= 0) - spk = DEEP_ROOTS; - if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) - spk = BEAR_CHAINED; - if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) - spk = STILL_LOCKED; - if (obj == URN) - spk = URN_NOBUDGE; - if (obj == CAVITY) - spk = DOUGHNUT_HOLES; - if (obj == BLOOD) - spk = FEW_DROPS; - if (obj == RUG && game.prop[RUG] == RUG_HOVER) - spk = RUG_HOVERS; - if (obj == SIGN) - spk = HAND_PASSTHROUGH; + if (obj == MESSAG) { rspeak(REMOVE_MESSAGE); DESTROY(MESSAG); return GO_CLEAROBJ; } + if (game.fixed[obj] != 0) { - rspeak(spk); + if (obj == PLANT && game.prop[PLANT] <= 0) { + rspeak(DEEP_ROOTS); + return GO_CLEAROBJ; + } + if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR) { + rspeak(BEAR_CHAINED); + return GO_CLEAROBJ; + } + if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR) { + rspeak(STILL_LOCKED); + return GO_CLEAROBJ; + } + if (obj == URN) { + rspeak(URN_NOBUDGE); + return GO_CLEAROBJ; + } + if (obj == CAVITY) { + rspeak(DOUGHNUT_HOLES); + return GO_CLEAROBJ; + } + if (obj == BLOOD) { + rspeak(FEW_DROPS); + return GO_CLEAROBJ; + } + if (obj == RUG && game.prop[RUG] == RUG_HOVER) { + rspeak(RUG_HOVERS); + return GO_CLEAROBJ; + } + if (obj == SIGN) { + rspeak(HAND_PASSTHROUGH); + return GO_CLEAROBJ; + } + rspeak(YOU_JOKING); return GO_CLEAROBJ; } + int spk; if (obj == WATER || obj == OIL) { if (!HERE(BOTTLE) || LIQUID() != obj) { - if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE) - return (fill(verb, BOTTLE)); - else { - if (game.prop[BOTTLE] != EMPTY_BOTTLE) - spk = BOTTLE_FULL; - if (!TOTING(BOTTLE)) - spk = NO_CONTAINER; - rspeak(spk); + if (TOTING(BOTTLE)) { + if (game.prop[BOTTLE] == EMPTY_BOTTLE) { + return (fill(verb, BOTTLE)); + } else if (game.prop[BOTTLE] != EMPTY_BOTTLE) + rspeak(BOTTLE_FULL); return GO_CLEAROBJ; } + rspeak(NO_CONTAINER); + return GO_CLEAROBJ; } obj = BOTTLE; } @@ -367,10 +383,11 @@ static int vcarry(token_t verb, token_t obj) -1 - game.prop[BIRD] == 1)) carry(BIRD + CAGE - obj, game.loc); carry(obj, game.loc); - if (obj == BOTTLE && LIQUID() != 0) + if (obj == BOTTLE && LIQUID() != NO_OBJECT) game.place[LIQUID()] = CARRIED; if (GSTONE(obj) && game.prop[obj] != 0) { - game.prop[obj] = STATE_GROUND; + game.prop[obj] + = STATE_GROUND; game.prop[CAVITY] = CAVITY_EMPTY; } rspeak(OK_MAN); diff --git a/tests/urntest.chk b/tests/urntest.chk index 9efe234..9caa54e 100644 --- a/tests/urntest.chk +++ b/tests/urntest.chk @@ -1090,6 +1090,42 @@ You're at west end of Twopit Room. There is a huge beanstalk growing out of the west pit up to the hole. +> w + +You're in Slab Room. + +> u + +You are in a secret n/s canyon above a large room. + +> reservoir + +You're at reservoir. + +The waters have parted to form a narrow path across the reservoir. + +> take water + +Your bottle is now full of water. + +> s + +You're in Mirror Canyon. + +> s + +You are in a secret n/s canyon above a large room. + +> d + +You're in Slab Room. + +> s + +You're at west end of Twopit Room. + +There is a huge beanstalk growing out of the west pit up to the hole. + > drop appendage OK @@ -1113,6 +1149,14 @@ a small pool of oil in one corner of the pit. Don't be ridiculous! +> get + +Get what? + +> drink water + +The bottle of water is now empty. + > get oil Your bottle is now full of oil. @@ -1125,7 +1169,8 @@ There is a huge beanstalk growing out of the west pit up to the hole. > w -You're at west end of Twopit Room. +You are at the west end of the Twopit Room. There is a large hole in +the wall above the pit at this end of the room. Your keen eye spots a severed leporine appendage lying on the ground. @@ -1281,24 +1326,10 @@ OK > se -There is a threatening little dwarf in the room with you! - You are in a room whose walls resemble swiss cheese. Obvious passages go west, east, ne, and nw. Part of the room is occupied by a large bedrock block. -> throw axe - -You killed a little dwarf. - -You're in Swiss Cheese Room. - -There is a little axe here. - -> take axe - -OK - > e You are in the Soft Room. The walls are covered with heavy curtains, @@ -1432,16 +1463,12 @@ OK It is now pitch dark. If you proceed you will likely fall into a pit. -A hollow voice says "PLUGH". - > on Your lamp is now on. You're at "Y2". -A hollow voice says "PLUGH". - > s You're in n/s passage above e/w passage. @@ -1510,8 +1537,7 @@ There is a huge beanstalk growing out of the west pit up to the hole. > w -You are at the west end of the Twopit Room. There is a large hole in -the wall above the pit at this end of the room. +You're at west end of Twopit Room. Your keen eye spots a severed leporine appendage lying on the ground. @@ -1767,9 +1793,7 @@ There is a huge beanstalk growing out of the west pit up to the hole. > e -You are in a room whose walls resemble swiss cheese. Obvious passages -go west, east, ne, and nw. Part of the room is occupied by a large -bedrock block. +You're in Swiss Cheese Room. There is a little axe here. @@ -1851,7 +1875,11 @@ There is a huge beanstalk growing out of the west pit up to the hole. > w -You're in Slab Room. +You are in a large low circular chamber whose floor is an immense slab +fallen from the ceiling (Slab Room). East and west there once were +large passages, but they are now filled with boulders. Low small +passages go north and south, and the south one quickly bends west +around the boulders. > u @@ -1879,8 +1907,6 @@ You're in n/s passage above e/w passage. You're at "Y2". -A hollow voice says "PLUGH". - > off Your lamp is now off. @@ -2029,6 +2055,9 @@ Extinguish what? > look +Tsk! A wizard wouldn't have to take 350 turns. This is going to cost +you a couple of points. + Sorry, but I am not allowed to give more detail. I will repeat the long description of your location. @@ -2076,8 +2105,8 @@ If you mean to use the persian rug, it does not appear inclined to cooperate. -You scored 267 out of a possible 430, using 350 turns. +You scored 265 out of a possible 430, using 358 turns. You have reached "Junior Master" status. -To achieve the next higher rating, you need 54 more points. +To achieve the next higher rating, you need 56 more points. diff --git a/tests/urntest.log b/tests/urntest.log index fa82b01..8add0df 100644 --- a/tests/urntest.log +++ b/tests/urntest.log @@ -180,10 +180,20 @@ s d water plant u +w +u +reservoir +take water +s +s +d +s drop appendage e d drink oil +get +drink water get oil u w @@ -215,8 +225,6 @@ nw s take vase se -throw axe -take axe e take pillow w -- 2.31.1