From: NHOrus Date: Sun, 2 Jul 2017 13:08:57 +0000 (+0300) Subject: Fix for issue #21, hopefully X-Git-Tag: takebird~115 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=73af0e3a55cb241a10c8abee9a1241e240cf650b;p=open-adventure.git Fix for issue #21, hopefully --- diff --git a/actions.c b/actions.c index 409e58e..ae46321 100644 --- a/actions.c +++ b/actions.c @@ -527,15 +527,19 @@ static int extinguish(token_t verb, int obj) if (obj == INTRANSITIVE) { if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT) obj = LAMP; - if (HERE(URN) && game.prop[URN] == 2) + if (HERE(URN) && game.prop[URN] == URN_LIT) obj = obj * NOBJECTS + URN; if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN; } if (obj == URN) { - game.prop[URN] = game.prop[URN] / 2; - spk = URN_DARK; + if (game.prop[URN] != URN_EMPTY) { + state_change(URN, URN_DARK); + } else { + pspeak(URN, change, URN_DARK); + } + return GO_CLEAROBJ; } else if (obj == LAMP) { state_change(LAMP, LAMP_DARK); spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE; @@ -728,32 +732,25 @@ static int inven(void) static int light(token_t verb, token_t obj) /* Light. Applicable only to lamp and urn. */ { - int spk = actions[verb].message; if (obj == INTRANSITIVE) { if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0) obj = LAMP; - if (HERE(URN) && game.prop[URN] == 1) - obj = obj * NOBJECTS + URN; + if (HERE(URN) && game.prop[URN] == URN_DARK) + obj = URN; if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN; } if (obj == URN) { - if (game.prop[URN] == 0) { - rspeak(URN_EMPTY); - } else { - game.prop[URN] = 2; - rspeak(URN_LIT); - } + state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT); return GO_CLEAROBJ; } else { if (obj != LAMP) { - rspeak(spk); + rspeak(actions[verb].message); return GO_CLEAROBJ; } - spk = LAMP_OUT; if (game.limit < 0) { - rspeak(spk); + rspeak(LAMP_OUT); return GO_CLEAROBJ; } state_change(LAMP, LAMP_BRIGHT); diff --git a/adventure.yaml b/adventure.yaml index 0e8949b..35560f1 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -2805,7 +2805,6 @@ arbitrary_messages: !!omap - NOT_LOCKABLE: 'I don''t know how to lock or unlock such a thing.' - ALREADY_LOCKED: 'It was already locked.' - ALREADY_UNLOCKED: 'It was already unlocked.' -- URN_EMPTY: 'The urn is empty and will not light.' - BEAR_BLOCKS: 'There is no way to get past the bear to unlock the chain, which is\nprobably just as well.' - NOTHING_HAPPENS: 'Nothing happens.' - WHERE_QUERY: 'Where?' @@ -2952,8 +2951,6 @@ arbitrary_messages: !!omap - FREE_FLY: 'The bird flies about agitatedly for a moment.' - CAGE_FLY: 'The bird flies agitatedly about the cage.' - NECKLACE_FLY: 'The bird flies about agitatedly for a moment, then disappears through\nthe crack. It reappears shortly, carrying in its beak a jade\nnecklace, which it drops at your feet.' -- URN_LIT: 'The urn is now lit.' -- URN_DARK: 'The urn is now dark.' - WATER_URN: 'You empty the bottle into the urn, which promptly ejects the water\nwith uncanny accuracy, squirting you directly between the eyes.' - OIL_URN: 'Your bottle is now empty and the urn is full of oil.' - FULL_URN: 'The urn is already full of oil.' @@ -3406,9 +3403,13 @@ objects: !!omap locations: LOC_CLIFF immovable: true descriptions: - - 'A small urn is embedded in the rock.' - - 'A small urn full of oil is embedded in the rock.' - - 'A small oil flame extrudes from an urn embedded in the rock.' + - [URN_EMPTY, 'A small urn is embedded in the rock.'] + - [URN_DARK, 'A small urn full of oil is embedded in the rock.'] + - [URN_LIT, 'A small oil flame extrudes from an urn embedded in the rock.'] + changes: + - 'The urn is empty and will not light.' + - 'The urn is now dark.' + - 'The urn is now lit.' - CAVITY: words: ['cavit'] inventory: '*cavity' diff --git a/tests/urntest.chk b/tests/urntest.chk index f186114..90ae17c 100644 --- a/tests/urntest.chk +++ b/tests/urntest.chk @@ -2048,7 +2048,7 @@ The urn is now dark. The forest thins out here to reveal a steep cliff. There is no way down, but a small ledge can be seen to the west across the chasm. -A small urn is embedded in the rock. +A small urn full of oil is embedded in the rock. > fly