Bazaar developer reference

CvDiplomacyAI::DoTestPromises()

Defined in
CvDiplomacyAI.cpp, line 22266
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoTestPromises

Hooks

static bool BeforeCvDiplomacyAI_DoTestPromises(CvDiplomacyAI* self);static void AfterCvDiplomacyAI_DoTestPromises(CvDiplomacyAI* self);static void ReplaceCvDiplomacyAI_DoTestPromises(void (*original)(CvDiplomacyAI*), CvDiplomacyAI* self);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoTestPromises>(host, &BeforeCvDiplomacyAI_DoTestPromises);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoTestPromises>(host, &AfterCvDiplomacyAI_DoTestPromises);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoTestPromises>(host, &ReplaceCvDiplomacyAI_DoTestPromises);

Code

22266void CvDiplomacyAI::DoTestPromises()22267{22268	AggressivePostureTypes eOldPosture;2226922270	// Loop through all (known) Majors22271	PlayerTypes eLoopPlayer;22272	TeamTypes eLoopTeam;22273	for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)22274	{22275		eLoopPlayer = (PlayerTypes) iPlayerLoop;22276		eLoopTeam = GET_PLAYER(eLoopPlayer).getTeam();2227722278		if(IsPlayerValid(eLoopPlayer))22279		{22280			// Military Promise22281			if(IsPlayerMadeMilitaryPromise(eLoopPlayer))22282			{22283				ChangePlayerMilitaryPromiseCounter(eLoopPlayer, 1);2228422285				// Expired?22286				if(GetPlayerMilitaryPromiseCounter(eLoopPlayer) > 20)22287				{22288					SetPlayerMadeMilitaryPromise(eLoopPlayer, false);22289					SetPlayerMilitaryPromiseCounter(eLoopPlayer, -1);22290				}22291			}2229222293			// Expansion Promise22294			if(IsPlayerMadeExpansionPromise(eLoopPlayer))22295			{22296				eOldPosture = GetPlayerExpansionPromiseData(eLoopPlayer);2229722298				// Player has been up to no good since we last warned him22299				if(GetExpansionAggressivePosture(eLoopPlayer) > eOldPosture)22300				{22301					if (!IsPlayerBrokenExpansionPromise(eLoopPlayer))22302					{22303						SetBrokenExpansionPromiseValue(eLoopPlayer, GC.getOPINION_WEIGHT_EXPANSION_PROMISE_BROKE_MAX() * GC.getGame().getGameSpeedInfo().getOpinionDurationPercent());22304						SetPlayerBrokenExpansionPromise(eLoopPlayer, true);22305					}22306				}22307			}22308			else if (IsPlayerMadeExpansionPromise(eLoopPlayer, GC.getGame().getGameTurn() - 1)) // if the expansion promise expired last turn, announce it22309			{22310				// fire off notification that promise has expired22311				CvNotifications* pNotifications = GET_PLAYER(eLoopPlayer).GetNotifications();22312				if(pNotifications)22313				{22314					CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_EXPANSION_PROMISE_EXPIRED", GET_PLAYER(GetPlayer()->GetID()).getCivilizationShortDescriptionKey());22315					CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_EXPANSION_PROMISE_EXPIRED_S");22316					pNotifications->Add(NOTIFICATION_EXPANSION_PROMISE_EXPIRED, strBuffer, strSummary, -1, -1, GetPlayer()->GetID(), eLoopPlayer);22317				}2231822319			}2232022321			// Border Promise22322			if(IsPlayerMadeBorderPromise(eLoopPlayer))22323			{22324				eOldPosture = GetPlayerBorderPromiseData(eLoopPlayer);2232522326				// Player has been up to no good since we last warned him22327				if(GetPlotBuyingAggressivePosture(eLoopPlayer) > eOldPosture)22328				{22329					if (!IsPlayerBrokenBorderPromise(eLoopPlayer))22330					{22331						SetBrokenBorderPromiseValue(eLoopPlayer, GC.getOPINION_WEIGHT_BORDER_PROMISE_BROKE_MAX() * GC.getGame().getGameSpeedInfo().getOpinionDurationPercent());22332						SetPlayerBrokenBorderPromise(eLoopPlayer, true);22333					}22334				}22335			}22336			else if (IsPlayerMadeBorderPromise(eLoopPlayer, GC.getGame().getGameTurn() - 1)) // if the border promise expired last turn, announce it22337			{22338				// fire off notification that promise has expired22339				CvNotifications* pNotifications = GET_PLAYER(eLoopPlayer).GetNotifications();22340				if(pNotifications)22341				{22342					CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_BORDER_PROMISE_EXPIRED", GET_PLAYER(GetPlayer()->GetID()).getCivilizationShortDescriptionKey());22343					CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_BORDER_PROMISE_EXPIRED_S");22344					pNotifications->Add(NOTIFICATION_BORDER_PROMISE_EXPIRED, strBuffer, strSummary, -1, -1, GetPlayer()->GetID(), eLoopPlayer);22345				}2234622347			}22348		}22349	}22350}

Calls

Called by