RecruitHero.cpp 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 "../AIGateway.h"
  13. #include "../AIUtility.h"
  14. #include "../../../lib/mapping/CMap.h" //for victory conditions
  15. #include "../../../lib/CPathfinder.h"
  16. #include "../../../lib/StringConstants.h"
  17. namespace NKAI
  18. {
  19. extern boost::thread_specific_ptr<CCallback> cb;
  20. extern boost::thread_specific_ptr<AIGateway> ai;
  21. using namespace Goals;
  22. std::string RecruitHero::toString() const
  23. {
  24. return "Recruit hero at " + town->name;
  25. }
  26. void RecruitHero::accept(AIGateway * ai)
  27. {
  28. auto t = town;
  29. if(!t) t = ai->findTownWithTavern();
  30. if(t)
  31. {
  32. ai->recruitHero(t, true);
  33. //TODO try to free way to blocked town
  34. //TODO: adventure map tavern or prison?
  35. }
  36. else
  37. {
  38. throw cannotFulfillGoalException("No town to recruit hero!");
  39. }
  40. }
  41. }