浏览代码

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

Ivan Savenko 1 年之前
父节点
当前提交
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);