Skip to content
Permalink
Browse files

Merged PR 539: Merge 619_hirelings to master

Related work items: #619
  • Loading branch information...
realms-mud committed Jul 16, 2019
1 parent 247439b commit fe7c1e2cc2ed1b9ff3d8164bc6649906f81f9525
@@ -0,0 +1,80 @@
//*****************************************************************************
// Copyright (c) 2019 - Allen Cummings, RealmsMUD, All rights reserved. See
// the accompanying LICENSE file for details.
//*****************************************************************************
#ifndef henchmanNames_h
#define henchmanNames_h

private string *maleNames = ({
"Aradan", "Aramed", "Ardenel", "Aglaradan", "Alarac", "Alerik", "Alberich",
"Aidan", "Angus", "Ahearn", "Angus", "Arthur", "Bain", "Baird", "Balfour",
"Beathan", "Boyd", "Beren", "Bregor", "Berenar", "Brennan", "Brendan",
"Bregloas", "Caden", "Caedmon", "Cael", "Carlin", "Carrick", "Carson",
"Celath", "Chargon", "Cian", "Curthan", "Collin", "Colvin", "Corbin",
"Cowan", "Derek", "Daenor", "Darrick", "Donald", "Devin", "Duran", "Duor",
"Dougan", "Drystan", "Duncan", "Eagnor", "Eachann", "Edan", "Egan", "Eradin",
"Ergal", "Ewan", "Ewing", "Faolan", "Faerdil", "Fergus", "Fingal", "Finn",
"Flynn", "Gainor", "Gerak", "Geren", "Galvin", "Glynn", "Graeden", "Hagan",
"Herach", "Haeron", "Huran", "Herumor", "Huradan", "Helcaron", "Helfast",
"Helmuth", "Haeradin", "Kaden", "Kael", "Keron", "Kagan", "Karsten",
"Kaelan", "Kerak", "Kellen", "Kenneth", "Kevin", "Kiernan", "Kieron",
"Kyle", "Leith", "Lognar", "Lorien", "Lorren", "Les", "Loran", "Lorcan",
"Laeron", "Laradin", "Marach", "Malfen", "Marrick", "Macaeth", "Mallen",
"Halgaladh", "Harold", "Maxwell", "Murray", "Malcolm", "Neil", "Nagrath",
"Nelson", "Nigel", "Niall", "Nolan", "Norm", "Oredh", "Orathon", "Oisin",
"Ormond", "Owen", "Quill", "Quinlan", "Quillan", "Rey", "Roan", "Riordan",
"Relach", "Raenor", "Ralagon", "Rodan", "Ronin", "Rory", "Saoirse", "Serach",
"Seradin", "Seranel", "Saeron", "Saradil", "Tarack", "Taeron", "Teagan",
"Tevin", "Turan", "Tuonath", "Tiernan", "Torin", "Tristan", "Ulreth", "Ulgor",
"Ueran", "Uinar", "Vargath", "Vaeron", "Verak", "Valroth", "Vaerdan",
"Verach", "Vorgal", "Volrith", "Thomas", "Vaernor", "Warak", "Waeron", "Wallan",
"Willhelm", "Warnach", "Werdhel", "Wyan", "Winfreth", "Wigandh", "Yrchvin",
"Yrgal", "Yaradhel", "Yendrath", "Vendrath", "Yenegal", "Zurdhen", "Zuredh",
"Zalden", "Arawn", "Jerac", "Juron", "Jerith", "Jorgil", "Jordath", "Jorath",
"Joren", "Jordan", "Irich", "Erich", "Olric", "Osric", "Oren", "Oranal"
});

