Skip to content
Permalink
Browse files

Merged PR 542: Merge 620_use_remote_henchmen to master

Related work items: #620
  • Loading branch information...
realms-mud committed Jul 19, 2019
1 parent fa0503c commit 84694a39758676ea3c60580543aad0a79491c036
@@ -10,4 +10,10 @@ protected mapping Locations = ([
"title": "##Count## of Argalach",
"type": "castle"
]),
"durthan castle":([
"name": "Durthan Castle",
"entry point": "lib/areas/eledhel/durthan/entry.c",
"title": "##Count## of Durthan",
"type": "castle"
]),
]);
@@ -258,7 +258,7 @@ private nomask mapping getSkillsForProfession(object henchman,

/////////////////////////////////////////////////////////////////////////////
private nomask int getBenefit(string benefitType, string profession,
string baseline, int maxModifier, mapping skills)
string baseline, int maxModifier, mapping skills, int isRemote)
{
float ret = 0.0;

@@ -294,10 +294,14 @@ private nomask int getBenefit(string benefitType, string profession,
}
}
}

if (isRemote && (benefitType == "duration"))
{
ret -= 25.0;
}
return to_int(ret);
}


/////////////////////////////////////////////////////////////////////////////
private nomask string getDecorator(string type, string charset)
{
@@ -388,19 +392,25 @@ private nomask string displayDescription(object user, mapping data)
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getBenefits(object user, object henchman, string type)
public nomask mapping getBenefits(object user, object henchman, string type,
string location)
{
mapping ret = ([]);

string baseline = getBenefitLevel(henchman, type);
int maxModifier = getModifier("maximum modifier", baseline);
mapping skills = getSkillsForProfession(henchman, type);

ret["duration"] = getBenefit("duration", type, baseline, maxModifier, skills);
ret["materials"] = getBenefit("materials", type, baseline, maxModifier, skills);
ret["structure"] = getBenefit("structure", type, baseline, maxModifier, skills);
ret["units"] = getBenefit("units", type, baseline, maxModifier, skills);
ret["combat"] = getBenefit("combat", type, baseline, maxModifier, skills);
ret["duration"] = getBenefit("duration", type, baseline, maxModifier,
skills, location != henchman->location());
ret["materials"] = getBenefit("materials", type, baseline, maxModifier,
skills, location != henchman->location());
ret["structure"] = getBenefit("structure", type, baseline, maxModifier,
skills, location != henchman->location());
ret["units"] = getBenefit("units", type, baseline, maxModifier,
skills, location != henchman->location());
ret["combat"] = getBenefit("combat", type, baseline, maxModifier,
skills, location != henchman->location());

ret["description"] = displayDescription(user, ret);
ret["level"] = baseline;
@@ -442,10 +452,10 @@ private nomask varargs string domainModifierDisplay(string description,

/////////////////////////////////////////////////////////////////////////////
public nomask string getHenchmanDetails(object user, object henchman,
string type, string name)
string type, string name, string location)
{
string ret = "";
mapping benefits = getBenefits(user, henchman, type);
mapping benefits = getBenefits(user, henchman, type, location);

string colorConfiguration = user->colorConfiguration();
string charset = user->charsetConfiguration();
@@ -501,5 +511,14 @@ public nomask string getHenchmanDetails(object user, object henchman,
(benefits["level"] == "low end worker") ? "" : "n",
benefits["level"]),
benefits["level"], "player domains", colorConfiguration);

if (location != henchman->location())
{
ret += configuration->decorate(
sprintf("The duration is increased because this person is not at "
"%s.\n", generateTitle(location || "this location")),
"negative value", "player domains", colorConfiguration);
}

return ret;
}
@@ -135,7 +135,7 @@ public nomask string getWorkersOfType(object user, string type,
currentSelections[entry]["level"], "player domains",
colorConfiguration) +
configuration->decorate(
sprintf("%-50s\n", (sizeof(details) > 4000) ?
sprintf("%-50s\n", (sizeof(details) > 50) ?
details[0..46] + "..." : details),
"heading", "player domains", colorConfiguration);
}
@@ -149,7 +149,7 @@ public nomask mapping getWorkersByTypeMenu(object user, string location,
{
mapping ret = ([]);

mapping henchmen = user->getHenchmen(location, type);
mapping henchmen = user->getHenchmen(type);
if(sizeof(henchmen))
{
string *workers = sort_array(m_indices(henchmen), (: $1 > $2 :));
@@ -167,8 +167,10 @@ public nomask mapping getWorkersByTypeMenu(object user, string location,
"type": worker,
"description": sprintf("This option assigns %s to the task of "
"building the selected component.\nStats:\n%s\n", name,
this_object()->getHenchmanDetails(user, henchmen[worker], type, name)),
this_object()->getHenchmanDetails(user, henchmen[worker], type,
name, location)),
"is disabled": henchmen[worker]->activity() != "idle",
"is remote": (location != henchmen[worker]->location()),
"cost": henchmen[worker]->cost(),
"data": henchmen[worker],
"canShow": 1
@@ -1086,6 +1086,11 @@ private nosave mapping decorators = ([
"8-bit": "\x1b[0;38;5;9m",
"24-bit": "\x1b[0;38;2;200;0;0m"
]),
"is remote": ([
"3-bit": "\x1b[0;31;1m",
"8-bit": "\x1b[0;38;5;9;1m",
"24-bit": "\x1b[0;38;2;200;60;0;1m"
]),
"positive value":([
"3-bit": "\x1b[0;34;1m",
"8-bit": "\x1b[0;38;5;25;1m",
@@ -144,23 +144,23 @@ public nomask int removeHenchman(string location, string key)
}

/////////////////////////////////////////////////////////////////////////////
public nomask varargs mapping getHenchmen(string location, string type)
public nomask varargs mapping getHenchmen(string type, string location)
{
mapping ret = ([]);

if (stringp(location) && member(henchmen, location))
{
ret = henchmen[location];
}
else if((location == "all") && sizeof(henchmen))
else if((!location || (location == "all")) && sizeof(henchmen))
{
foreach(string key in m_indices(henchmen))
{
ret += henchmen[key];
}
}

if (sizeof(ret) && stringp(type))
if (sizeof(ret) && stringp(type) && (type != "all"))
{
ret = filter(ret, (: $2->type() == $3 ||
$2->hasTraitOfRoot($3) :), type);
@@ -123,6 +123,13 @@ protected nomask string displayDetails(string choice)
" (*)"),
"selected", "selector", colorConfiguration);
}
else if (Data[choice]["is remote"])
{
ret = configuration->decorate(sprintf("%-7s",
(User->charsetConfiguration() == "unicode") ? " (\xe2\x99\x99)" :
" (R)"),
"is remote", "selector", colorConfiguration);
}
return ret;
}

@@ -156,7 +163,7 @@ private nomask void setupHireling(string type, string selection)
Selections[worker->Name() + " " + worker->Title()] = ([
"object": worker,
"benefits" : dictionary->getBenefits(User, worker,
WorkerType),
WorkerType, Location),
"level" : dictionary->getBenefitLevel(worker, WorkerType)
]);
}
@@ -199,7 +206,7 @@ protected nomask int processSelection(string selection)
Selections[Data[selection]["type"]] = ([
"object": worker,
"benefits": dictionary->getBenefits(User, worker,
WorkerType),
WorkerType, Location),
"level": dictionary->getBenefitLevel(worker, WorkerType)
]);
}
@@ -397,3 +397,49 @@ void DescriptionShowsWorkDetails()
"This person is considered an elite worker for this project.\n\n",
Player->caughtMessage());
}

