From ab94051da166ca2be050c0d5725774f2edf3e7ee Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 1 Jul 2017 09:21:04 -0400 Subject: [PATCH] Magic-number and state-arithmetic removal. --- actions.c | 8 ++++++-- adventure.yaml | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/actions.c b/actions.c index a30d7c0..4d6944f 100644 --- a/actions.c +++ b/actions.c @@ -93,8 +93,12 @@ static int attack(struct command_t *command) } spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2; } else if (obj == BEAR) { - /* FIXME: Arithmetic on message numbers */ - spk = BEAR_HANDS + (game.prop[BEAR] + 1) / 2; + switch (game.prop[BEAR]) { + case UNTAMED_BEAR: spk = BEAR_HANDS; break; + case SITTING_BEAR: spk = BEAR_CONFUSED; break; + case CONTENTED_BEAR: spk = BEAR_CONFUSED; break; + case BEAR_DEAD: spk = ALREADY_DEAD; break; + } } else if (obj == DRAGON && game.prop[DRAGON] == 0) { /* Fun stuff for dragon. If he insists on attacking it, win! * Set game.prop to dead, move dragon to central loc (still diff --git a/adventure.yaml b/adventure.yaml index a3e2841..ed482e2 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -3057,7 +3057,6 @@ arbitrary_messages: !!omap - TROLL_SCAMPERS: 'The bear lumbers toward the troll, who lets out a startled shriek and\nscurries away. The bear soon gives up the pursuit and wanders back.' - AXE_LOST: 'The axe misses and lands near the bear where you can''t get at it.' - BEAR_HANDS: 'With what? Your bare hands? Against *HIS* bear hands??' -# The following three messages must be contiguous - 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\ndown considerably and even becomes rather friendly.' -- 2.31.1