private string *femaleNames = ({
"Aelinwen", "Alanna", "Ayana", "Aegrid", "Aeryn", "Aewyn", "Alanwyn",
"Arissa", "Anna", "Alandria", "Arandwyn", "Baerwyn", "Balanna", "Berwyn",
"Baeradhel", "Binadwen", "Brianna", "Bulwyn", "Calaya", "Caryn", "Caelana",
"Curiene", "Caewyn", "Coriele", "Caedhwyn", "Branwyn", "Brenna", "Bryn",
"Cienne", "Aranwyn", "Adaena", "Aedana", "Alyssa", "Curana", "Culiene",
"Duna", "Danessa", "Duriel", "Dolwyn", "Donessa", "Delana", "Dorina", "Ellen",
"Erin", "Earwyn", "Eadana", "Elena", "Elwyth", "Fionah", "Fiorwyn", "Faerna",
"Fulryth", "Ferah", "Galawyn", "Galana", "Gilmyth", "Galnara", "Gwydhneth",
"Gwen", "Guiriel", "Helen", "Haleth", "Herah", "Helana", "Hilgrid", "Hurwyth",
"Karen", "Ilya", "Ilreth", "Ilana", "Ilaya", "Iriel", "Inawin", "Idwyn",
"Janeth", "Aaliyah", "Abigail", "Ada", "Adele", "Adelita", "Adina", "Adria",
"Adrianna", "Adrianne", "Adrienn", "Agata", "Agneta", "Agnes", "Aileen",
"Alisa", "Aja", "Alecta", "Ailese", "Alessa", "Alfhild", "Alexa", "Alice",
"Amara", "Ianthe", "Jadeth", "Jaden", "Kaerin", "Kaelan", "Kai", "Kei",
"Kaia", "Karina", "Katrin", "Correnne", "Kaja", "Kaedhwen", "Laia",
"Lacey", "Lanessa", "Laiwyth", "Liliene", "Lenwyth", "Layana", "Loriene",
"Lyllith", "Lya", "Lara", "Larissa", "Lark", "Laurel", "Lauren", "Leah",
"Lavonne", "Layla", "Lorwyn", "Maerin", "Marwyn", "Melwyn", "Melweth",
"Madalyn", "Madwyn", "Melian", "Morwen", "Morwyn", "Morwyth", "Milana",
"Miriel", "Mariel", "Marien", "Marina", "Cordelia", "Merwyn", "Naela",
"Narissa", "Nienwyn", "Nelina", "Nurina", "Nulwyth", "Olaina", "Oria",
"Ophelia", "Orana", "Paena", "Parwyn", "Paula", "Petra", "Phaeda",
"Phoebe", "Quiana", "Querida", "Rian", "Rhiannon", "Rhia", "Renae",
"Rhenwyn", "Rachel", "Raine", "Rae", "Rayen", "Rayna", "Rochelle",
"Rolaweth", "Salwen", "Saffron", "Safaya", "Sarawyn", "Serweth",
"Saerweth", "Shaywyn", "Sirena", "Siobhan", "Selena", "Siri", "Skyleigh",
"Sonia", "Sora", "Sorcha", "Selweth", "Siriel", "Sorana", "Taina",
"Talitha", "Telwyn", "Tirwyn", "Tienna", "Talia", "Tania", "Tara",
"Terana", "Hope", "Ulwyn", "Uinya", "Vala", "Vaira", "Varana", "Verwyn",
"Vulweth", "Wrena", "Walreth", "Winreth", "Winara", "Wranya", "Wynne",
"Xanrda", "Xanthe", "Xenia", "Yasania", "Yara", "Yorina", "Zaira",
"Zara"
});

private string *familyNames = ({
"Arthellyn", "Argalen", "Aelfan", "Aladain", "Eznaruin", "Ghandur",
"Eralkidh", "Hrondil", "Eolach", "Kirin", "Evendim", "Dalthren",
"Belathon", "Anduradan", "Belectar", "Marannuminas", "Gundil", "Denlap",
"Karendur", "Gundil", "Galdur", "Erator", "Aelgil", "Valamar",
"Endur", "Hador", "Urdhan", "Oeldhen", "Llenwych"
});

#endif
@@ -3,6 +3,7 @@
// the accompanying LICENSE file for details.
//*****************************************************************************
virtual inherit "/lib/dictionaries/domains/sub-dictionaries/core.c";
#include "henchman-names.h"

