From: NHOrus Date: Wed, 5 Jul 2017 16:55:52 +0000 (+0300) Subject: Made feeding a switch instead of elsif chain X-Git-Tag: takebird~5 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=725105b4a24d245765d0f1c2f57e4014c6c7534b Made feeding a switch instead of elsif chain --- diff --git a/actions.c b/actions.c index 971bbb3..c5494d0 100644 --- a/actions.c +++ b/actions.c @@ -624,46 +624,56 @@ static int feed(token_t verb, token_t obj) /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him * mad. Bear, special. */ { - int spk = actions[verb].message; - if (obj == BIRD) { + switch (obj) { + case BIRD: rspeak(BIRD_PINING); - return GO_CLEAROBJ; - } else if (obj == SNAKE || - obj == DRAGON || - obj == TROLL) { - spk = NOTHING_EDIBLE; - if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS) - spk = RIDICULOUS_ATTEMPT; - if (obj == TROLL) - spk = TROLL_VICES; - if (obj == SNAKE && !game.closed && HERE(BIRD)) { + break; + + case DRAGON: + if (game.prop[DRAGON] != DRAGON_BARS) + rspeak(RIDICULOUS_ATTEMPT); + else + rspeak(NOTHING_EDIBLE); + break; + case SNAKE: + if (!game.closed && HERE(BIRD)) { DESTROY(BIRD); - spk = BIRD_DEVOURED; - } - } else if (obj == DWARF) { + rspeak(BIRD_DEVOURED); + } else + rspeak(NOTHING_EDIBLE); + break; + case TROLL: + rspeak(TROLL_VICES); + break; + case DWARF: if (HERE(FOOD)) { game.dflag += 2; - spk = REALLY_MAD; + rspeak(REALLY_MAD); } - } else if (obj == BEAR) { - if (game.prop[BEAR] == UNTAMED_BEAR) - spk = NOTHING_EDIBLE; - if (game.prop[BEAR] == BEAR_DEAD) - spk = RIDICULOUS_ATTEMPT; - if (HERE(FOOD)) { - DESTROY(FOOD); - game.prop[BEAR] = SITTING_BEAR; - game.fixed[AXE] = IS_FREE; - game.prop[AXE] = AXE_HERE; - spk = BEAR_TAMED; + break; + case BEAR: + if (game.prop[BEAR] == BEAR_DEAD) { + rspeak(RIDICULOUS_ATTEMPT); + break; + } + if (game.prop[BEAR] == UNTAMED_BEAR) { + if (HERE(FOOD)) { + DESTROY(FOOD); + game.fixed[AXE] = IS_FREE; + game.prop[AXE] = AXE_HERE; + state_change(BEAR, SITTING_BEAR); + } else + rspeak(NOTHING_EDIBLE); } - } else if (obj == OGRE) { + break; + case OGRE: if (HERE(FOOD)) - spk = OGRE_FULL; - } else { - spk = AM_GAME; + rspeak(OGRE_FULL); + else rspeak(actions[verb].message); + break; + default: + rspeak(AM_GAME); } - rspeak(spk); return GO_CLEAROBJ; } diff --git a/adventure.yaml b/adventure.yaml index c816099..fe44ce8 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -2966,9 +2966,6 @@ arbitrary_messages: !!omap - BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??' - BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.' - ALREADY_DEAD: 'For crying out loud, the poor thing is already dead!' -- BEAR_TAMED: |- - The bear eagerly wolfs down your food, after which he seems to calm - down considerably and even becomes rather friendly. - BEAR_CHAINED: 'The bear is still chained to the wall.' - STILL_LOCKED: 'The chain is still locked.' - CHAIN_UNLOCKED: 'The chain is now unlocked.' @@ -3537,6 +3534,11 @@ objects: !!omap - 'There is a gentle cave bear sitting placidly in one corner.' - 'There is a contented-looking bear wandering about nearby.' - '' + changes: + - '' + - 'The bear eagerly wolfs down your food, after which he seems to calm\ndown considerably and even becomes rather friendly.' + - '' + - '' - MESSAG: words: ['messa'] inventory: '*message in second maze' diff --git a/misc.c b/misc.c index b4869d8..c219cfb 100644 --- a/misc.c +++ b/misc.c @@ -402,7 +402,7 @@ bool yes(const char* question, const char* yes_response, const char* no_response for (;;) { speak(question); - char* reply = get_input(); + char* reply = get_input(); if (reply == NULL) { // LCOV_EXCL_START // Should be unreachable. Reply should never be NULL