/////////////////////////////////////////////////////////////////////////////
void DescriptionShowsWorkDetailsWhenNotInSameLocation()
{
SetupHenchmen("carpenter");
Selector->setLocation("durthan castle");
Selector->setQuantityNeeded(3);
Selector->setWorkerType("carpenter");

Selector->initiateSelector(Player);

ExpectEq("Building Projects - Assign Workers:\n"
"From this menu, you can select the carpenters who will be executing your\n"
"project in your holdings at Durthan Castle.\n"
"\nCarpenters selected: 0 of 3.\n\n"
"[1] - Arnalt Arator (R) [2] - Derek Evendim busy \n"
"[3] - Marik Argalen (R) [4] - Royce Eralkidh (R) \n"
"[5] - Hire Apprentice ($12500) low $ [6] - Hire Carpenter ($112500) low $ \n"
"[7] - Confirm Selections N/A [8] - Exit Building Menu \n"
"You must select a number from 1 to 8.\n"
"Type 'exit' if you do not wish to make a selection at this time.\n"
"For details on a given choice, type 'describe X' (or '? X') where\n"
"X is the option about which you would like further details.\n"
"You have 3 workers left to assign.\n",
Player->caughtMessage());

command("? 3", Player);

ExpectEq("This option assigns Marik Argalen to the task of building the selected\n"
"component.\n"
"Stats:\n"
"Name : Marik Argalen\n"
"Traits: Master Carpenter, Swordsman\n"
"Skills:\n"
" Carpentry: 25\n"
" Wood Crafting: 20\n"
"Domain Modifiers - This worker will have the following project-level effects:\n"
"This person increases the duration by 8% on this project.\n"
"This person reduces the materials used by 17% on this project.\n"
"This person increases the structural strength by 15% on this project.\n"
"This person increases the units accomodated by 10% on this project.\n"
"This person increases the combat modifiers by 10% on this project.\n"
"This person is considered an elite worker for this project.\n"
"The duration is increased because this person is not at Durthan Castle.\n\n",
Player->caughtMessage());
}
@@ -141,16 +141,20 @@ void GetTitlesReturnsListOfTitles()
ExpectEq(({ "##Count## of Argalach" }), Player->getTitles());
}

