RecruitHero.cpp 832 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * RecruitHero.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "Goals.h"
  12. #include "../VCAI.h"
  13. #include "../AIUtility.h"
  14. #include "../AIhelper.h"
  15. #include "../FuzzyHelper.h"
  16. #include "../ResourceManager.h"
  17. #include "../BuildingManager.h"
  18. #include "../../../lib/constants/StringConstants.h"
  19. using namespace Goals;
  20. TSubgoal RecruitHero::whatToDoToAchieve()
  21. {
  22. const CGTownInstance * t = ai->findTownWithTavern();
  23. if(!t)
  24. return sptr(BuildThis(BuildingID::TAVERN).setpriority(2));
  25. TResources res;
  26. res[EGameResID::GOLD] = GameConstants::HERO_GOLD_COST;
  27. return ai->ah->whatToDo(res, iAmElementar()); //either buy immediately, or collect res
  28. }