Skip to content
Permalink
Browse files

Merged PR 512: Merge 608_component_construction to master

Related work items: #608
  • Loading branch information...
realms-mud committed Jun 3, 2019
1 parent 885cac8 commit 74c3955aecdeb67cbb10d51c56cd93e059ae69ea
@@ -129,21 +129,37 @@ private nomask string applyColorToBuilding(mapping component, string key,
}

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

return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask varargs mapping getPlayerDomain(object player, string location,
string type, string highlightComponent)
private nomask void updateSections(mapping blueprint, string *sections,
string key, string component, string highlightComponent,
string colorConfiguration, string charset)
{
mapping ret = ([]);
foreach(string section in sections)
{
blueprint[section] = applyColorToBuilding(
CastleComponents[key]["components"][section] + ([]),
key, colorConfiguration, charset);

if (stringp(highlightComponent) && (highlightComponent == component))
{
blueprint[section] =
applyIsBuildingBackground(blueprint[section], colorConfiguration);
}
}
}

string colorConfiguration = player->colorConfiguration();
string charset = player->charsetConfiguration();
/////////////////////////////////////////////////////////////////////////////
private nomask mapping getUnbuiltDomain(string type, string highlightComponent,
string colorConfiguration, string charset)
{
mapping ret = ([]);

if (stringp(type) && member(CastleBlueprints, type))
{
@@ -155,57 +171,71 @@ public nomask varargs mapping getPlayerDomain(object player, string location,
ret["components"][component]["sections"] = ([]);

string key = sprintf("unbuilt %s", component);
foreach(string section in m_indices(CastleComponents[key]["components"]))
{
ret["components"][component]["sections"][section] =
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);
}
}

updateSections(ret["components"][component]["sections"],
m_indices(CastleComponents[key]["components"]),
sprintf("unbuilt %s", component),
component, highlightComponent, colorConfiguration, charset);
}
}
return ret;
}

mapping upgrades = player->getDomainUpgrades(location, type);
if (sizeof(upgrades))
{
foreach(string upgrade in m_indices(upgrades))
{
string upgradeName = upgrades[upgrade]["name"];
/////////////////////////////////////////////////////////////////////////////
private nomask void applyDomainUpgrades(mapping domains, object player,
string location, string type, string highlightComponent,
string colorConfiguration, string charset)
{
mapping upgrades = player->getDomainUpgrades(location, type);
if (sizeof(upgrades))
{
foreach(string upgrade in m_indices(upgrades))
{
string upgradeName = upgrades[upgrade]["name"];

if (member(CastleComponents, upgradeName))
{
updateSections(domains["components"][upgrade]["sections"],
m_indices(CastleComponents[upgradeName]["components"]),
upgradeName, upgrade, highlightComponent,
colorConfiguration, charset);

domains["components"][upgrade]["constructed"] =
upgrades[upgrade];
}
}
}
}

if (member(CastleComponents, upgradeName))
{
mapping components =
CastleComponents[upgradeName]["components"];

foreach(string section in m_indices(components))
{
ret["components"][upgrade]["sections"][section] =
applyColorToBuilding(
CastleComponents[upgradeName]["components"][section] + ([]),
upgradeName, 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];
}
}
}
/////////////////////////////////////////////////////////////////////////////
private nomask void applyCurrentComponent(mapping domains, string component,
string highlightComponent, string colorConfiguration, string charset)
{
if (component && member(CastleComponents, component))
{
string upgrade = CastleComponents[component]["type"];

updateSections(domains["components"][upgrade]["sections"],
m_indices(CastleComponents[component]["components"]),
component, upgrade, highlightComponent, colorConfiguration, charset);
}
}

/////////////////////////////////////////////////////////////////////////////
private nomask varargs mapping getPlayerDomain(object player, string location,
string type, string highlightComponent, string currentComponent)
{
string colorConfiguration = player->colorConfiguration();
string charset = player->charsetConfiguration();

mapping ret =
getUnbuiltDomain(type, highlightComponent, colorConfiguration, charset);

applyDomainUpgrades(ret, player, location, type, highlightComponent,
colorConfiguration, charset);

applyCurrentComponent(ret, currentComponent, highlightComponent,
colorConfiguration, charset);

if (sizeof(ret))
{
@@ -434,11 +464,56 @@ public nomask mapping getBuildingMenu(object user, string location,
return ret;
}

/////////////////////////////////////////////////////////////////////////////
private nomask string *getComponentInfo(object user, string component)
{
string *ret = ({});

if (member(CastleComponents, component))
{
string colorConfiguration = user->colorConfiguration();
string charset = user->charsetConfiguration();

object configuration =
load_object("/lib/dictionaries/configurationDictionary.c");

ret += ({

});
}
return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getBuildComponentMenu(object user, string location,
string type, string highlightComponent)
string component)
{
return ([]);
mapping ret = ([]);

string domainType = user->getDomainType(location);

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

string *details = getComponentInfo(user, component);
string *options = ({});
int count = 1;
int offset = 0;
string *firstSection = 0;

if (sizeof(playerDomain["layout"]) > sizeof(options))
{
offset = sizeof(playerDomain["layout"]) - sizeof(options);
firstSection = playerDomain["layout"][0..(offset - 1)];
}

foreach(string option in options)
{
string key = to_string(count);
count++;
}

return ret;
}

/////////////////////////////////////////////////////////////////////////////

0 comments on commit 74c3955

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