Skip to content
Permalink
Browse files

Merged PR 460: Merge 567_inventory_enhancements to master

Related work items: #567
  • Loading branch information...
realms-mud committed Mar 7, 2019
1 parent 3372e89 commit f81646a9ac73d44dfe5fbb82100ced1c045d1d14
@@ -26,9 +26,7 @@ public nomask int execute(string command, object initiator)
ret = 1;

int verbose = sizeof(regexp(({ command }), "-v"));
tell_object(initiator, initiator->inventoryText(verbose) +
sprintf("\x1b[0;31m| \x1b[0;36mYou currently have \x1b[0;32m%d\x1b[0;36m in cash on hand.\n", initiator->Money()) +
"\x1b[0;31m+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\x1b[0m");
tell_object(initiator, initiator->inventoryText(verbose, 1));
}
return ret;
}
@@ -28,11 +28,14 @@ public nomask int execute(string command, object initiator)
ret = 1;
if (initiator->hasTraitOfRoot("blind"))
{
tell_object(initiator, "\x1b[0;30;1mYou are blind.\x1b[0m\n");
tell_object(initiator, configuration->decorate("You are blind.\n",
"too dark", "environment", initiator->colorConfiguration()));
}
else if (!initiator->canSee(1))
{
tell_object(initiator, "\x1b[0;30;1mIt is too dark.\x1b[0m\n");
string colorConfiguration = initiator->colorConfiguration();
tell_object(initiator, configuration->decorate("It is too dark.\n",
"too dark", "environment", colorConfiguration));

object *environmentInventory = filter(
all_inventory(environment(initiator)),
@@ -45,13 +48,18 @@ public nomask int execute(string command, object initiator)
initiator->hasTraitOfRoot("infravision") &&
sizeof(environmentInventory))
{
string visibleList = "\x1b[0;30;1mYou can see objects faintly glowing in red:\n\x1b[0m";
foreach(object environmentItem in environmentInventory)
string visibleList = configuration->decorate(
"You can see objects faintly glowing in red:\n",
"too dark", "environment", colorConfiguration);

foreach(object environmentItem in environmentInventory)
{
string shortDesc = environmentItem->short();
if (shortDesc && (shortDesc != ""))
{
visibleList += sprintf("\x1b[0;31m%s\n\x1b[0m", capitalize(shortDesc));
visibleList += configuration->decorate(
capitalize(shortDesc),
"infravision", "environment", colorConfiguration);
}
}

@@ -436,6 +436,11 @@ private nosave mapping decorators = ([
"8-bit": "\x1b[0;38;5;238;1m",
"24-bit": "\x1b[0;38;2;60;60;70;1m"
]),
"too dark":([
"3-bit": "\x1b[0;30;1m",
"8-bit": "\x1b[0;38;5;12m",
"24-bit": "\x1b[0;38;2;150;230;190m"
]),
"inventory": ([
"3-bit": "\x1b[0;36m",
"8-bit": "\x1b[0;38;5;80m",
@@ -1156,7 +1156,7 @@ private nomask string displayUnequippedItems(object banner, int verbose,
}

/////////////////////////////////////////////////////////////////////////////
public nomask varargs string inventoryText(int verbose)
public nomask varargs string inventoryText(int verbose, int showMoney)
{
string ret = "";

@@ -1167,11 +1167,10 @@ public nomask varargs string inventoryText(int verbose)

string colorConfiguration = "none";
string charset = "ascii";
if (this_player())
{
charset = this_player()->charsetConfiguration();
colorConfiguration = this_player()->colorConfiguration();
}
object character = this_player() ? this_player() : this_object();

charset = character->charsetConfiguration();
colorConfiguration = character->colorConfiguration();

if (sizeof(equippedItems))
{
@@ -1238,7 +1237,23 @@ public nomask varargs string inventoryText(int verbose)

ret += displayUnequippedItems(banner, verbose, colorConfiguration, charset);

ret += banner->buildBanner(colorConfiguration, charset, "middle", "Money");
if (showMoney)
{
string money = to_string(Money());
ret += banner->buildBanner(colorConfiguration, charset, "middle", "Money") +
banner->banneredContent(colorConfiguration, charset,
configuration->decorate("You currently have ",
"field", "equipment", colorConfiguration) +
configuration->decorate(money,
"value", "equipment", colorConfiguration) +
configuration->decorate(
sprintf(" %-" + to_string(55 - sizeof(money)) + "s",
"in cash on hand."), "field", "equipment", colorConfiguration));
}

if (sizeof(ret))
{
ret += banner->buildBanner(colorConfiguration, charset, "bottom", "");
}
return ret;
}
@@ -46,15 +46,21 @@ public nomask void runAway()
private int checkForImpairedVision(object player)
{
int ret = 0;

object configuration = getDictionary("configuration");
string colorConfiguration = this_object()->colorConfiguration() || "none";

if (player->hasTraitOfRoot("blind"))
{
tell_object(player, "\x1b[0;30;1mYou are blind.\x1b[0m\n");
tell_object(player, configuration->decorate("You are blind.\n",
"too dark", "environment", colorConfiguration));
ret = 1;
}
else if (!player->canSee())
{
ret = 1;
tell_object(player, "\x1b[0;30;1mIt is too dark.\x1b[0m\n");
tell_object(player, configuration->decorate("It is too dark.\n",
"too dark", "environment", colorConfiguration));

object *environmentInventory = filter(
all_inventory(environment(player)),
@@ -65,13 +71,18 @@ private int checkForImpairedVision(object player)
if (player->hasTraitOfRoot("infravision") &&
sizeof(environmentInventory))
{
string visibleList = "\x1b[0;30;1mYou can see objects faintly glowing in red:\n\x1b[0m";
string visibleList = configuration->decorate(
"You can see objects faintly glowing in red:\n",
"too dark", "environment", colorConfiguration);

foreach(object environmentItem in environmentInventory)
{
string shortDesc = environmentItem->short();
if (shortDesc && (shortDesc != ""))
{
visibleList += sprintf("\x1b[0;31m%s\n\x1b[0m", capitalize(shortDesc));
visibleList += configuration->decorate(
capitalize(shortDesc),
"infravision", "environment", colorConfiguration);
}
}

Oops, something went wrong.

0 comments on commit f81646a

Please sign in to comment.
You can’t perform that action at this time.