RecruitHeroBehavior.cpp 1017 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Goals.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 "RecruitHeroBehavior.h"
  12. #include "../VCAI.h"
  13. #include "../AIhelper.h"
  14. #include "../AIUtility.h"
  15. #include "../Goals/RecruitHero.h"
  16. #include "lib/mapping/CMap.h" //for victory conditions
  17. #include "lib/CPathfinder.h"
  18. extern boost::thread_specific_ptr<CCallback> cb;
  19. extern boost::thread_specific_ptr<VCAI> ai;
  20. extern FuzzyHelper * fh;
  21. using namespace Goals;
  22. std::string RecruitHeroBehavior::toString() const
  23. {
  24. return "Recruit hero";
  25. }
  26. Goals::TGoalVec RecruitHeroBehavior::getTasks()
  27. {
  28. Goals::TGoalVec tasks;
  29. if(ai->canRecruitAnyHero())
  30. {
  31. if(cb->getDate(Date::DAY) == 1
  32. || cb->getHeroesInfo().size() < cb->getTownsInfo().size() + 1
  33. || cb->getResourceAmount(Res::GOLD) > 10000)
  34. {
  35. tasks.push_back(Goals::sptr(Goals::RecruitHero()));
  36. }
  37. }
  38. return tasks;
  39. }