candy bar wrappers

Adopt the suggestion that candy bar stacks which get split should
keep the same wrapper text for both halves of the stack.  The patch
stuck with using obj->o_id to manage the wrapper which prior to the
patch wasn't a factor in merging and splitting.  Switch to obj->spe
instead, comparable to tin varities, so mergability is already
taken care of.

End of game disclosure tacks on T-shirt text to formatted items.
Do the same for candy bar wrappers.
This commit is contained in:
PatR
2020-07-30 19:25:57 -07:00
parent 8ca0834eb2
commit c64049306d
6 changed files with 74 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 read.c $NHDT-Date: 1595966992 2020/07/28 20:09:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.199 $ */
/* NetHack 3.6 read.c $NHDT-Date: 1596162345 2020/07/31 02:25:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.200 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -178,6 +178,39 @@ char *buf;
return erode_obj_text(apron, buf);
}
static const char *candy_wrappers[] = {
"", /* (none -- should never happen) */
"Apollo", /* Lost */
"Moon Crunchy", /* South Park */
"Snacky Cake", "Chocolate Nuggie", "The Small Bar",
"Crispy Yum Yum", "Nilla Crunchie", "Berry Bar",
"Choco Nummer", "Om-nom", /* Cat Macro */
"Fruity Oaty", /* Serenity */
"Wonka Bar", /* Charlie and the Chocolate Factory */
};
/* return the text of a candy bar's wrapper */
const char *
candy_wrapper_text(obj)
struct obj *obj;
{
/* modulo operation is just bullet proofing; 'spe' is already in range */
return candy_wrappers[obj->spe % SIZE(candy_wrappers)];
}
/* assign a wrapper to a candy bar stack */
void
assign_candy_wrapper(obj)
struct obj *obj;
{
if (obj->otyp == CANDY_BAR) {
/* skips candy_wrappers[0] */
obj->spe = 1 + rn2(SIZE(candy_wrappers) - 1);
}
return;
}
/* the 'r' command; read a scroll or spell book or various other things */
int
doread()
{
@@ -299,22 +332,17 @@ doread()
u.uconduct.literate++;
return 1;
} else if (scroll->otyp == CANDY_BAR) {
static const char *wrapper_msgs[] = {
"Apollo", /* Lost */
"Moon Crunchy", /* South Park */
"Snacky Cake", "Chocolate Nuggie", "The Small Bar",
"Crispy Yum Yum", "Nilla Crunchie", "Berry Bar",
"Choco Nummer", "Om-nom", /* Cat Macro */
"Fruity Oaty", /* Serenity */
"Wonka Bar" /* Charlie and the Chocolate Factory */
};
const char *wrapper = candy_wrapper_text(scroll);
if (Blind) {
You_cant("feel any Braille writing.");
return 0;
}
pline("The wrapper reads: \"%s\".",
wrapper_msgs[scroll->o_id % SIZE(wrapper_msgs)]);
if (!*wrapper) {
pline("The candy bar's wrapper is blank.");
return 0;
}
pline("The wrapper reads: \"%s\".", wrapper);
u.uconduct.literate++;
return 1;
} else if (scroll->oclass != SCROLL_CLASS