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

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunt authored and Gunt committed Apr 11, 2012
2 parents 49d3bb1 + 451cf3c commit 2da62a2
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 9 deletions.
52 changes: 50 additions & 2 deletions Source/CK2World/CK2Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@



CK2Character::CK2Character()
{
name = "";
religion = "";
culture = "";
dynasty = NULL;
birthDate = (string)"1.1.1";
dead = true;
deathDate = (string)"1.1.1";
fatherNum = -1;
father = NULL;
motherNum = -1;
mother = NULL;
children.clear();
female = false;
}


void CK2Character::init(Object* obj, map<int, CK2Dynasty*>& dynasties)
{
name = obj->getLeaf("birth_name");
Expand Down Expand Up @@ -32,11 +50,23 @@ void CK2Character::init(Object* obj, map<int, CK2Dynasty*>& dynasties)
vector<Object*> deathObj = obj->getValue("death_date");
if (deathObj.size() > 0)
{
dead = true;
dead = true;
deathDate = deathObj[0]->getLeaf();
}
else
{
dead = false;
dead = false;
deathDate = (string)"1.1.1";
}

vector<Object*> femaleObj = obj->getValue("female");
if (femaleObj.size() > 0)
{
female = ( femaleObj[0]->getLeaf() == "yes" );
}
else
{
female = false;
}
}

Expand Down Expand Up @@ -99,6 +129,24 @@ bool CK2Character::isDead()
}


date CK2Character::getDeathDate()
{
return deathDate;
}


bool CK2Character::isFemale()
{
return female;
}


CK2Character* CK2Character::getFather()
{
return father;
}


CK2Character* CK2Character::getPrimogenitureHeir()
{
for (list<CK2Character*>::iterator i = children.begin(); i != children.end(); i++)
Expand Down
6 changes: 6 additions & 0 deletions Source/CK2World/CK2Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ using namespace std;
class CK2Character
{
public:
CK2Character();
void init(Object*, map<int, CK2Dynasty*>&);
string getName();
CK2Dynasty* getDynasty();
date getBirthDate();
void setParents(map<int, CK2Character*>&);
void addChild(CK2Character*);
bool isDead();
date getDeathDate();
bool isFemale();
CK2Character* getFather();
CK2Character* getPrimogenitureHeir();
private:
string name;
Expand All @@ -28,6 +32,8 @@ class CK2Character
CK2Dynasty* dynasty;
date birthDate;
bool dead;
date deathDate;
bool female;

int fatherNum;
CK2Character* father;
Expand Down
13 changes: 12 additions & 1 deletion Source/CK2World/CK2Title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ void CK2Title::init(Object* obj, map<int, CK2Character*>& characters)
{
holder = characters[ atoi( holderObjs[0]->getLeaf().c_str() ) ];
}

heir = NULL;
successionLaw = obj->getLeaf("succession");
if (successionLaw == "primogeniture")
{
heir = holder->getPrimogenitureHeir();
CK2Character* tempHolder = holder;
do
{
heir = tempHolder->getPrimogenitureHeir();
tempHolder = tempHolder->getFather();
if (tempHolder == NULL)
{
break;
}
} while (heir == NULL);
}

vector<Object*> historyObjs = obj->getValue("history");
Expand Down
4 changes: 4 additions & 0 deletions Source/EU3World/EU3Country.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ void EU3Country::output(FILE* output)
{
fprintf(output, " government=%s\n", government.c_str());
}
else
{
fprintf(output, " government=tribal_despotism\n");
}
if (monarch != NULL)
{
fprintf(output, " monarch=\n");
Expand Down
6 changes: 2 additions & 4 deletions Source/EU3World/EU3History.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ void EU3History::output(FILE* output)
fprintf(output, " {\n");
if (monarch != NULL)
{
fprintf(output," monarch=\n");
monarch->output(output);
monarch->outputAsMonarch(output);
}
if (heir != NULL)
{
fprintf(output," heir=\n");
heir->output(output);
heir->outputAsHeir(output);
}
fprintf(output, " }\n");
}
Expand Down
87 changes: 86 additions & 1 deletion Source/EU3World/EU3Ruler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,56 @@ EU3Ruler::EU3Ruler(Object* obj)
{
dynasty = "blank";
}

vector<Object*> birthdateObjs = obj->getValue("birth_Date");
if (birthdateObjs.size() > 0)
{
birthDate = birthdateObjs[0]->getLeaf();
}
else
{
birthDate = (string)"1.1.1";
}

vector<Object*> deathdateObjs = obj->getValue("death_Date");
if (deathdateObjs.size() > 0)
{
deathDate = deathdateObjs[0]->getLeaf();
}
else
{
deathDate = (string)"1.1.1";
}

vector<Object*> claimObjs = obj->getValue("claim");
if (claimObjs.size() > 0)
{
claim = atoi( claimObjs[0]->getLeaf().c_str() );
}
else
{
claim = 100;
}

vector<Object*> monarchNameObjs = obj->getValue("monarch_name");
if (monarchNameObjs.size() > 0)
{
monarchName = monarchNameObjs[0]->getLeaf();
}
else
{
monarchName = "";
}

vector<Object*> femaleObjs = obj->getValue("female");
if (femaleObjs.size() > 0)
{
female = (femaleObjs[0]->getLeaf() == "yes");
}
else
{
female = false;
}
}


Expand All @@ -81,6 +131,10 @@ EU3Ruler::EU3Ruler(CK2Character* src)
id = Configuration::getID();
dynasty = "blank";
birthDate = src->getBirthDate();
deathDate = src->getDeathDate();
claim = 100;
monarchName = "";
female = src->isFemale();

name = src->getName();
CK2Dynasty* dynPointer = src->getDynasty();
Expand All @@ -95,20 +149,51 @@ EU3Ruler::EU3Ruler(CK2Character* src)
}


