Skip to content
Permalink
Browse files

Merged PR 503: Merge 603_player_domains to master

Related work items: #604, #603
  • Loading branch information...
realms-mud committed May 16, 2019
1 parent fa9f397 commit 38393e7ca79f65873537b13084db8622c760346c
@@ -217,6 +217,7 @@ public nomask int applySelection(string arguments)
{
ret = Describe;
tell_object(User, displayMessage() + "\n");

tell_object(User, configuration->decorate(
member(Data[element],"do not format") ? Data[element]["description"] :
format(Data[element]["description"], 78),
@@ -252,6 +253,7 @@ public nomask int applySelection(string arguments)
{
undoSelection(selection);
}

tell_object(User, configuration->decorate(
"You have reset your selections.\n",
"action", "selector", colorConfiguration) +
@@ -262,9 +264,11 @@ public nomask int applySelection(string arguments)
else if ((arguments == "exit") && AllowAbort)
{
ret = Success;

tell_object(User, configuration->decorate(
Type + " has been exited.\n",
"action", "selector", colorConfiguration));

emitCompletionEvent();
notifySynchronous("onSelectorAborted");
}
@@ -276,6 +280,7 @@ public nomask int applySelection(string arguments)
{
choice = choice[0..48] + "...";
}

tell_object(User, configuration->decorate(
sprintf("You have selected '%s'.\n", choice),
"action", "selector", colorConfiguration));
@@ -69,6 +69,36 @@ private nomask void transformLayout(mapping building)
building["layout"] = explode(layout, "\n");
}

/////////////////////////////////////////////////////////////////////////////
private nomask string applyIsBuildingBackground(string message,
string colorConfiguration)
{
string ret = message;
string colorReplacement = "";

switch (colorConfiguration)
{
case "3-bit":
{
colorReplacement = "\x1b[0;31;1";
break;
}
case "8-bit":
{
colorReplacement = "\x1b[0;48;5;52;\\1";
break;
}
case "24-bit":
{
colorReplacement = "\x1b[0;48;2;90;0;0;\\1";
break;
}
}

return
regreplace(ret, "\x1b.0;([^m]+)", colorReplacement, 1);
}

/////////////////////////////////////////////////////////////////////////////
private nomask string applyColorToBuilding(mapping component, string key,
string colorConfiguration, string charset)
@@ -97,9 +127,17 @@ private nomask string applyColorToBuilding(mapping component, string key,
return ret;
}

/////////////////////////////////////////////////////////////////////////////
private nomask string* getComponentDetails(mapping component)
{
string* ret = ({ "" });

return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask varargs mapping getPlayerDomain(object player, string location,
string type)
string type, string highlightComponent)
{
mapping ret = ([]);

@@ -122,6 +160,15 @@ public nomask varargs mapping getPlayerDomain(object player, string location,
applyColorToBuilding(
CastleComponents[key]["components"][section] + ([]),
key, colorConfiguration, charset);

if (stringp(highlightComponent) &&
(highlightComponent == component))
{
ret["components"][component]["sections"][section] =
applyIsBuildingBackground(
ret["components"][component]["sections"][section],
colorConfiguration);
}
}
}
}
@@ -142,6 +189,15 @@ public nomask varargs mapping getPlayerDomain(object player, string location,
applyColorToBuilding(
CastleComponents[upgrades[upgrade]]["components"][section] + ([]),
upgrades[upgrade], colorConfiguration, charset);

if (stringp(highlightComponent) &&
(highlightComponent == upgrade))
{
ret["components"][upgrade]["sections"][section] =
applyIsBuildingBackground(
ret["components"][upgrade]["sections"][section],
colorConfiguration);
}
}
ret["components"][upgrade]["constructed"] = upgrades[upgrade];
}
@@ -245,17 +301,20 @@ public nomask mapping getHoldingsMenu(object user)

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getBuildingMenu(object user, string location,
string type)
string type, string highlightComponent)
{
mapping ret = ([]);
string *components = ComponentTypes + ({});
string domainType = user->getDomainType(location);
int showCategories = 1;

mapping playerDomain = getPlayerDomain(user, location, domainType);
mapping playerDomain = getPlayerDomain(user, location, domainType,
highlightComponent);

if ((member(components, type) > -1) && domainType &&
member(CastleBlueprints, domainType))
{
showCategories = 0;
components = sort_array(
filter(m_indices(CastleBlueprints[domainType]["components"]),
(: CastleBlueprints[$2]["components"][$1]["type"] == $3 :),
@@ -277,28 +336,34 @@ public nomask mapping getBuildingMenu(object user, string location,

foreach(string component in components)
{
if (member(playerDomain["components"], component))
if(showCategories)
{
ret[to_string(count)] = ([
"name":playerDomain["components"][component]["display name"][0..18],
"type" : component,
"description" : playerDomain["components"][component]["description"],
"canShow" : 1,
"layout panel" : (sizeof(playerDomain["layout"]) >= count) ?
playerDomain["layout"][count + offset - 1] : "",
"name": sprintf("Construct %s", capitalize(component))[0..18],
"type" : component,
"description" : sprintf("From this menu, you can initiate, "
"modify, or abort %s projects in your holdings at %s.",
component, location),
"canShow" : 1,
"is category": 1,
"layout panel" : (sizeof(playerDomain["layout"]) >= count) ?
playerDomain["layout"][count + offset - 1] : "",
]);
}
else
else if (member(playerDomain["components"], component))
{
ret[to_string(count)] = ([
"name": capitalize(component[0..18]),
"name": playerDomain["components"][component]["display name"][0..18],
"type" : component,
"description" : "",
"description" : playerDomain["components"][component]["description"],
"canShow" : 1,
"layout panel" : (sizeof(playerDomain["layout"]) >= count) ?
playerDomain["layout"][count + offset - 1] : "",
"details": getComponentDetails(
playerDomain["components"][component])
]);
}

if (firstSection)
{
ret[to_string(count)]["first section"] = firstSection;
@@ -137,5 +137,13 @@ of light are positive, the environment will be light and otherwise, it will be d

The optional parameters limit the light source to specific states, times of day, and seasons respectively.

#### Active Lighting

TBD

#### Decaying Light Sources

TBD

##### State Machines
TBD
@@ -351,7 +351,7 @@ private nosave mapping decorators = ([
]),
"description":([
"3-bit": "\x1b[0;36m",
"8-bit": "\x1b[0;38;5;117m",
"8-bit": "\x1b[0;38;5;116m",
"24-bit": "\x1b[0;38;2;140;180;190m"
]),
"action":([
@@ -4,6 +4,14 @@
//*****************************************************************************
inherit "/lib/core/baseSelector.c";

private string Location;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
{
Location = location;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
@@ -38,7 +38,8 @@ protected nomask void setUpUserForSelection()
object dictionary = load_object("/lib/dictionaries/domainDictionary.c");
if (dictionary)
{
Data = dictionary->getBuildingMenu(User, Location, HoldingType);
Data = dictionary->getBuildingMenu(User, Location, HoldingType,
"northwest tower");
}
Data[to_string(sizeof(Data) + 1)] = ([
"name":"Exit Building Projects Menu",
@@ -78,3 +79,24 @@ protected string choiceFormatter(string choice)
displayDetails(choice),
Data[choice]["layout panel"] || "");
}

/////////////////////////////////////////////////////////////////////////////
protected nomask int processSelection(string selection)
{
int ret = -1;
if (User)
{
ret = (Data[selection]["type"] == "exit") || (selection == "abort");
if (!ret && member(Data[selection], "is category") &&
Data[selection]["is category"])
{
HoldingType = Data[selection]["type"];
Description = capitalize(HoldingType) + ":\n" +
configuration->decorate(format(Data[selection]["description"], 78),
"description", "selector", colorConfiguration);
SuppressColon = 1;
initiateSelector(User);
}
}
return ret;
}
@@ -4,6 +4,14 @@
//*****************************************************************************
inherit "/lib/core/baseSelector.c";

private string Location;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
{
Location = location;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
@@ -4,6 +4,14 @@
//*****************************************************************************
inherit "/lib/core/baseSelector.c";

private string Location;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
{
Location = location;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
@@ -5,6 +5,13 @@
inherit "/lib/core/baseSelector.c";

private object SubselectorObj;
private string Location;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
{
Location = location;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
@@ -47,6 +54,7 @@ protected nomask int processSelection(string selection)
SubselectorObj =
clone_object(Data[selection]["selector file"]);
SubselectorObj->setType(Data[selection]["selector"]);
SubselectorObj->setLocation(Location);
move_object(SubselectorObj, User);
SubselectorObj->registerEvent(this_object());
SubselectorObj->initiateSelector(User);
@@ -4,6 +4,14 @@
//*****************************************************************************
inherit "/lib/core/baseSelector.c";

private string Location;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
{
Location = location;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{
@@ -4,6 +4,14 @@
//*****************************************************************************
inherit "/lib/core/baseSelector.c";

private string Location;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
{
Location = location;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg)
{

0 comments on commit 38393e7

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