Просмотр исходного кода

VCAI will now check whether it actually has enough gold to buy a hero

Ivan Savenko 1 год назад
Родитель
Сommit
03786fb63b
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      AI/VCAI/VCAI.cpp

+ 3 - 0
AI/VCAI/VCAI.cpp

@@ -2031,6 +2031,9 @@ void VCAI::tryRealize(Goals::Explore & g)
 
 void VCAI::tryRealize(Goals::RecruitHero & g)
 {
+	if(cb->getResourceAmount(EGameResID::GOLD) < GameConstants::HERO_GOLD_COST)
+		throw cannotFulfillGoalException("Not enough gold to recruit hero!");
+
 	if(const CGTownInstance * t = findTownWithTavern())
 	{
 		recruitHero(t, true);