void EU3Ruler::output(FILE* output)
void EU3Ruler::outputAsMonarch(FILE* output)
{
fprintf(output," monarch=\n");
fprintf(output," {\n");
fprintf(output," name=\"%s\"\n", name.c_str());
fprintf(output," DIP=%d\n", diplomacy);
fprintf(output," ADM=%d\n", administration);
fprintf(output," MIL=%d\n", military);
if (female)
{
fprintf(output, " female=yes\n");
}
fprintf(output," id=\n");
fprintf(output," {\n");
fprintf(output," id=%d\n", id);
fprintf(output," type=37\n");
fprintf(output," }\n");
fprintf(output," dynasty=\"%s\"\n", dynasty.c_str());
fprintf(output," birth_date=\"%d.%d.%d\"\n", birthDate.year, birthDate.month, birthDate.day);
fprintf(output," }\n");
}


void EU3Ruler::outputAsHeir(FILE* output)
{
fprintf(output," heir=\n");
fprintf(output," {\n");
fprintf(output," name=\"%s\"\n", name.c_str());
fprintf(output," DIP=%d\n", diplomacy);
fprintf(output," ADM=%d\n", administration);
fprintf(output," MIL=%d\n", military);
if (female)
{
fprintf(output, " female=yes\n");
}
fprintf(output," id=\n");
fprintf(output," {\n");
fprintf(output," id=%d\n", id);
fprintf(output," type=37\n");
fprintf(output," }\n");
fprintf(output," dynasty=\"%s\"\n", dynasty.c_str());
fprintf(output," birth_date=\"%d.%d.%d\"\n", birthDate.year, birthDate.month, birthDate.day);
fprintf(output," death_date=\"%d.%d.%d\"\n", deathDate.year, deathDate.month, deathDate.day);
fprintf(output," claim=%d\n", claim);
fprintf(output," monarch_name=\"%s\"\n", monarchName.c_str());
fprintf(output," }\n");
}

Expand Down
7 changes: 6 additions & 1 deletion Source/EU3World/EU3Ruler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class EU3Ruler
EU3Ruler(string name, int dip, int adm, int mil, string dynasty);
EU3Ruler(CK2Character*);
EU3Ruler(Object*);
void output(FILE*);
void outputAsMonarch(FILE*);
void outputAsHeir(FILE*);
int getID();
date getBirthDate();
private:
Expand All @@ -26,6 +27,10 @@ class EU3Ruler
int id;
string dynasty;
date birthDate;
date deathDate;
int claim;
string monarchName;
bool female;
};


Expand Down

0 comments on commit 2da62a2

Please sign in to comment.