Browse Source

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

Ivan Savenko 1 year ago
parent
commit
03786fb63b
1 changed files with 3 additions and 0 deletions
  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);