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 mkobj.c $NHDT-Date: 1595787211 2020/07/26 18:13:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.182 $ */
/* NetHack 3.6 mkobj.c $NHDT-Date: 1596162341 2020/07/31 02:25:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.183 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -836,6 +836,12 @@ boolean artif;
case KELP_FROND:
otmp->quan = (long) rnd(2);
break;
case CANDY_BAR:
/* set otmp->spe */
assign_candy_wrapper(otmp);
break;
default:
break;
}
if (Is_pudding(otmp)) {
otmp->quan = 1L; /* for emphasis; glob quantity is always 1 */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 objnam.c $NHDT-Date: 1595627152 2020/07/24 21:45:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.303 $ */
/* NetHack 3.7 objnam.c $NHDT-Date: 1596162343 2020/07/31 02:25:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.304 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -718,10 +718,25 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
if (pluralize)
Strcpy(buf, makeplural(buf));
if (obj->otyp == T_SHIRT && g.program_state.gameover) {
/* maybe give some extra information which isn't shown during play */
if (g.program_state.gameover) {
const char *lbl;
char tmpbuf[BUFSZ];
Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf));
/* disclose without breaking illiterate conduct, but mainly tip off
players who aren't aware that something readable is present */
switch (obj->otyp) {
case T_SHIRT:
Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf));
break;
case CANDY_BAR:
lbl = candy_wrapper_text(obj);
if (*lbl)
Sprintf(eos(buf), " labeled \"%s\"", lbl);
break;
default:
break;
}
}
if (has_oname(obj) && dknown) {

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