Bazaar developer reference

CvReligionAI::ChooseReformationBelief(PlayerTypes, ReligionTypes)

Defined in
CvReligionClasses.cpp, line 5290
Class
CvReligionAI
Hook name
CivHooks::CvReligionAI_ChooseReformationBelief

Hooks

static bool BeforeCvReligionAI_ChooseReformationBelief(CvReligionAI* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes& result);static void AfterCvReligionAI_ChooseReformationBelief(CvReligionAI* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes& result);static BeliefTypes ReplaceCvReligionAI_ChooseReformationBelief(BeliefTypes (*original)(CvReligionAI*, PlayerTypes, ReligionTypes), CvReligionAI* self, PlayerTypes ePlayer, ReligionTypes eReligion);CivRegisterBefore<CivHooks::CvReligionAI_ChooseReformationBelief>(host, &BeforeCvReligionAI_ChooseReformationBelief);CivRegisterAfter<CivHooks::CvReligionAI_ChooseReformationBelief>(host, &AfterCvReligionAI_ChooseReformationBelief);CivRegisterReplace<CivHooks::CvReligionAI_ChooseReformationBelief>(host, &ReplaceCvReligionAI_ChooseReformationBelief);

Code

5288/// Select the belief most helpful to gain from Reformation social policy5289#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)5290BeliefTypes CvReligionAI::ChooseReformationBelief(PlayerTypes ePlayer, ReligionTypes eReligion)5291#else5292BeliefTypes CvReligionAI::ChooseReformationBelief()5293#endif5294{5295	CvGameReligions* pGameReligions = GC.getGame().GetGameReligions();5296	CvWeightedVector<BeliefTypes, SAFE_ESTIMATE_NUM_BELIEFS, true> beliefChoices;52975298#if defined(MOD_EVENTS_ACQUIRE_BELIEFS)5299	std::vector<BeliefTypes> availableBeliefs = pGameReligions->GetAvailableReformationBeliefs(ePlayer, eReligion);5300#else5301	std::vector<BeliefTypes> availableBeliefs = pGameReligions->GetAvailableReformationBeliefs();5302#endif53035304	for(std::vector<BeliefTypes>::iterator it = availableBeliefs.begin();5305	        it!= availableBeliefs.end(); ++it)5306	{5307		const BeliefTypes eBelief = (*it);5308		CvBeliefEntry* pEntry = m_pBeliefs->GetEntry(eBelief);5309		if(pEntry)5310		{5311			const int iScore = ScoreBelief(pEntry);5312#if !defined(MOD_BUGFIX_MINOR)5313			if(iScore > 0)5314			{5315#endif5316				beliefChoices.push_back(eBelief, iScore);5317#if !defined(MOD_BUGFIX_MINOR)5318			}5319#endif5320		}5321	}53225323	// Choose from weighted vector5324	beliefChoices.SortItems();5325	int iNumChoices = MIN(beliefChoices.size(),3);   // this was way too loose as choices way down were being selected now only top 35326	RandomNumberDelegate fcn = MakeDelegate(&GC.getGame(), &CvGame::getJonRandNum);5327	BeliefTypes rtnValue = beliefChoices.ChooseFromTopChoices(iNumChoices, &fcn, "Choosing belief from Top Choices");5328	LogBeliefChoices(beliefChoices, rtnValue);53295330	return rtnValue;5331}

Calls

Called by