コード例 #1
0
/// Is this a valid Promotion for the UnitCombatType?
bool IsPromotionValidForUnitCombatType(PromotionTypes ePromotion, UnitTypes eUnit)
{
	CvUnitEntry* unitInfo = GC.getUnitInfo(eUnit);
	CvPromotionEntry* promotionInfo = GC.getPromotionInfo(ePromotion);

	if(unitInfo == NULL || promotionInfo == NULL)
		return false;

	// No combat class (civilians)
	if(unitInfo->GetUnitCombatType() == NO_UNITCOMBAT)
	{
		return false;
	}

	// Combat class not valid for this Promotion
#if defined(MOD_GLOBAL_PROMOTION_CLASSES)
	if(!(promotionInfo->GetUnitCombatClass(unitInfo->GetUnitPromotionType())))
#else
	if(!(promotionInfo->GetUnitCombatClass(unitInfo->GetUnitCombatType())))
#endif
	{
		return false;
	}

	return true;
}