Skip to content
Permalink
Browse files

Merged PR 534: Merge 612_worker_assignment to master

Related work items: #612
  • Loading branch information...
realms-mud committed Jul 10, 2019
1 parent 7d974eb commit d4cf664f7ef23ccd569e0c0b55d57a18dcbe9da7
@@ -7,6 +7,7 @@ virtual inherit "/lib/dictionaries/domains/sub-dictionaries/administration-menu.
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/build-component-menu.c";
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/building-menu.c";
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/execute-build.c";
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/henchman.c";
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/hiring-menu.c";
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/holdings-menu.c";
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/section-menu.c";
@@ -92,27 +93,3 @@ public nomask int validTroopEffects(mapping effects)
{
return 0;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int isValidHenchmanType(string data)
{
return member(({ "aegis", "diplomat", "senechal", "advisor", "soldier",
"concubine", "mage", "artisan", "sage", "noble", "scholar",
"engineer", "architect", "craftsman", "banker", "innkeeper",
"retailer", "manager", "scientist", "arcane craftsman" }), data) > -1;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int isValidHenchman(mapping data)
{
return mappingp(data) && member(data, "name") &&
member(data, "type") && isValidHenchmanType(data["type"]) &&
member(data, "persona") && member(data, "level") &&
member(data, "vitals") && member(data, "activity");
}

/////////////////////////////////////////////////////////////////////////////
public nomask int isValidActivity(string location, mapping activity)
{
return 1;
}
@@ -0,0 +1,74 @@
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/core.c";

/////////////////////////////////////////////////////////////////////////////
public nomask int isValidActivity(string location, string activity)
{
return 1;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int isValidHenchmanType(string data)
{
return member(({ "aegis", "diplomat", "senechal", "advisor", "soldier",
"concubine", "mage", "artisan", "sage", "noble", "scholar",
"engineer", "architect", "craftsman", "banker", "innkeeper",
"retailer", "manager", "scientist", "arcane craftsman" }), data) > -1;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int isValidHenchman(mapping data)
{
int ret = mappingp(data);
if (ret && member(data, "skills"))
{
ret &&= mappingp(data["skills"]) && sizeof(data["skills"]);
if (ret)
{
object skillsDictionary =
load_object("/lib/dictionaries/skillsDictionary.c");

foreach(string skill in m_indices(data["skills"]))
{
ret &&= skillsDictionary->isValidSkill(skill);
}
}
}

if (ret && member(data, "traits"))
{
ret &&= mappingp(data["traits"]) && sizeof(data["traits"]);
if (ret)
{
object traitsDictionary =
load_object("/lib/dictionaries/traitsDictionary.c");

foreach(string trait in m_indices(data["traits"]))
{
ret &&= traitsDictionary->validTrait(trait);
}
}
}

return ret && mappingp(data) && member(data, "name") &&
member(data, "type") && isValidHenchmanType(data["type"]) &&
member(data, "persona") && member(data, "level") &&
member(data, "activity");
}

/////////////////////////////////////////////////////////////////////////////
public nomask object getHenchmanFromData(mapping data, object user)
{
object ret = 0;

if (isValidHenchman(data))
{
ret = clone_object("/lib/realizations/henchman.c");
ret->setHenchmanData(data, user);
}

return ret;
}
@@ -110,13 +110,14 @@ public nomask mapping getWorkersByTypeMenu(object user, string location,
"type": worker,
"description": sprintf("This option assigns %s to the task of "
"building the selected component.\n", name),
"is disabled": member(henchmen[worker], "current assignment"),
"is disabled": henchmen[worker]->activity() != "idle",
"data": henchmen[worker],
"canShow": 1
]);
}
}
ret[to_string(sizeof(ret) + 1)] = ([
"name": "Confirm Selected Workers",
"name": "Confirm Selections",
"type": "confirm",
"description": "This option assigns workers to the task of "
"building the selected component.\n",
@@ -1081,6 +1081,11 @@ private nosave mapping decorators = ([
"8-bit": "\x1b[0;38;5;25;1m",
"24-bit": "\x1b[0;38;2;10;80;160;1m"
]),
"busy":([
"3-bit": "\x1b[0;31m",
"8-bit": "\x1b[0;38;5;9m",
"24-bit": "\x1b[0;38;2;200;0;0m"
]),
]),
]);

