Skip to content
Permalink
Browse files

Merged PR 555: 617_added_guild_rank_prereqs_to_buildings

Added guild rank prerequisites

Related Work Items: #617

Related work items: #617
  • Loading branch information...
realms-mud committed Aug 14, 2019
1 parent d93c205 commit 16a825158749d467b9375ca01836fb49158f3e14
@@ -42,6 +42,11 @@ protected mapping prerequisites = ([
// "type": "guild",
// "value": ({ "fighter" })
// ]),
// "guild rank": ([
// "type": "guild rank",
// "guild": "mage",
// "value": ({ "acolyte", "archmage" })
// ]),
// "best kill": ([
// "type": "combat statistic",
// "value": 45
@@ -69,7 +74,7 @@ private nomask int isValidPrerequisiteType(string type)
{
return (member(({ "research", "attribute", "skill", "quest", "guild",
"race", "faction", "trait", "background", "combat statistic", "level",
"opinion", "state", "presence", "not present" }), type) > -1);
"opinion", "state", "presence", "not present", "guild rank" }), type) > -1);
}

//-----------------------------------------------------------------------------
@@ -305,6 +310,14 @@ private nomask int checkGuilds(object researcher, string *guilds)
return ret;
}

/////////////////////////////////////////////////////////////////////////////
private nomask int checkGuildRanks(object researcher, string guild,
string *ranks)
{
return checkGuilds(researcher, ({ guild })) && pointerp(ranks) &&
(member(ranks, researcher->guildRank(guild)) > -1);
}

//-----------------------------------------------------------------------------
// Method: checkRaces
// Description: This method will check whether or not the passed researcher
@@ -530,6 +543,12 @@ public nomask varargs int checkPrerequisites(object researcher, string grouping,
ret &&= checkGuilds(researcher, prerequisiteData["value"]);
break;
}
case "guild rank":
{
ret &&= checkGuildRanks(researcher,
prerequisiteData["guild"], prerequisiteData["value"]);
break;
}
case "race":
{
ret &&= checkRaces(researcher, prerequisiteData["value"]);
@@ -702,6 +721,12 @@ public nomask string displayPrerequisites(string colorConfiguration,
prerequisites[key]["value"]);
break;
}
case "guild rank":
{
prereq = sprintf("Rank in the %s guild of ",
prerequisites[key]["guild"]);
// Yes, fall through!
}
case "guild":
case "race":
case "presence":
@@ -711,11 +736,19 @@ public nomask string displayPrerequisites(string colorConfiguration,
if (pointerp(prerequisites[key]["value"]) &&
sizeof(prerequisites[key]["value"]))
{
foreach(string value in prerequisites[key]["value"])
string *words = explode(implode(
prerequisites[key]["value"], " or "), " ");

int size = sizeof(words);
for (int i = 0; i < size; i++)
{
prereq += capitalize(value) + " or ";
if (words[i] != "or")
{
words[i] = capitalize(words[i]);
}
}
prereq = prereq[..(sizeof(prereq) - 5)];

prereq += implode(words, " ");
}
break;
}
@@ -5,12 +5,14 @@
#ifndef buildingComponents_h
#define buildingComponents_h

#include "buildings.h"
#include "stone-keep-components.h"
#include "tower-components.h"
#include "wall-components.h"
#include "wooden-keep-components.h"

protected mapping BuildingComponents = StoneKeepComponents +
protected mapping BuildingComponents = BuildingBlueprints +
StoneKeepComponents +
WoodenKeepComponents +
WallComponents +
TowerComponents + ([]);
@@ -215,9 +215,33 @@ protected mapping BuildingBlueprints = ([
"aegis guard": 10,
]),
"building prerequisites": ([
"phaedra":(["type":"trait", "value": ({
"/lib/instances/traits/personas/fighter/aegis.c", })
]),
"aegis":(["type":"guild", "value" : ({ "aegis" }) ]),
"stonemasonry": (["type":"skill", "value": 5]),
"carpentry": (["type":"skill", "value": 5]),
"wood crafting": (["type":"skill", "value": 5]),
"engineering": (["type":"skill", "value": 5]),
"sewing": (["type":"skill", "value": 2]),
]),
"building materials": ([
"stone": 100,
"wood": 150,
"metal": 15,
"textile": 5,
]),
"added duration": 300,
"structure": 300,
]),

