RecruitHero.cpp 942 B

123456789101112131415161718192021222324252627282930313233343536
  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/StringConstants.h"
  19. extern boost::thread_specific_ptr<CCallback> cb;
  20. extern boost::thread_specific_ptr<VCAI> ai;
  21. extern FuzzyHelper * fh;
  22. using namespace Goals;
  23. TSubgoal RecruitHero::whatToDoToAchieve()
  24. {
  25. const CGTownInstance * t = ai->findTownWithTavern();
  26. if(!t)
  27. return sptr(BuildThis(BuildingID::TAVERN).setpriority(2));
  28. TResources res;
  29. res[EGameResID::GOLD] = GameConstants::HERO_GOLD_COST;
  30. return ai->ah->whatToDo(res, iAmElementar()); //either buy immediately, or collect res
  31. }