@@ -118,7 +118,15 @@ public nomask int addHenchman(string location, mapping data)
{
henchmen[location] = ([]);
}
henchmen[location][data["name"]] = data;
string key = data["name"];
if (member(data, "house"))
{
key += " " + data["house"];
}

data["location"] = location;
henchmen[location][key] =
dictionary->getHenchmanFromData(data, this_object());
}
return ret;
}
@@ -134,8 +142,8 @@ public nomask varargs mapping getHenchmen(string location, string type)

if (stringp(type))
{
ret = filter(ret, (: $2["type"] == $3 :), type);
ret = filter(ret, (: $2->type() == $3 :), type);
}
}
return ret;
return ret + ([]);
}
@@ -9,7 +9,6 @@ private string MaterialType;
private string Selection;
private mapping MaterialData = 0;
private object dictionary = load_object("/lib/dictionaries/domainDictionary.c");
private object SubselectorObj;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
@@ -63,17 +62,6 @@ protected nomask void setUpUserForSelection()
}
}

/////////////////////////////////////////////////////////////////////////////
public nomask void onSelectorCompleted(object caller)
{
if (User)
{
setUpUserForSelection();
tell_object(User, displayMessage());
}
caller->cleanUp();
}

/////////////////////////////////////////////////////////////////////////////
protected string choiceFormatter(string choice)
{
@@ -141,12 +129,6 @@ protected nomask int processSelection(string selection)
return ret;
}

/////////////////////////////////////////////////////////////////////////////
protected nomask int suppressMenuDisplay()
{
return objectp(SubselectorObj);
}

/////////////////////////////////////////////////////////////////////////////
public string selection()
{
@@ -10,7 +10,6 @@ private int QuantityNeeded;
private mapping Selections = ([]);

private object dictionary = load_object("/lib/dictionaries/domainDictionary.c");
private object SubselectorObj;

/////////////////////////////////////////////////////////////////////////////
public nomask void setLocation(string location)
@@ -70,17 +69,6 @@ protected nomask void setUpUserForSelection()
}
}

/////////////////////////////////////////////////////////////////////////////
public nomask void onSelectorCompleted(object caller)
{
if (User)
{
setUpUserForSelection();
tell_object(User, displayMessage());
}
caller->cleanUp();
}

/////////////////////////////////////////////////////////////////////////////
protected nomask string additionalInstructions()
{
@@ -93,10 +81,15 @@ protected nomask string additionalInstructions()
protected nomask string displayDetails(string choice)
{
string ret = sprintf("%7s", "");
if ((Data[choice]["type"] == "confirm") &&
(User->colorConfiguration() == "none"))
if ((Data[choice]["type"] == "confirm") && Data[choice]["is disabled"])
{
ret = sprintf("%-7s", " N/A");
ret = sprintf("%-7s", (User->colorConfiguration() == "none") ?
"N/A" : "");
}
else if (Data[choice]["is disabled"])
{
ret = configuration->decorate(sprintf("%-7s", "busy"),
"busy", "player domains", colorConfiguration);
}
else if (member(m_indices(Selections), Data[choice]["type"]) > -1)
{
@@ -132,14 +125,26 @@ protected nomask int processSelection(string selection)

if (!ret)
{

if (!Data[selection]["is disabled"] &&
Data[selection]["type"] == "confirm")
{
ret = 1;
}
else if (!Data[selection]["is disabled"])
{
if (!member(Selections, Data[selection]["type"]))
{
Selections[Data[selection]["type"]] =
Data[selection]["data"];

}
else
{
m_delete(Selections, Data[selection]["type"]);
}
setUpUserForSelection();
}
}
}
return ret;
}

/////////////////////////////////////////////////////////////////////////////
protected nomask int suppressMenuDisplay()
{
return objectp(SubselectorObj);
}

0 comments on commit d4cf664

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