Bazaar developer reference

CvPlayerCulture::GetTurnsToInfluential(PlayerTypes) const

Defined in
CvCultureClasses.cpp, line 2875
Class
CvPlayerCulture
Hook name
CivHooks::CvPlayerCulture_GetTurnsToInfluential

Hooks

static bool BeforeCvPlayerCulture_GetTurnsToInfluential(const CvPlayerCulture* self, PlayerTypes ePlayer, int& result);static void AfterCvPlayerCulture_GetTurnsToInfluential(const CvPlayerCulture* self, PlayerTypes ePlayer, int& result);static int ReplaceCvPlayerCulture_GetTurnsToInfluential(int (*original)(const CvPlayerCulture*, PlayerTypes), const CvPlayerCulture* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvPlayerCulture_GetTurnsToInfluential>(host, &BeforeCvPlayerCulture_GetTurnsToInfluential);CivRegisterAfter<CivHooks::CvPlayerCulture_GetTurnsToInfluential>(host, &AfterCvPlayerCulture_GetTurnsToInfluential);CivRegisterReplace<CivHooks::CvPlayerCulture_GetTurnsToInfluential>(host, &ReplaceCvPlayerCulture_GetTurnsToInfluential);

Code

2874/// If influence is rising, how many turns until we get to Influential? (999 if not rising fast enough to make it there eventually)2875int CvPlayerCulture::GetTurnsToInfluential(PlayerTypes ePlayer) const2876{2877	CvPlayer &kOtherPlayer = GET_PLAYER(ePlayer);2878	int iRtnValue = 999;28792880	if (GetInfluenceLevel(ePlayer) >= INFLUENCE_LEVEL_INFLUENTIAL)2881	{2882		return 0;2883	}2884	else if (GetInfluenceTrend(ePlayer) == INFLUENCE_TREND_RISING)2885	{2886		int iInfluence = GetInfluenceOn(ePlayer);2887		int iInflPerTurn = GetInfluencePerTurn(ePlayer);2888		int iCulture = kOtherPlayer.GetJONSCultureEverGenerated();2889		int iCultPerTurn = kOtherPlayer.GetTotalJONSCulturePerTurn();28902891		int iNumerator = (GC.getCULTURE_LEVEL_INFLUENTIAL() * iCulture / 100) -  iInfluence;2892		int iDivisor = iInflPerTurn - (GC.getCULTURE_LEVEL_INFLUENTIAL() * iCultPerTurn / 100);28932894		if (iDivisor > 0)2895		{2896			iRtnValue = iNumerator / iDivisor;28972898			// Round up2899			if (iNumerator % iDivisor != 0)2900			{2901				iRtnValue++;2902			}2903		}2904	}29052906	return iRtnValue;2907}

Calls

Called by