Made feeding a switch instead of elsif chain

This commit is contained in:
NHOrus 2017-07-05 19:55:52 +03:00 committed by Eric S. Raymond
parent 23aced5c7c
commit 725105b4a2
3 changed files with 48 additions and 36 deletions

View file

@ -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;
}
} else if (obj == OGRE) {
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);
}
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;
}

View file

@ -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'

2
misc.c
View file

@ -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