Skip to content

Commit

Permalink
Merged PR 503: Merge 603_player_domains to master
Browse files Browse the repository at this point in the history
Related work items: #604, #603
  • Loading branch information
Allen B. Cummings committed May 16, 2019
1 parent fa9f397 commit 38393e7
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 23 deletions.
5 changes: 5 additions & 0 deletions core/baseSelector.c
Expand Up @@ -217,6 +217,7 @@ public nomask int applySelection(string arguments)
{ {
ret = Describe; ret = Describe;
tell_object(User, displayMessage() + "\n"); tell_object(User, displayMessage() + "\n");

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

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

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

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

tell_object(User, configuration->decorate( tell_object(User, configuration->decorate(
sprintf("You have selected '%s'.\n", choice), sprintf("You have selected '%s'.\n", choice),
"action", "selector", colorConfiguration)); "action", "selector", colorConfiguration));
Expand Down
91 changes: 78 additions & 13 deletions dictionaries/domainDictionary.c
Expand Up @@ -69,6 +69,36 @@ private nomask void transformLayout(mapping building)
building["layout"] = explode(layout, "\n"); 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, private nomask string applyColorToBuilding(mapping component, string key,
string colorConfiguration, string charset) string colorConfiguration, string charset)
Expand Down Expand Up @@ -97,9 +127,17 @@ private nomask string applyColorToBuilding(mapping component, string key,
return ret; return ret;
} }


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

return ret;
}

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


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

if (stringp(highlightComponent) &&
(highlightComponent == component))
{
ret["components"][component]["sections"][section] =
applyIsBuildingBackground(
ret["components"][component]["sections"][section],
colorConfiguration);
}
} }
} }
} }
Expand All @@ -142,6 +189,15 @@ public nomask varargs mapping getPlayerDomain(object player, string location,
applyColorToBuilding( applyColorToBuilding(
CastleComponents[upgrades[upgrade]]["components"][section] + ([]), CastleComponents[upgrades[upgrade]]["components"][section] + ([]),
upgrades[upgrade], colorConfiguration, charset); 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]; ret["components"][upgrade]["constructed"] = upgrades[upgrade];
} }
Expand Down Expand Up @@ -245,17 +301,20 @@ public nomask mapping getHoldingsMenu(object user)


///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public nomask mapping getBuildingMenu(object user, string location, public nomask mapping getBuildingMenu(object user, string location,
string type) string type, string highlightComponent)
{ {
mapping ret = ([]); mapping ret = ([]);
string *components = ComponentTypes + ({}); string *components = ComponentTypes + ({});
string domainType = user->getDomainType(location); 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 && if ((member(components, type) > -1) && domainType &&
member(CastleBlueprints, domainType)) member(CastleBlueprints, domainType))
{ {
showCategories = 0;
components = sort_array( components = sort_array(
filter(m_indices(CastleBlueprints[domainType]["components"]), filter(m_indices(CastleBlueprints[domainType]["components"]),
(: CastleBlueprints[$2]["components"][$1]["type"] == $3 :), (: CastleBlueprints[$2]["components"][$1]["type"] == $3 :),
Expand All @@ -277,28 +336,34 @@ public nomask mapping getBuildingMenu(object user, string location,


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

if (firstSection) if (firstSection)
{ {
ret[to_string(count)]["first section"] = firstSection; ret[to_string(count)]["first section"] = firstSection;
Expand Down
8 changes: 8 additions & 0 deletions documentation/terrain.md
Expand Up @@ -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. 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 ##### State Machines
TBD TBD
2 changes: 1 addition & 1 deletion include/itemFormatters.h
Expand Up @@ -351,7 +351,7 @@ private nosave mapping decorators = ([
]), ]),
"description":([ "description":([
"3-bit": "\x1b[0;36m", "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" "24-bit": "\x1b[0;38;2;140;180;190m"
]), ]),
"action":([ "action":([
Expand Down
8 changes: 8 additions & 0 deletions modules/domains/administrationSelector.c
Expand Up @@ -4,6 +4,14 @@
//***************************************************************************** //*****************************************************************************
inherit "/lib/core/baseSelector.c"; inherit "/lib/core/baseSelector.c";


private string Location;

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

///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg) public nomask void reset(int arg)
{ {
Expand Down
24 changes: 23 additions & 1 deletion modules/domains/buildSelector.c
Expand Up @@ -38,7 +38,8 @@ protected nomask void setUpUserForSelection()
object dictionary = load_object("/lib/dictionaries/domainDictionary.c"); object dictionary = load_object("/lib/dictionaries/domainDictionary.c");
if (dictionary) if (dictionary)
{ {
Data = dictionary->getBuildingMenu(User, Location, HoldingType); Data = dictionary->getBuildingMenu(User, Location, HoldingType,
"northwest tower");
} }
Data[to_string(sizeof(Data) + 1)] = ([ Data[to_string(sizeof(Data) + 1)] = ([
"name":"Exit Building Projects Menu", "name":"Exit Building Projects Menu",
Expand Down Expand Up @@ -78,3 +79,24 @@ protected string choiceFormatter(string choice)
displayDetails(choice), displayDetails(choice),
Data[choice]["layout panel"] || ""); 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;
}
8 changes: 8 additions & 0 deletions modules/domains/hiringSelector.c
Expand Up @@ -4,6 +4,14 @@
//***************************************************************************** //*****************************************************************************
inherit "/lib/core/baseSelector.c"; inherit "/lib/core/baseSelector.c";


private string Location;

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

///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg) public nomask void reset(int arg)
{ {
Expand Down
8 changes: 8 additions & 0 deletions modules/domains/improvementSelector.c
Expand Up @@ -4,6 +4,14 @@
//***************************************************************************** //*****************************************************************************
inherit "/lib/core/baseSelector.c"; inherit "/lib/core/baseSelector.c";


private string Location;

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

///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg) public nomask void reset(int arg)
{ {
Expand Down
8 changes: 8 additions & 0 deletions modules/domains/seneschalSelector.c
Expand Up @@ -5,6 +5,13 @@
inherit "/lib/core/baseSelector.c"; inherit "/lib/core/baseSelector.c";


private object SubselectorObj; private object SubselectorObj;
private string Location;

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


///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg) public nomask void reset(int arg)
Expand Down Expand Up @@ -47,6 +54,7 @@ protected nomask int processSelection(string selection)
SubselectorObj = SubselectorObj =
clone_object(Data[selection]["selector file"]); clone_object(Data[selection]["selector file"]);
SubselectorObj->setType(Data[selection]["selector"]); SubselectorObj->setType(Data[selection]["selector"]);
SubselectorObj->setLocation(Location);
move_object(SubselectorObj, User); move_object(SubselectorObj, User);
SubselectorObj->registerEvent(this_object()); SubselectorObj->registerEvent(this_object());
SubselectorObj->initiateSelector(User); SubselectorObj->initiateSelector(User);
Expand Down
8 changes: 8 additions & 0 deletions modules/domains/taskSelector.c
Expand Up @@ -4,6 +4,14 @@
//***************************************************************************** //*****************************************************************************
inherit "/lib/core/baseSelector.c"; inherit "/lib/core/baseSelector.c";


private string Location;

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

///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public nomask void reset(int arg) public nomask void reset(int arg)
{ {
Expand Down
8 changes: 8 additions & 0 deletions modules/domains/troopsSelector.c
Expand Up @@ -4,6 +4,14 @@
//***************************************************************************** //*****************************************************************************
inherit "/lib/core/baseSelector.c"; inherit "/lib/core/baseSelector.c";


private string Location;

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

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

0 comments on commit 38393e7

Please sign in to comment.