CvPlayerReligions::CanAffordFaithPurchase(int) const
- Defined in
- CvReligionClasses.cpp, line 3080
- Class
- CvPlayerReligions
- Hook name
CivHooks::CvPlayerReligions_CanAffordFaithPurchase
Hooks
static bool BeforeCvPlayerReligions_CanAffordFaithPurchase(const CvPlayerReligions* self, int iMinimumFaith, bool& result);static void AfterCvPlayerReligions_CanAffordFaithPurchase(const CvPlayerReligions* self, int iMinimumFaith, bool& result);static bool ReplaceCvPlayerReligions_CanAffordFaithPurchase(bool (*original)(const CvPlayerReligions*, int), const CvPlayerReligions* self, int iMinimumFaith);CivRegisterBefore<CivHooks::CvPlayerReligions_CanAffordFaithPurchase>(host, &BeforeCvPlayerReligions_CanAffordFaithPurchase);CivRegisterAfter<CivHooks::CvPlayerReligions_CanAffordFaithPurchase>(host, &AfterCvPlayerReligions_CanAffordFaithPurchase);CivRegisterReplace<CivHooks::CvPlayerReligions_CanAffordFaithPurchase>(host, &ReplaceCvPlayerReligions_CanAffordFaithPurchase);
Code
3078/// Does this player have enough faith to buy a religious unit or building?3079#if defined(MOD_RELIGION_RECURRING_PURCHASE_NOTIFIY)3080bool CvPlayerReligions::CanAffordFaithPurchase(int iMinimumFaith) const3081#else3082bool CvPlayerReligions::CanAffordFaithPurchase() const3083#endif3084{3085 int iFaith = m_pPlayer->GetFaith();3086 CvCity* pCapital = m_pPlayer->getCapitalCity();3087 if(pCapital)3088 {3089 for (int iI = 0; iI < GC.getNumUnitInfos(); iI++)3090 {3091 const UnitTypes eUnit = static_cast<UnitTypes>(iI);3092 CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eUnit);3093 if(pkUnitInfo)3094 {3095 if (m_pPlayer->IsCanPurchaseAnyCity(false, false, eUnit, NO_BUILDING, YIELD_FAITH))3096 {3097 int iCost = pCapital->GetFaithPurchaseCost(eUnit, true);3098#if defined(MOD_RELIGION_RECURRING_PURCHASE_NOTIFIY)3099 if(iCost != 0 && iFaith > iCost && iCost > iMinimumFaith)3100#else3101 if(iCost != 0 && iFaith > iCost)3102#endif3103 {3104 return true;3105 }3106 }3107 }3108 }3109 for (int iI = 0; iI < GC.getNumBuildingInfos(); iI++)3110 {3111 const BuildingTypes eBuilding = static_cast<BuildingTypes>(iI);3112 CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eBuilding);3113 if(pkBuildingInfo)3114 {3115 if (m_pPlayer->IsCanPurchaseAnyCity(false, false, NO_UNIT, eBuilding, YIELD_FAITH))3116 {3117 int iCost = pCapital->GetFaithPurchaseCost(eBuilding);3118#if defined(MOD_RELIGION_RECURRING_PURCHASE_NOTIFIY)3119 if(iCost != 0 && iFaith > iCost && iCost > iMinimumFaith)3120#else3121 if(iCost != 0 && iFaith > iCost)3122#endif3123 {3124 return true;3125 }3126 }3127 }3128 }3129 }31303131 return false;3132}
Calls
- CvCity::GetFaithPurchaseCost(BuildingTypes)
- CvCity::GetFaithPurchaseCost(UnitTypes, bool)
- CvGlobals::getBuildingInfo(BuildingTypes)
- CvGlobals::getNumBuildingInfos()
- CvGlobals::getNumUnitInfos()
- CvGlobals::getUnitInfo(UnitTypes)
- CvPlayer::getCapitalCity()
- CvPlayer::GetFaith() const
- CvPlayer::IsCanPurchaseAnyCity(bool, bool, UnitTypes, BuildingTypes, YieldTypes)