"scion of dhuras outpost": ([
"class": "military floorplan",
"description": "",
"experience modifier": 1.1,
"default units": ([
"henchman": 1,
"scion of dhuras": 10,
]),
"building prerequisites": ([
"scion of dhuras": (["type":"guild", "value" : ({ "scion of dhuras" })]),
"stonemasonry": (["type":"skill", "value": 5]),
"carpentry": (["type":"skill", "value": 5]),
"wood crafting": (["type":"skill", "value": 5]),
@@ -379,22 +403,38 @@ protected mapping BuildingBlueprints = ([
"workshop":([
"type": "craftsman's floorplan",
"description": "",
"effects": ([
]),
"upgrades": ([
"default units": ([
"henchman": 3,
]),
"colors": ([
"default":([
"3-bit": "\x1b[0;31m",
"8-bit": "\x1b[0;38;5;9m",
"24-bit": "\x1b[0;38;2;200;0;0m"
"effects": ([
"craft seige equipment":([
"action": "craft seige equipment",
"duration bonus": 10,
"quantity bonus": 10,
]),
"workshop research": ([
"duration bonus": 10,
"apply": "1 every 12 hours",
"type" : ({ "domains", "crafting" })
])
]),
"icon":([
"ascii": "",
"unicode": "",
"building prerequisites": ([
"stonemasonry": (["type":"skill", "value": 5]),
"carpentry": (["type":"skill", "value": 5]),
"wood crafting": (["type":"skill", "value": 5]),
"engineering": (["type":"skill", "value": 5]),
"sewing": (["type":"skill", "value": 2]),
]),
"building materials": ([
"stone": 100,
"wood": 150,
"metal": 15,
"textile": 5,
]),
"added duration": 300,
"structure": 300,
]),

"carpenter":([
"type": "craftsman's floorplan",
"description": "",
@@ -116,6 +116,31 @@ void CheckPrerequsistesCorrectlyHandlesGuildChecks()
ExpectTrue(Prerequisite->checkPrerequisites(Researcher), "check succeeds when guild set");
}

/////////////////////////////////////////////////////////////////////////////
void CheckPrerequsistesCorrectlyHandlesGuildRankChecks()
{
Researcher->ToggleMockGuilds();
ExpectTrue(Prerequisite->AddTestPrerequisite("guild rank",
(["type": "guild rank", "guild": "mage", "value" : ({ "adept", "archmage" })])));

ExpectFalse(Prerequisite->checkPrerequisites(Researcher), "check initially fails");

Researcher->SetGuild("fighter");
ExpectFalse(Prerequisite->checkPrerequisites(Researcher), "check fails when wrong guild set");

Researcher->SetGuild("mage");
ExpectFalse(Prerequisite->checkPrerequisites(Researcher), "check fails when correct guild set");

Researcher->SetRank("acolyte");
ExpectFalse(Prerequisite->checkPrerequisites(Researcher), "check fails when wrong rank set");

Researcher->SetRank("adept");
ExpectTrue(Prerequisite->checkPrerequisites(Researcher), "check succeeds when valid rank set");

Researcher->SetRank("archmage");
ExpectTrue(Prerequisite->checkPrerequisites(Researcher));
}

/////////////////////////////////////////////////////////////////////////////
void CheckPrerequsistesCorrectlyHandlesRaceChecks()
{
@@ -394,7 +419,7 @@ void DisplayPrerequisitesCorrectlyDisplaysRacePrerequisites()
"type":"race", "value" : ({ "elf", "half-elf", "high elf" }) ])));

ExpectEq("\x1b[0;36mPrerequisites:\n\x1b[0m"
"\x1b[0;33m Race: \x1b[0m\x1b[0;35mElf or Half-elf or High elf\n\x1b[0m",
"\x1b[0;33m Race: \x1b[0m\x1b[0;35mElf or Half-elf or High Elf\n\x1b[0m",
Prerequisite->displayPrerequisites(colorConfiguration, Configuration));
}

@@ -408,13 +433,24 @@ void DisplayPrerequisitesCorrectlyDisplaysGuildPrerequisites()
Prerequisite->displayPrerequisites(colorConfiguration, Configuration));
}

/////////////////////////////////////////////////////////////////////////////
void DisplayPrerequisitesCorrectlyDisplaysGuildRankPrerequisites()
{
ExpectTrue(Prerequisite->AddTestPrerequisite("guild rank",
(["type":"guild rank", "guild" : "mage", "value" : ({ "adept", "archmage" })])));

ExpectEq("\x1b[0;36mPrerequisites:\n\x1b[0m\x1b[0;33m Guild rank: "
"\x1b[0m\x1b[0;35mRank in the mage guild of Adept or Archmage\n\x1b[0m",
Prerequisite->displayPrerequisites(colorConfiguration, Configuration));
}

/////////////////////////////////////////////////////////////////////////////
void DisplayPrerequisitesCorrectlyDisplaysFactionPrerequisites()
{
ExpectTrue(Prerequisite->AddTestPrerequisite("faction", ([
"type":"faction", "value": ({ "Llama lords" })])));
"type":"faction", "value": ({ "llama lords" })])));

ExpectEq("\x1b[0;36mPrerequisites:\n\x1b[0m\x1b[0;33m Faction: \x1b[0m\x1b[0;35mLlama lords\n\x1b[0m",
ExpectEq("\x1b[0;36mPrerequisites:\n\x1b[0m\x1b[0;33m Faction: \x1b[0m\x1b[0;35mLlama Lords\n\x1b[0m",
Prerequisite->displayPrerequisites(colorConfiguration, Configuration));
}

@@ -9,6 +9,7 @@ private string guild = "";
private int level = 0;
private int experience = 0;
private object guildObj = 0;
private string rank = "";

/////////////////////////////////////////////////////////////////////////////
public void ToggleMockGuilds()
@@ -35,6 +36,12 @@ public void SetLevel(int newLevel)
level = newLevel;
}

/////////////////////////////////////////////////////////////////////////////
public void SetRank(string newRank)
{
rank = newRank;
}

/////////////////////////////////////////////////////////////////////////////
public void SetExperience(int exp)
{
@@ -66,6 +73,12 @@ public nomask int guildLevel(string check)
return (guild == check) ? level : 0;
}

/////////////////////////////////////////////////////////////////////////////
public nomask string guildRank(string check)
{
return (guild == check) ? rank : 0;
}

/////////////////////////////////////////////////////////////////////////////
public nomask int guildExperience(string check)
{
@@ -100,4 +113,3 @@ public nomask int costToAdvanceSkill(string skillType)
{
return guildObj ? guildObj->costToAdvanceSkillOfType(skillType) : 2;
}

0 comments on commit 16a8251

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