From 759b9ffe3a50bc0a7aeaed53e3d6cb39967645c9 Mon Sep 17 00:00:00 2001 From: idhrendur Date: Wed, 11 Apr 2012 19:41:43 -0700 Subject: [PATCH] Initial stat conversion --- Data Files/Changelog.txt | 6 +++++- Source/CK2World/CK2Character.cpp | 29 +++++++++++++++++++++++++++++ Source/CK2World/CK2Character.h | 12 ++++++++++++ Source/EU3World/EU3Ruler.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index 56fca5556..29fff2e0b 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/Source/CK2World/CK2Character.cpp b/Source/CK2World/CK2Character.cpp index 3c9fcbe17..7300ac920 100644 --- a/Source/CK2World/CK2Character.cpp +++ b/Source/CK2World/CK2Character.cpp @@ -1,4 +1,5 @@ #include "CK2Character.h" +#include "..\log.h" @@ -17,6 +18,8 @@ CK2Character::CK2Character() mother = NULL; children.clear(); female = false; + + memset(stats, 0, sizeof(stats)); } @@ -68,6 +71,26 @@ void CK2Character::init(Object* obj, map& dynasties) { female = false; } + + vector attributesObj = obj->getValue("attributes"); + if (attributesObj.size() > 0) + { + vector 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; + } + } @@ -141,6 +164,12 @@ bool CK2Character::isFemale() } +int* CK2Character::getStats() +{ + return stats; +} + + CK2Character* CK2Character::getFather() { return father; diff --git a/Source/CK2World/CK2Character.h b/Source/CK2World/CK2Character.h index 9f7fc8da3..dc47c6ec6 100644 --- a/Source/CK2World/CK2Character.h +++ b/Source/CK2World/CK2Character.h @@ -23,6 +23,7 @@ class CK2Character bool isDead(); date getDeathDate(); bool isFemale(); + int* getStats(); CK2Character* getFather(); CK2Character* getPrimogenitureHeir(); private: @@ -34,6 +35,7 @@ class CK2Character bool dead; date deathDate; bool female; + int stats[5]; int fatherNum; CK2Character* father; @@ -43,6 +45,16 @@ class CK2Character }; +enum stats +{ + DIPLOMACY = 0, + MARTIAL, + STEWARDSHIP, + INTRIGUE, + LEARNING +}; + + diff --git a/Source/EU3World/EU3Ruler.cpp b/Source/EU3World/EU3Ruler.cpp index e1f72b1f5..1599e0967 100644 --- a/Source/EU3World/EU3Ruler.cpp +++ b/Source/EU3World/EU3Ruler.cpp @@ -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; + } }