Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Commit

Permalink
Gender laws
Browse files Browse the repository at this point in the history
  • Loading branch information
Idhrendur committed Apr 12, 2012
1 parent 759b9ff commit 695d23c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Data Files/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ Revision Log Message
61 Eastern Europe mapped. All mappings (dirty) done.
62 Merge
63 greece & turkey
64 Initial stat conversion
64 Initial stat conversion
65 Gender laws
15 changes: 10 additions & 5 deletions Source/CK2World/CK2Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,25 @@ CK2Character* CK2Character::getFather()
}


CK2Character* CK2Character::getPrimogenitureHeir()
CK2Character* CK2Character::getPrimogenitureHeir(string genderLaw)
{
for (list<CK2Character*>::iterator i = children.begin(); i != children.end(); i++)
{
if ( !(*i)->isDead() )
if ( ( !(*i)->isDead() ) &&
( !(*i)->isFemale() || (genderLaw == "true_cognatic") )
)
{
return *i;
}
else
{
CK2Character* possibleHeir = (*i)->getPrimogenitureHeir();
if (possibleHeir != NULL)
if ( !(*i)->isFemale() || (genderLaw == "true_cognatic") || (genderLaw == "cognatic") )
{
return possibleHeir;
CK2Character* possibleHeir = (*i)->getPrimogenitureHeir(genderLaw);
if (possibleHeir != NULL)
{
return possibleHeir;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/CK2World/CK2Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CK2Character
bool isFemale();
int* getStats();
CK2Character* getFather();
CK2Character* getPrimogenitureHeir();
CK2Character* getPrimogenitureHeir(string);
private:
string name;
string religion;
Expand Down
19 changes: 18 additions & 1 deletion Source/CK2World/CK2Title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,37 @@ void CK2Title::init(Object* obj, map<int, CK2Character*>& characters)
}

heir = NULL;
genderLaw = obj->getLeaf("gender");
successionLaw = obj->getLeaf("succession");
if (successionLaw == "primogeniture")
{
CK2Character* tempHolder = holder;
do
{
heir = tempHolder->getPrimogenitureHeir();
heir = tempHolder->getPrimogenitureHeir(genderLaw);
tempHolder = tempHolder->getFather();
if (tempHolder == NULL)
{
break;
}
} while (heir == NULL);
}
else if (successionLaw == "gavelkind")
{
heir = NULL;
}
else if (successionLaw == "seniority")
{
heir = NULL;
}
else if (successionLaw == "feudal_elective")
{
heir = NULL;
}
else if (successionLaw == "turkish_succession")
{
heir = NULL;
}

vector<Object*> historyObjs = obj->getValue("history");
if (historyObjs.size() > 0)
Expand Down
1 change: 1 addition & 0 deletions Source/CK2World/CK2Title.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CK2Title
CK2Character* holder;
CK2Character* heir;
string successionLaw;
string genderLaw;
vector<CK2History*> history;
string liegeString;
CK2Title* liege;
Expand Down

0 comments on commit 695d23c

Please sign in to comment.