private mapping Modifiers = ([
"duration": ([
@@ -151,6 +152,53 @@ public nomask object getHenchmanFromData(mapping data, object user)
return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask string getName(string gender)
{
return (gender == "female") ? femaleNames[random(sizeof(femaleNames))] :
maleNames[random(sizeof(maleNames))];
}

/////////////////////////////////////////////////////////////////////////////
public nomask string getFamilyName()
{
return familyNames[random(sizeof(familyNames))];
}

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getRandomHenchman(string type, string rating, int cost,
int duration)
{
mapping ret = ([]);

string revisedType = type;
if (member(({ "engineer", "architect", "arcane craftsman", "blacksmith",
"carpenter", "stonemason" }), type) > -1)
{
revisedType = "craftsman";
}

if(isValidHenchmanType(revisedType) &&
(member(({ "apprentice", "journeyman", "master" }), rating) > -1))
{
string gender = (random(100) >= 50) ? "female": "male";

return ([
"name": getName(gender),
"house": getFamilyName(),
"gender": gender,
"type": revisedType,
"traits": ({ sprintf("lib/instances/traits/domains/%s-%s.c",
rating, type) }),
"cost": cost,
"duration": duration,
"persona": "swordsman",
"level": 5,
"activity": "idle"
]);
}
}

/////////////////////////////////////////////////////////////////////////////
public nomask string getBenefitLevel(object henchman, string type)
{
@@ -37,6 +37,7 @@ public nomask mapping getWorkersMenu(object user, string location,
"name": sprintf("Select %s", pluralizeValue(worker)),
"type": worker,
"quantity": componentData["construction"]["workers"][worker],
"duration": componentData["construction"]["duration"],
"description": "This option assigns workers to the task of "
"building the selected component.\n",
"is disabled": canSelectWorkers(componentData),
@@ -126,7 +127,7 @@ public nomask string getWorkersOfType(object user, string type,

/////////////////////////////////////////////////////////////////////////////
public nomask mapping getWorkersByTypeMenu(object user, string location,
string type, int confirmDisabled)
string type, int confirmDisabled, int duration, int currentCost)
{
mapping ret = ([]);

@@ -149,11 +150,35 @@ public nomask mapping getWorkersByTypeMenu(object user, string location,
"description": sprintf("This option assigns %s to the task of "
"building the selected component.\n", name),
"is disabled": henchmen[worker]->activity() != "idle",
"cost": henchmen[worker]->cost(),
"data": henchmen[worker],
"canShow": 1
]);
}
}
int cost = duration * 25;
ret[to_string(sizeof(ret) + 1)] = ([
"name": sprintf("Hire Apprentice ($%d)", cost),
"type": "hire apprentice",
"description": "This option hires a low-end contract worker in leiu "
"of a henchman\n",
"duration": duration,
"cost": cost,
"is disabled": user->Money() < (cost + currentCost),
"canShow": 1
]);

cost = duration * 225;
ret[to_string(sizeof(ret) + 1)] = ([
"name": sprintf("Hire %s ($%d)", generateTitle(type), cost),
"type": "hire journeyman",
"description": "This option hires a contract worker in leiu "
"of a henchman\n",
"duration": duration,
"cost": cost,
"is disabled": user->Money() < (cost + currentCost),
"canShow": 1
]);
ret[to_string(sizeof(ret) + 1)] = ([
"name": "Confirm Selections",
"type": "confirm",
@@ -106,14 +106,13 @@ public nomask string *getTitles()
}

/////////////////////////////////////////////////////////////////////////////
public nomask int addHenchman(string location, mapping data)
public nomask object addHenchman(string location, mapping data)
{
int ret = 0;
object ret = 0;
object dictionary = getDictionary("domain");

if (dictionary->isValidHenchman(data) && member(holdings, location))
{
ret = 1;
if (!member(henchmen, location))
{
henchmen[location] = ([]);
@@ -125,8 +124,21 @@ public nomask int addHenchman(string location, mapping data)
}

data["location"] = location;
henchmen[location][key] =
dictionary->getHenchmanFromData(data, this_object());
ret = dictionary->getHenchmanFromData(data, this_object());

henchmen[location][key] = ret;
}
return ret;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int removeHenchman(string location, string key)
{
int ret = 0;
if (member(henchmen, location) && member(henchmen[location], key))
{
m_delete(henchmen[location], key);
ret = 1;
}
return ret;
}
@@ -117,6 +117,7 @@ protected nomask int processSelection(string selection)
clone_object("/lib/modules/domains/workerSelector.c");
SubselectorObj->setWorkerType(Data[selection]["type"]);
SubselectorObj->setQuantityNeeded(Data[selection]["quantity"]);
SubselectorObj->setDuration(Data[selection]["duration"]);
SubselectorObj->setLocation(Location);

move_object(SubselectorObj, User);
@@ -7,6 +7,8 @@ inherit "/lib/core/baseSelector.c";
private string Location;
private string WorkerType;
private int QuantityNeeded;
private int Duration;
private int CurrentCost = 0;
private mapping Selections = ([]);

private object dictionary = load_object("/lib/dictionaries/domainDictionary.c");
@@ -27,6 +29,12 @@ public nomask void setQuantityNeeded(int quantity)
QuantityNeeded = quantity;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void setDuration(int duration)
{
Duration = duration;
}

/////////////////////////////////////////////////////////////////////////////
public nomask void setWorkerType(string type)
{
@@ -64,7 +72,7 @@ protected nomask void setUpUserForSelection()
QuantityNeeded, Selections);

Data = dictionary->getWorkersByTypeMenu(User, Location, WorkerType,
(QuantityNeeded - sizeof(Selections)) != 0);
(QuantityNeeded - sizeof(Selections)) != 0, Duration, CurrentCost);
}
}

@@ -80,7 +88,13 @@ protected nomask string additionalInstructions()
protected nomask string displayDetails(string choice)
{
string ret = sprintf("%7s", "");
if ((Data[choice]["type"] == "confirm") && Data[choice]["is disabled"])
if ((member(({ "hire apprentice", "hire journeyman" }),
Data[choice]["type"]) > -1) && Data[choice]["is disabled"])
{
ret = sprintf("%-7s", (User->colorConfiguration() == "none") ?
"low $" : "");
}
else if ((Data[choice]["type"] == "confirm") && Data[choice]["is disabled"])
{
ret = sprintf("%-7s", (User->colorConfiguration() == "none") ?
"N/A" : "");
@@ -117,6 +131,24 @@ protected string choiceFormatter(string choice)
Data[choice]["layout panel"] || "");
}

/////////////////////////////////////////////////////////////////////////////
private nomask void setupHireling(string type, string selection)
{
mapping workerData = dictionary->getRandomHenchman(
WorkerType, type, Data[selection]["cost"],
Data[selection]["duration"]);
CurrentCost += Data[selection]["cost"];

object worker = User->addHenchman(Location, workerData);

Selections[worker->Name() + " " + worker->Title()] = ([
"object": worker,
"benefits" : dictionary->getBenefits(User, worker,
WorkerType),
"level" : dictionary->getBenefitLevel(worker, WorkerType)
]);
}

/////////////////////////////////////////////////////////////////////////////
protected nomask int processSelection(string selection)
{
@@ -134,7 +166,17 @@ protected nomask int processSelection(string selection)
}
else if (!Data[selection]["is disabled"])
{
if (!member(Selections, Data[selection]["type"]) &&
if ((Data[selection]["type"] == "hire apprentice") &&
(QuantityNeeded > sizeof(Selections)))
{
setupHireling("apprentice", selection);
}
else if ((Data[selection]["type"] == "hire journeyman") &&
(QuantityNeeded > sizeof(Selections)))
{
setupHireling("journeyman", selection);
}
else if (!member(Selections, Data[selection]["type"]) &&
(QuantityNeeded > sizeof(Selections)))
{
object worker = Data[selection]["data"];
@@ -147,6 +189,11 @@ protected nomask int processSelection(string selection)
}
else
{
if (Data[selection]["cost"])
{
CurrentCost -= Data[selection]["cost"];
User->removeHenchman(Location, Data[selection]["name"]);
}
m_delete(Selections, Data[selection]["type"]);
}
setUpUserForSelection();

0 comments on commit fe7c1e2

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