Explorar o código

Quick fix for https://bugs.vcmi.eu/view.php?id=3041

AlexVinS %!s(int64=6) %!d(string=hai) anos
pai
achega
f36a86412e
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      AI/VCAI/Goals/AdventureSpellCast.cpp

+ 3 - 0
AI/VCAI/Goals/AdventureSpellCast.cpp

@@ -44,6 +44,9 @@ TSubgoal AdventureSpellCast::whatToDoToAchieve()
 	if(hero->mana < hero->getSpellCost(spell))
 	if(hero->mana < hero->getSpellCost(spell))
 		throw cannotFulfillGoalException("Hero has not enough mana to cast " + spell->name);
 		throw cannotFulfillGoalException("Hero has not enough mana to cast " + spell->name);
 
 
+	if(spellID == SpellID::TOWN_PORTAL && town && town->visitingHero)
+		throw cannotFulfillGoalException("The town is already occupied by " + town->visitingHero->name);
+
 	return iAmElementar();
 	return iAmElementar();
 }
 }