Bazaar developer reference

CvDealAI::GetTradeAgreementValue(bool, PlayerTypes, bool)

Defined in
CvDealAI.cpp, line 1910
Class
CvDealAI
Hook name
CivHooks::CvDealAI_GetTradeAgreementValue

Hooks

static bool BeforeCvDealAI_GetTradeAgreementValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue, int& result);static void AfterCvDealAI_GetTradeAgreementValue(CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue, int& result);static int ReplaceCvDealAI_GetTradeAgreementValue(int (*original)(CvDealAI*, bool, PlayerTypes, bool), CvDealAI* self, bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_GetTradeAgreementValue>(host, &BeforeCvDealAI_GetTradeAgreementValue);CivRegisterAfter<CivHooks::CvDealAI_GetTradeAgreementValue>(host, &AfterCvDealAI_GetTradeAgreementValue);CivRegisterReplace<CivHooks::CvDealAI_GetTradeAgreementValue>(host, &ReplaceCvDealAI_GetTradeAgreementValue);

Code

1909/// How much is a Trade Agreement worth?1910int CvDealAI::GetTradeAgreementValue(bool bFromMe, PlayerTypes eOtherPlayer, bool bUseEvenValue)1911{1912	CvAssertMsg(GetPlayer()->GetID() != eOtherPlayer, "DEAL_AI: Trying to check value of a Trade Agreement with oneself.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");19131914	int iItemValue = 100;19151916	if(bFromMe)1917	{1918		// Approach is important1919		switch(GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ true))1920		{1921		case MAJOR_CIV_APPROACH_HOSTILE:1922			iItemValue *= 250;1923			break;1924		case MAJOR_CIV_APPROACH_GUARDED:1925			iItemValue *= 130;1926			break;1927		case MAJOR_CIV_APPROACH_AFRAID:1928			iItemValue *= 80;1929			break;1930		case MAJOR_CIV_APPROACH_FRIENDLY:1931			iItemValue *= 100;1932			break;1933		case MAJOR_CIV_APPROACH_NEUTRAL:1934			iItemValue *= 110;1935			break;1936		default:1937			CvAssertMsg(false, "DEAL_AI: AI player has no valid Approach for Research Agreement valuation.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.")1938			iItemValue *= 100;1939			break;1940		}1941		iItemValue /= 100;1942	}19431944	// Are we trying to find the middle point between what we think this item is worth and what another player thinks it's worth?1945	if(bUseEvenValue)1946	{1947		iItemValue += GET_PLAYER(eOtherPlayer).GetDealAI()->GetTradeAgreementValue(!bFromMe, GetPlayer()->GetID(), /*bUseEvenValue*/ false);19481949		iItemValue /= 2;1950	}19511952	return iItemValue;1953}

Calls

Called by