/////////////////////////////////////////////////////////////////////////////
void GetHenchmenReturnsEmptyListWhenNoLocationUsed()
{
ExpectEq(([]), Player->getHenchmen());
}

/////////////////////////////////////////////////////////////////////////////
void GetHenchmenReturnsEmptyListWhenUnownedLocationUsed()
{
ExpectEq(([]), Player->getHenchmen("argalach castle"));
mapping henchman = ([
"name": "Tantor the Unclean",
"type": "architect",
"persona": "mage",
"level": 10,
"activity": "building"
]);
Player->addPlayerHolding("durthan castle");
ExpectTrue(Player->addHenchman("durthan castle", henchman));

ExpectEq(([]), Player->getHenchmen("all", "argalach castle"));
}

/////////////////////////////////////////////////////////////////////////////
@@ -173,8 +177,14 @@ void GetHenchmenReturnsCorrectListForLocation()
ExpectFalse(Player->addHenchman("argalach castle", ([ "name": "Bob" ])));
ExpectEq(([]), Player->getHenchmen("argalach castle"));

Player->addPlayerHolding("durthan castle");
ExpectTrue(Player->addHenchman("argalach castle", henchman));
mapping henchmen = Player->getHenchmen("argalach castle");

henchman["name"] = "Bob the Boorish";
ExpectTrue(Player->addHenchman("durthan castle", henchman));

mapping henchmen = Player->getHenchmen("all", "argalach castle");
ExpectEq(1, sizeof(henchmen));
ExpectTrue(member(m_indices(henchmen), "Tantor the Unclean") > -1);
object tantor = henchmen["Tantor the Unclean"];

@@ -185,6 +195,30 @@ void GetHenchmenReturnsCorrectListForLocation()
ExpectEq("architect", tantor->type());
}

/////////////////////////////////////////////////////////////////////////////
void GetHenchmenReturnsAllHenchmenWhenNoLocationUsed()
{
mapping henchman = ([
"name": "Tantor the Unclean",
"type": "architect",
"persona": "mage",
"level": 10,
"activity": "building"
]);

Player->addPlayerHolding("argalach castle");
Player->addPlayerHolding("durthan castle");

ExpectTrue(Player->addHenchman("argalach castle", henchman));

henchman["name"] = "Bob the Boorish";
ExpectTrue(Player->addHenchman("durthan castle", henchman));

mapping henchmen = Player->getHenchmen();
ExpectEq(2, sizeof(henchmen));
ExpectEq(({ "Bob the Boorish", "Tantor the Unclean" }), m_indices(henchmen));
}

/////////////////////////////////////////////////////////////////////////////
void GetHenchmenReturnsCorrectTypeOfHenchmen()
{
@@ -200,7 +234,7 @@ void GetHenchmenReturnsCorrectTypeOfHenchmen()
Player->addPlayerHolding("argalach castle");
ExpectTrue(Player->addHenchman("argalach castle", henchman), "added henchman");

mapping henchmen = Player->getHenchmen("argalach castle", "carpenter");
mapping henchmen = Player->getHenchmen("carpenter");
ExpectTrue(member(m_indices(henchmen), "Tantor the Unclean") > -1, "Tantor in list");
object tantor = henchmen["Tantor the Unclean"];

0 comments on commit 84694a3

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