Skip to content

Commit

Permalink
Merged PR 425: Merge 542_continued_trial_quest to master
Browse files Browse the repository at this point in the history
Related work items: #543, #542
  • Loading branch information
Allen B. Cummings committed Feb 1, 2019
1 parent b1158a8 commit 1380a71
Show file tree
Hide file tree
Showing 14 changed files with 934 additions and 8 deletions.
6 changes: 5 additions & 1 deletion core/specification.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,11 @@ public nomask string displayLimiters(string colorConfiguration, object configura
case "crafting type":
case "environment":
{
ret += sprintf(limiter, key, "is", researchData["limited by"][key]);
string types = stringp(researchData["limited by"][key]) ?
researchData["limited by"][key] :
implode(researchData["limited by"][key], ", ");

ret += sprintf(limiter, key, "is", types);
break;
}
case "opponent faction":
Expand Down
7 changes: 5 additions & 2 deletions environment/environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ private nomask string parseEfunCall(string match)
// obj is either this OR a file path.
// function is a method on the called object. That method MUST return a
// string.
match = regreplace(match, "\n", "", 1);

string *arguments = explode(match, "::");
if (sizeof(arguments) >= 4)
{
Expand Down Expand Up @@ -649,8 +651,9 @@ public varargs string long(string item)
{
ret += " " + environmentalElements["description"][currentState()];
}
ret = format(ret, 78);
ret = regreplace(ret,
"##([^:]+)::(key|filename|room)::([^:]+)::([a-zA-Z0-9_]+)::",
"##([^:]+)::(key|filename|room)::([^:]+)::([a-zA-Z0-9_\n]+)::",
#'parseEfunCall,1);
}
else
Expand All @@ -662,7 +665,7 @@ public varargs string long(string item)
string colorConfiguration = this_player() ?
this_player()->colorConfiguration() : "none";

return configuration->decorate(format(capitalizeSentences(ret), 78),
return configuration->decorate(capitalizeSentences(ret),
"description", "environment", colorConfiguration) +
getExitDescription() + getInventoryDescription() + "\n";
}
Expand Down
7 changes: 7 additions & 0 deletions include/itemFormatters.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ private nosave mapping decorators = ([
"24-bit": "\x1b[0;38;2;100;10;0m"
]),
]),
"grid":([
"display":([
"3-bit": "\x1b[0;31m",
"8-bit": "\x1b[0;38;5;9m",
"24-bit": "\x1b[0;38;2;200;0;0m"
]),
]),
]);

#endif
31 changes: 31 additions & 0 deletions tests/core/specificationTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ void CanSetLimitorForEquipmentThatIsValidListType()
ExpectEq(limitor, Specification->query("limited by"), "query the limitor");
}

/////////////////////////////////////////////////////////////////////////////
void CanSetLimitorThatIsAList()
{
mapping limitor = ([
"crafting type":({ "sword", "dagger", "pole arm", "staff",
"axe", "hammer", "mace", "flail", "crossbow",
"bow", "sling", "thrown", "shield" })
]);

ExpectTrue(Specification->addSpecification("limited by", limitor), "set the limitor");
ExpectEq(limitor, Specification->query("limited by"), "query the limitor");
}

/////////////////////////////////////////////////////////////////////////////
void CanSetMultipleLimitors()
{
Expand Down Expand Up @@ -528,6 +541,24 @@ void DisplayLimitersStringCorrectWithLimitorForWeapon()
ExpectEq("\x1b[0;36mThis is only applied when you're using: long sword.\n\x1b[0m", Specification->displayLimiters(colorConfiguration, Configuration));
}

/////////////////////////////////////////////////////////////////////////////
void DisplayLimitorsCorrectWithMultipleCraftingItems()
{
mapping limitor = ([
"crafting type":({ "sword", "dagger", "pole arm", "staff",
"axe", "hammer", "mace", "flail", "crossbow",
"bow", "sling", "thrown", "shield" })
]);

ExpectTrue(Specification->addSpecification("limited by", limitor),
"set the limitor");

ExpectEq("\x1b[0;36mThis is only applied when crafting type is sword, "
"dagger, pole arm, staff,\naxe, hammer, mace, flail, crossbow, bow, "
"sling, thrown, shield.\n\x1b[0m",
Specification->displayLimiters(colorConfiguration, Configuration));
}

/////////////////////////////////////////////////////////////////////////////
void DisplayLimitersStringCorrectWithLimitorForWeaponInList()
{
Expand Down
Loading

0 comments on commit 1380a71

Please sign in to comment.