Come with me on another edition of "fixing things that weren't broken" by Zi!
TLDR: added dynamic keywords to fit dynamic coin descriptions.
Drop a handful of coins... go ahead, drop 234, then look.
(SOMETHING'S UP HERE... THERE'S A LAG WHEN LOOKING AT COINS IN A ROOM)
You'll see:
Code:
A pile of coins is lying here.
Great.
Take pile...
Code:
You do not see that here.
The player does see it in the look command, but okay. 'take coins' returns:
Code:
You get a pile of coins.
There were 234 coins.
same with... large pile, mountain, etc. so let's make those keywords match the descriptions whence creating an object depending on the amount of coins left! My mud uses "tokens" instead of coins, so just roll with it.
In handler.c I have what I think is the TBA standard:
Code:
const char *money_desc(int amount)
{
int cnt;
struct {
int limit;
const char *description;
} money_table[] = {
{ 1, "a token" },
{ 10, "a tiny pile of tokens" },
{ 20, "a handful of tokens" },
{ 75, "a little pile of tokens" },
{ 200, "a small pile of tokens" },
{ 1000, "a pile of tokens" },
{ 5000, "a big pile of tokens" },
{ 10000, "a large heap of tokens" },
{ 20000, "a huge mound of tokens" },
{ 75000, "an enormous mound of tokens" },
{ 150000, "a small mountain of tokens" },
{ 250000, "a mountain of tokens" },
{ 500000, "a huge mountain of tokens" },
{ 750000, "an enormous mountain of tokens" },
{ 0, NULL },
};
if (amount <= 0) {
log("SYSERR: Try to create negative or 0 money (%d).", amount);
return (NULL);
}
for (cnt = 0; money_table[cnt].limit; cnt++)
if (amount <= money_table[cnt].limit)
return (money_table[cnt].description);
return ("an absolutely colossal mountain of tokens");
}
so I added underneath:
Code:
const char *money_keywords(int amount)
{
int cnt;
struct {
int limit;
const char *keywords;
} money_table[] = {
{ 1, "token" },
{ 10, "pile" },
{ 20, "tokens handful" },
{ 75, "tokens pile little" },
{ 200, "tokens small pile" },
{ 1000, "tokens pile" },
{ 5000, "tokens big pile" },
{ 10000, "tokens large heap" },
{ 20000, "tokens huge mound" },
{ 75000, "tokens enormous mound" },
{ 150000, "tokens small mountain" },
{ 250000, "tokens mountain" },
{ 500000, "tokens huge mountain" },
{ 750000, "tokens enormous mountain" },
{ 0, NULL },
};
if (amount <= 0) {
log("SYSERR: Try to create negative or 0 money (%d).", amount);
return (NULL);
}
for (cnt = 0; money_table[cnt].limit; cnt++)
if (amount <= money_table[cnt].limit)
return (money_table[cnt].keywords);
return ("tokens colossal mountain");
}
and in the struct obj_data *create_money(int amount) modified to:
Code:
struct obj_data *create_money(int amount)
{
struct obj_data *obj;
struct extra_descr_data *new_descr;
char buf[200];
int y;
if (amount <= 0) {
log("SYSERR: Try to create negative or 0 tokens. (%d)", amount);
return (NULL);
}
obj = create_obj();
CREATE(new_descr, struct extra_descr_data, 1);
if (amount == 1) {
obj->name = strdup("token");
obj->short_description = strdup("a token");
obj->description = strdup("A single token is lying here.");
new_descr->keyword = strdup("token");
new_descr->description = strdup("It's just one little token.");
} else {
obj->name = strdup(money_keywords(amount));
obj->short_description = strdup(money_desc(amount));
snprintf(buf, sizeof(buf), "%s is lying here.", money_desc(amount));
obj->description = strdup(CAP(buf));
new_descr->keyword = strdup(money_keywords(amount));
if (amount < 10)
snprintf(buf, sizeof(buf), "There are %s%d%s tokens.", BYEL, amount, CNRM);
else if (amount < 100)
snprintf(buf, sizeof(buf), "There are about %s%d%s tokens.", BYEL, 10 * (amount / 10), CNRM);
else if (amount < 1000)
snprintf(buf, sizeof(buf), "It looks to be about %s%d%s tokens.", BYEL, 100 * (amount / 100), CNRM);
else if (amount < 100000)
snprintf(buf, sizeof(buf), "You guess there are close to %s%d%s tokens.", BYEL,
1000 * ((amount / 1000) + rand_number(0, (amount / 1000))), CNRM);
else
strcpy(buf, "There are a LOT of tokens."); /* strcpy: OK (is < 200) */
new_descr->description = strdup(buf);
}
so now the pile/mountain/whatever can be taken by "take pile" or "take token" or "take tokens"
Overkill? add to the next release to make TBA even more coherent? am I a TBA sweat? yes. yes I am.