Skip to content
Permalink
Browse files

Merged PR 502: Merge 603_player_domains to master

Related work items: #603
  • Loading branch information...
realms-mud committed May 14, 2019
1 parent 3383802 commit fa9f397a6ea32dc5e65c8f3eb931e14c02234175
@@ -11,109 +11,6 @@

private string DomainSelectorBase = "/lib/modules/domains/%sSelector.c";

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getTopLevelDomainMenu(object user)
{
return ([
"1":([
"name":"Administration Projects",
"description" : "This option lets you administer to your realm - "
"be it the taxation of your subjects or the assigning of "
"workers to the various projects in your domain.\n",
"selector" : "administration",
"selector file": sprintf(DomainSelectorBase, "administration"),
"canShow" : user->canApplyResearchBonus(
"lib/instances/research/domains/administration/basicAdministration.c",
"diplomacy")
]),
"2":([
"name":"Building Projects",
"description" : "This option lets you build large projects in your realm.\n",
"selector": "build",
"selector file": sprintf(DomainSelectorBase, "build"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/construction/basicBuilding.c",
"carpentry")
]),
"3":([
"name":"Resources and Holdings",
"description" : "This option lets you increase your holdings, prospect for "
"new resources, and manage resources in your domain.\n",
"selector": "improvement",
"selector file": sprintf(DomainSelectorBase, "improvement"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/holdings/basicHoldings.c",
"engineering")
]),
"4":([
"name":"Hire New Henchmen",
"description" : "This option lets you hire henchmen that can be used to "
"perform tasks within your domain.\n",
"selector": "hiring",
"selector file": sprintf(DomainSelectorBase, "hiring"),
"canShow" : user->canApplyResearchBonus(
"lib/instances/research/domains/hiring/basicHiring.c",
"persuasion")
]),
"5":([
"name":"Manage Tasks",
"description" : "This option lets you assign tasks to your hired "
"henchmen and companions.\n",
"selector": "task",
"selector file": sprintf(DomainSelectorBase, "task"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/tasks/basicTasks.c",
"persuasion")
]),
"6":([
"name":"Manage Troops",
"description" : "This option lets you create and manage "
"your troops and their activities.\n",
"selector": "troops",
"selector file": sprintf(DomainSelectorBase, "troops"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/troops/basicTroops.c",
"persuasion")
]),
]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getTroopsMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getTaskMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getHiringMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getHoldingsMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getBuildingMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getAdministrationMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask int validBuildings(mixed buildings)
{
@@ -162,10 +59,11 @@ private nomask void transformLayout(mapping building)

foreach(string key in m_indices(building["components"]))
{
foreach(string section in m_indices(building["components"][key]))
foreach(string section in
m_indices(building["components"][key]["sections"]))
{
layout = regreplace(layout, section,
building["components"][key][section], 1);
building["components"][key]["sections"][section], 1);
}
}
building["layout"] = explode(layout, "\n");
@@ -178,21 +76,24 @@ private nomask string applyColorToBuilding(mapping component, string key,
string ret = 0;
string *colors = m_indices(CastleComponents[key]["colors"]);

if (member(CastleComponents[key]["colors"]["default"], colorConfiguration))
ret = component[charset];
if (sizeof(colors))
{
ret = component[charset];
if (sizeof(colors))
foreach(string color in colors)
{
foreach(string color in colors)
{
ret = regreplace(ret, color,
CastleComponents[key]["colors"][color][colorConfiguration], 1);
}
}
string transformColor =
member(CastleComponents[key]["colors"][color], colorConfiguration) ?
CastleComponents[key]["colors"][color][colorConfiguration] :
"";

ret = CastleComponents[key]["colors"]["default"][colorConfiguration] +
ret + "\x1b[0m";
ret = regreplace(ret, color, transformColor, 1);
}
}

ret = member(CastleComponents[key]["colors"]["default"], colorConfiguration) ?
CastleComponents[key]["colors"]["default"][colorConfiguration] +
ret + "\x1b[0m" : ret;

return ret;
}

@@ -212,10 +113,12 @@ public nomask varargs mapping getPlayerDomain(object player, string location,
string *components = m_indices(ret["components"]);
foreach(string component in components)
{
ret["components"][component]["sections"] = ([]);

string key = sprintf("unbuilt %s", component);
foreach(string section in m_indices(CastleComponents[key]["components"]))
{
ret["components"][component][section] =
ret["components"][component]["sections"][section] =
applyColorToBuilding(
CastleComponents[key]["components"][section] + ([]),
key, colorConfiguration, charset);
@@ -228,23 +131,186 @@ public nomask varargs mapping getPlayerDomain(object player, string location,
{
foreach(string upgrade in m_indices(upgrades))
{
printf("Oy!\n");
if (member(CastleComponents, upgrades[upgrade]))
{
mapping components =
CastleComponents[upgrades[upgrade]]["components"];

foreach(string section in m_indices(components))
{
ret["components"][upgrade][section] =
ret["components"][upgrade]["sections"][section] =
applyColorToBuilding(
CastleComponents[upgrades[upgrade]]["components"][section] + ([]),
upgrades[upgrade], colorConfiguration, charset);
}
ret["components"][upgrade]["constructed"] = upgrades[upgrade];
}
}
}

transformLayout(ret);
return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getTopLevelDomainMenu(object user)
{
return ([
"1":([
"name":"Administration Projects",
"description" : "This option lets you administer to your realm - "
"be it the taxation of your subjects or the assigning of "
"workers to the various projects in your domain.\n",
"selector" : "administration",
"selector file": sprintf(DomainSelectorBase, "administration"),
"canShow" : user->canApplyResearchBonus(
"lib/instances/research/domains/administration/basicAdministration.c",
"diplomacy")
]),
"2":([
"name":"Building Projects",
"description" : "This option lets you build large projects in your realm.\n",
"selector": "build",
"selector file": sprintf(DomainSelectorBase, "build"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/construction/basicBuilding.c",
"carpentry")
]),
"3":([
"name":"Resources and Holdings",
"description" : "This option lets you increase your holdings, prospect for "
"new resources, and manage resources in your domain.\n",
"selector": "improvement",
"selector file": sprintf(DomainSelectorBase, "improvement"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/holdings/basicHoldings.c",
"engineering")
]),
"4":([
"name":"Hire New Henchmen",
"description" : "This option lets you hire henchmen that can be used to "
"perform tasks within your domain.\n",
"selector": "hiring",
"selector file": sprintf(DomainSelectorBase, "hiring"),
"canShow" : user->canApplyResearchBonus(
"lib/instances/research/domains/hiring/basicHiring.c",
"persuasion")
]),
"5":([
"name":"Manage Tasks",
"description" : "This option lets you assign tasks to your hired "
"henchmen and companions.\n",
"selector": "task",
"selector file": sprintf(DomainSelectorBase, "task"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/tasks/basicTasks.c",
"persuasion")
]),
"6":([
"name":"Manage Troops",
"description" : "This option lets you create and manage "
"your troops and their activities.\n",
"selector": "troops",
"selector file": sprintf(DomainSelectorBase, "troops"),
"canShow": user->canApplyResearchBonus(
"lib/instances/research/domains/troops/basicTroops.c",
"persuasion")
]),
]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getTroopsMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getTaskMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getHiringMenu(object user)
{
return ([]);
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getHoldingsMenu(object user)
{
return ([]);
}

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

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

if ((member(components, type) > -1) && domainType &&
member(CastleBlueprints, domainType))
{
components = sort_array(
filter(m_indices(CastleBlueprints[domainType]["components"]),
(: CastleBlueprints[$2]["components"][$1]["type"] == $3 :),
domainType, type),
(: CastleBlueprints[$3]["components"][$1]["sort order"] >
CastleBlueprints[$3]["components"][$2]["sort order"] :),
domainType);
}

int count = 1;
int offset = 0;
string *firstSection = 0;

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

foreach(string component in components)
{
if (member(playerDomain["components"], component))
{
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] : "",
]);
}
else
{
ret[to_string(count)] = ([
"name": capitalize(component[0..18]),
"type" : component,
"description" : "",
"canShow" : 1,
"layout panel" : (sizeof(playerDomain["layout"]) >= count) ?
playerDomain["layout"][count + offset - 1] : "",
]);
}
if (firstSection)
{
ret[to_string(count)]["first section"] = firstSection;
firstSection = 0;
}
count++;
}
return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getAdministrationMenu(object user)
{
return ([]);
}
@@ -12,6 +12,14 @@
#include "motte-buildings.h"
#include "motte-towers.h"

private string *ComponentTypes = ({
"building",
"keep",
"moat",
"tower",
"wall"
});

private mapping CastleComponents = CastleBuildings + CastleKeeps +
CastleTowers + CastleWalls + MotteBuildings + MotteTowers;

Oops, something went wrong.

0 comments on commit fa9f397

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