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 /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him
* mad. Bear, special. */ * mad. Bear, special. */
{ {
int spk = actions[verb].message; switch (obj) {
if (obj == BIRD) { case BIRD:
rspeak(BIRD_PINING); rspeak(BIRD_PINING);
return GO_CLEAROBJ; break;
} else if (obj == SNAKE ||
obj == DRAGON || case DRAGON:
obj == TROLL) { if (game.prop[DRAGON] != DRAGON_BARS)
spk = NOTHING_EDIBLE; rspeak(RIDICULOUS_ATTEMPT);
if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS) else
spk = RIDICULOUS_ATTEMPT; rspeak(NOTHING_EDIBLE);
if (obj == TROLL) break;
spk = TROLL_VICES; case SNAKE:
if (obj == SNAKE && !game.closed && HERE(BIRD)) { if (!game.closed && HERE(BIRD)) {
DESTROY(BIRD); DESTROY(BIRD);
spk = BIRD_DEVOURED; rspeak(BIRD_DEVOURED);
} } else
} else if (obj == DWARF) { rspeak(NOTHING_EDIBLE);
break;
case TROLL:
rspeak(TROLL_VICES);
break;
case DWARF:
if (HERE(FOOD)) { if (HERE(FOOD)) {
game.dflag += 2; game.dflag += 2;
spk = REALLY_MAD; rspeak(REALLY_MAD);
} }
} else if (obj == BEAR) { break;
if (game.prop[BEAR] == UNTAMED_BEAR) case BEAR:
spk = NOTHING_EDIBLE; if (game.prop[BEAR] == BEAR_DEAD) {
if (game.prop[BEAR] == BEAR_DEAD) rspeak(RIDICULOUS_ATTEMPT);
spk = RIDICULOUS_ATTEMPT; break;
if (HERE(FOOD)) {
DESTROY(FOOD);
game.prop[BEAR] = SITTING_BEAR;
game.fixed[AXE] = IS_FREE;
game.prop[AXE] = AXE_HERE;
spk = BEAR_TAMED;
} }
} 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)) if (HERE(FOOD))
spk = OGRE_FULL; rspeak(OGRE_FULL);
} else { else rspeak(actions[verb].message);
spk = AM_GAME; break;
default:
rspeak(AM_GAME);
} }
rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }

View file

@ -2966,9 +2966,6 @@ arbitrary_messages: !!omap
- BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??' - BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??'
- BEAR_CONFUSED: 'The bear is confused; he only wants to be your friend.' - 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!' - 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.' - BEAR_CHAINED: 'The bear is still chained to the wall.'
- STILL_LOCKED: 'The chain is still locked.' - STILL_LOCKED: 'The chain is still locked.'
- CHAIN_UNLOCKED: 'The chain is now unlocked.' - 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 gentle cave bear sitting placidly in one corner.'
- 'There is a contented-looking bear wandering about nearby.' - '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: - MESSAG:
words: ['messa'] words: ['messa']
inventory: '*message in second maze' 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 (;;) { for (;;) {
speak(question); speak(question);
char* reply = get_input(); char* reply = get_input();
if (reply == NULL) { if (reply == NULL) {
// LCOV_EXCL_START // LCOV_EXCL_START
// Should be unreachable. Reply should never be NULL // Should be unreachable. Reply should never be NULL