Пример #1
0
void CK2Character::setEmployer(map<int, CK2Character*>& characters, map<string, CK2Barony*>& baronies)
{
	if ( (hostNum != -1) && (jobType != NONE) )
	{
		CK2Character* employer = characters[hostNum];
		if (employer != NULL)
		{
			characters[hostNum]->addAdvisor(this, jobType);
		}
		else
		{
			log("%s %s has an invalid employer. (%d)\n", name.c_str(), dynasty->getName().c_str(), hostNum);
		}
	}

	if (hostNum != -1)
	{
		CK2Character* host = characters[employerNum];
		if (host != NULL)
		{
			string hostCapitalString = host->getCapitalString();
			map<string, CK2Barony*>::iterator itr = baronies.find(hostCapitalString);
			if (itr != baronies.end())
			{
				CK2Barony* homeBarony = itr->second;
				if (homeBarony != NULL)
				{
					locationNum = homeBarony->getProvince()->getNumber();
				}
			}
		}
	}
}
EU3History::EU3History(CK2History* src)
{
	when = src->getWhen();

	monarch	= NULL;
	regent	= NULL;
	heir		= NULL;
	advisor	= NULL;

	CK2Character* holder = src->getHolder();
	if (holder != NULL)
	{
		CK2Character* CK2Regent = holder->getRegent();
		if (CK2Regent != NULL)
		{
			regent	= new EU3Ruler(CK2Regent);
			heir		= new EU3Ruler(holder);
		}
		else
		{
			monarch = new EU3Ruler(holder);
		}
	}
	capital			= "";
	tradeGood		= "";
	baseTax			= 0.0f;
	population		= 0.0;
	manpower			= 0;
	owner				= "";
	government		= "";
	culture			= "";
	religion			= "";
	primaryCulture	= "";
	techGroup		= "";
	acceptedCultures.clear();
	discoverers.clear();
	shogunPower		= -1.0f;
}
Пример #3
0
void CK2Character::setStateStats()
{
	// start with regent's stats or mine
	if (regent != NULL)
		memcpy(stateStats, regent->getStats(), 5*sizeof(int));
	else
		memcpy(stateStats, stats, 5*sizeof(int));

	// add 1/2 of primary spouse's stats
	CK2Character* spouse = getPrimarySpouse();
	if (spouse != NULL)
	{
		for (int i = 0; i < 5; ++i)
			stateStats[i] += spouse->getStats()[i] / 2;
	}

	// add relevant advisors
	for (int i = 0; i < 5; ++i)
	{
		if (advisors[i] != NULL)
			stateStats[i] += advisors[i]->getStats()[i];
	}
}
void CK2Title::determineHeir(map<int, std::shared_ptr<CK2Character>>& characters)
{
	if (holder != NULL)
	{
		if (successionLaw == "primogeniture")
		{
			CK2Character* tempHolder = holder;
			do
			{
				heir = tempHolder->getPrimogenitureHeir(genderLaw, holder);
				tempHolder = tempHolder->getFather();
				if (tempHolder == NULL)
				{
					break;
				}
			} while (heir == NULL);
		}
		else if (successionLaw == "ultimogeniture")
		{
			CK2Character* tempHolder = holder;
			do
			{
				heir = tempHolder->getUltimogenitureHeir(genderLaw, holder);
				tempHolder = tempHolder->getFather();
				if (tempHolder == NULL)
				{
					break;
				}
			} while (heir == NULL);
		}
		else if (successionLaw == "gavelkind")
		{
			if(heir == NULL) // if the heir is not null, we've already set this
			{
				holder->setGavelkindHeirs(genderLaw);
			}
		}
		else if (successionLaw == "seniority")
		{
			heir = holder->getDynasty()->getSenoirityHeir(genderLaw);
		}
		else if ( (successionLaw == "feudal_elective") || (successionLaw == "tanistry") )
		{
			heir = getElectiveHeir(characters);
		}
		else if (successionLaw == "turkish_succession")
		{
			heir = getTurkishSuccessionHeir();
		}
	}
}
CK2Character* CK2Title::getTurkishSuccessionHeir()
{
	vector<CK2Character*> potentialHeirs;
	potentialHeirs.clear();
	CK2Character* tempHolder = holder;
	do
	{
		potentialHeirs = tempHolder->getPotentialOpenHeirs(genderLaw, holder);
		tempHolder = tempHolder->getFather();
		if (tempHolder == NULL)
		{
			break;
		}
	} while (potentialHeirs.size() == 0);

	int largestDemesne = 0;
	for (vector<CK2Character*>::iterator i = potentialHeirs.begin(); i != potentialHeirs.end(); i++)
	{
		vector<CK2Title*> titles = (*i)->getTitles();
		int demesne = 0;
		for (vector<CK2Title*>::iterator j = titles.begin(); j != titles.end(); j++)
		{
			if ( (*j)->getTitleString().substr(0, 2) == "k_" )
			{
				demesne++;
			}
		}
		if (demesne > largestDemesne)
		{
			heir = *i;
			largestDemesne = demesne;
		}
	}

	if (heir == NULL)
	{
		for (vector<CK2Character*>::iterator i = potentialHeirs.begin(); i != potentialHeirs.end(); i++)
		{
			vector<CK2Title*> titles = (*i)->getTitles();
			int demesne = 0;
			for (vector<CK2Title*>::iterator j = titles.begin(); j != titles.end(); j++)
			{
				if ( (*j)->getTitleString().substr(0, 2) == "d_" )
				{
					demesne++;
				}
			}
			if (demesne > largestDemesne)
			{
				heir = *i;
				largestDemesne = demesne;
			}
		}
	}

	if (heir == NULL)
	{
		for (vector<CK2Character*>::iterator i = potentialHeirs.begin(); i != potentialHeirs.end(); i++)
		{
			vector<CK2Title*> titles = (*i)->getTitles();
			int demesne = 0;
			for (vector<CK2Title*>::iterator j = titles.begin(); j != titles.end(); j++)
			{
				if ( (*j)->getTitleString().substr(0, 2) == "c_" )
				{
					demesne++;
				}
			}
			if (demesne > largestDemesne)
			{
				heir = *i;
				largestDemesne = demesne;
			}
		}
	}

	if (heir == NULL)
	{
		for (vector<CK2Character*>::iterator i = potentialHeirs.begin(); i != potentialHeirs.end(); i++)
		{
			vector<CK2Title*> titles = (*i)->getTitles();
			int demesne = 0;
			for (vector<CK2Title*>::iterator j = titles.begin(); j != titles.end(); j++)
			{
				if ( (*j)->getTitleString().substr(0, 2) == "b_" )
				{
					demesne++;
				}
			}
			if (demesne > largestDemesne)
			{
				heir = *i;
				largestDemesne = demesne;
			}
		}
	}

	if ( (heir == NULL) && (potentialHeirs.size() > 0) )
	{
		heir = potentialHeirs[0];
	}

	return heir;
}
Пример #6
0
void CK2Character::setGavelkindHeirs(string genderLaw)
{
	vector<CK2Character*> heirs;
	CK2Character* tempHolder = this;
	do
	{
			heirs = tempHolder->getGavelkindHeirs(genderLaw);
			tempHolder = tempHolder->getFather();
			if (tempHolder == NULL)
			{
				break;
			}
	} while (heirs.size() <= 0);
	if (heirs.size() <= 0)
	{
		return;
	}

	vector<CK2Title*>	empireTitles;
	vector<CK2Title*>	kingdomTitles;
	vector<CK2Title*>	duchyTitles;
	vector<CK2Title*>	countyTitles;
	vector<CK2Title*>	baronyTitles;
	for (vector<CK2Title*>::iterator i = titles.begin(); i != titles.end(); i++)
	{
		if ( (*i)->getSuccessionLaw() == "gavelkind")
		{
			string titleString = (*i)->getTitleString();
			if ( titleString.substr(0, 2) == "e_")
			{
				empireTitles.push_back(*i);
			}
			else if ( titleString.substr(0, 2) == "k_")
			{
				kingdomTitles.push_back(*i);
			}
			else if ( titleString.substr(0, 2) == "d_")
			{
				duchyTitles.push_back(*i);
			}
			else if ( titleString.substr(0, 2) == "c_")
			{
				countyTitles.push_back(*i);
			}
			else if ( titleString.substr(0, 2) == "b_")
			{
				baronyTitles.push_back(*i);
			}
		}
	}

	vector<CK2Character*>::iterator heirItr = heirs.begin();
	for (vector<CK2Title*>::iterator i = empireTitles.begin(); i != empireTitles.end(); i++)
	{
		if (heirItr == heirs.end())
		{
			heirItr = heirs.begin();
		}

		(*i)->setHeir(*heirItr);
		heirItr++;
	}

	heirItr = heirs.begin();
	for (vector<CK2Title*>::iterator i = kingdomTitles.begin(); i != kingdomTitles.end(); i++)
	{
		if (heirItr == heirs.end())
		{
			heirItr = heirs.begin();
		}

		(*i)->setHeir(*heirItr);
		heirItr++;
	}

	heirItr = heirs.begin();
	for (vector<CK2Title*>::iterator i = duchyTitles.begin(); i != duchyTitles.end(); i++)
	{
		if (heirItr == heirs.end())
		{
			heirItr = heirs.begin();
		}

		(*i)->setHeir(*heirItr);
		heirItr++;
	}

	heirItr = heirs.begin();
	for (vector<CK2Title*>::iterator i = countyTitles.begin(); i != countyTitles.end(); i++)
	{
		if (heirItr == heirs.end())
		{
			heirItr = heirs.begin();
		}

		(*i)->setHeir(*heirItr);
		heirItr++;
	}

	heirItr = heirs.begin();
	for (vector<CK2Title*>::iterator i = baronyTitles.begin(); i != baronyTitles.end(); i++)
	{
		if (heirItr == heirs.end())
		{
			heirItr = heirs.begin();
		}

		(*i)->setHeir(*heirItr);
		heirItr++;
	}
}
Пример #7
0
int CK2Character::getDemesneCap(CK2Version& version) const
{
	// http://forum.paradoxplaza.com/forum/showthread.php?584969-What-are-the-high-and-low-bound-demense-limits-for-different-ranks-authority-tech&p=13429280&viewfull=1#post13429280

	int rulerTier = 0;
	if (primaryTitleString.substr(0, 2) == "b_")
		rulerTier = 1;
	else if (primaryTitleString.substr(0, 2) == "c_")
		rulerTier = 2;
	else if (primaryTitleString.substr(0, 2) == "d_")
		rulerTier = 3;
	else if (primaryTitleString.substr(0, 2) == "k_")
		rulerTier = 4;
	else if (primaryTitleString.substr(0, 2) == "e_")
		rulerTier = 5;
	if (rulerTier == 0) // not a ruler - no demesne
		return 0;

	double stewardshipBonus = stats[STEWARDSHIP];
	CK2Character* spouse = getPrimarySpouse();
	if (spouse)
		stewardshipBonus += floor(spouse->getStats()[STEWARDSHIP] / 2.0);
	stewardshipBonus /= 4.0;

	double successionFactor = 1.0;
	if (primaryTitle->getSuccessionLaw() == "gavelkind")
		successionFactor = 1.3;

	int legalismBonus = 0;
	double legalismTech;
	if (CK2Version("1.10") > version)
	{
		legalismTech = capital->getTechLevels()[TECH_LEGALISM_OLD];
	}
	else
	{
		legalismTech = capital->getTechLevels()[TECH_LEGALISM];
	}
	if (legalismTech >= 1.0)
	{
		if (rulerTier >= 2)
			legalismBonus++;
	}
	if (legalismTech >= 2.0)
	{
		if (rulerTier == 1 || rulerTier >= 3)
			legalismBonus++;
	}
	if (legalismTech >= 3.0)
	{
		if (rulerTier == 2 || rulerTier >= 4)
			legalismBonus++;
	}
	if (legalismTech >= 4.0)
	{
		if (rulerTier >= 3)
			legalismBonus++;
	}
	if (legalismTech >= 5.0)
	{
		if (rulerTier == 5)
			legalismBonus++;
	}
	
	return (int)(floor( (rulerTier + stewardshipBonus) * successionFactor) + legalismBonus);
}