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

Commit

Permalink
Initial stat conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Idhrendur committed Apr 12, 2012
1 parent 451cf3c commit 759b9ff
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Data Files/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ Revision Log Message
57 Primogeniture heirs
58 More character information
59 Temporary government of tribal despotism
60 Search up the family tree for primogeniture heirs if needed
60 Search up the family tree for primogeniture heirs if needed
61 Eastern Europe mapped. All mappings (dirty) done.
62 Merge
63 greece & turkey
64 Initial stat conversion
29 changes: 29 additions & 0 deletions Source/CK2World/CK2Character.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "CK2Character.h"
#include "..\log.h"



Expand All @@ -17,6 +18,8 @@ CK2Character::CK2Character()
mother = NULL;
children.clear();
female = false;

memset(stats, 0, sizeof(stats));
}


Expand Down Expand Up @@ -68,6 +71,26 @@ void CK2Character::init(Object* obj, map<int, CK2Dynasty*>& dynasties)
{
female = false;
}

vector<Object*> attributesObj = obj->getValue("attributes");
if (attributesObj.size() > 0)
{
vector<string> attributeTokens = attributesObj[0]->getTokens();
stats[DIPLOMACY] = atoi( attributeTokens[0].c_str() );
stats[MARTIAL] = atoi( attributeTokens[1].c_str() );
stats[STEWARDSHIP] = atoi( attributeTokens[2].c_str() );
stats[INTRIGUE] = atoi( attributeTokens[3].c_str() );
stats[LEARNING] = atoi( attributeTokens[4].c_str() );
}
else
{
stats[DIPLOMACY] = 0;
stats[MARTIAL] = 0;
stats[STEWARDSHIP] = 0;
stats[INTRIGUE] = 0;
stats[LEARNING] = 0;
}

}


Expand Down Expand Up @@ -141,6 +164,12 @@ bool CK2Character::isFemale()
}


int* CK2Character::getStats()
{
return stats;
}


CK2Character* CK2Character::getFather()
{
return father;
Expand Down
12 changes: 12 additions & 0 deletions Source/CK2World/CK2Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CK2Character
bool isDead();
date getDeathDate();
bool isFemale();
int* getStats();
CK2Character* getFather();
CK2Character* getPrimogenitureHeir();
private:
Expand All @@ -34,6 +35,7 @@ class CK2Character
bool dead;
date deathDate;
bool female;
int stats[5];

int fatherNum;
CK2Character* father;
Expand All @@ -43,6 +45,16 @@ class CK2Character
};


enum stats
{
DIPLOMACY = 0,
MARTIAL,
STEWARDSHIP,
INTRIGUE,
LEARNING
};





Expand Down
29 changes: 29 additions & 0 deletions Source/EU3World/EU3Ruler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,35 @@ EU3Ruler::EU3Ruler(CK2Character* src)
{
log("Error: %s does not have a dynasty!\n", name.c_str());
}

int* stats = src->getStats();
int bonus = ( stats[INTRIGUE] + stats[LEARNING] ) / (3 * 3);
diplomacy = stats[DIPLOMACY] / 3 + bonus;
administration = stats[STEWARDSHIP] / 3 + bonus;
military = stats[MARTIAL] /3 + bonus;

int leftover = ( stats[INTRIGUE] + stats[LEARNING] ) % (3 * 3);
leftover += stats[DIPLOMACY] % 3;
leftover += stats[STEWARDSHIP] % 3;
leftover += stats[MARTIAL] % 3;

diplomacy += leftover / (3 * 3);
administration += leftover / (3 * 3);
military += leftover / (3 * 3);
leftover %= (3 * 3);

if ( (diplomacy >= administration) && (diplomacy >= military) )
{
diplomacy += leftover / 3;
}
else if (administration >= military)
{
administration += leftover / 3;
}
else
{
military += leftover / 3;
}
}


Expand Down

0 comments on commit 759b9ff

Please sign in to comment.