BuyArmyAction.cpp 937 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * BattleAction.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 "BuyArmyAction.h"
  12. #include "../../AIGateway.h"
  13. #include "../../Goals/CompleteQuest.h"
  14. #include "../../../../lib/mapping/CMap.h" //for victory conditions
  15. namespace NKAI
  16. {
  17. extern boost::thread_specific_ptr<CCallback> cb;
  18. extern boost::thread_specific_ptr<AIGateway> ai;
  19. namespace AIPathfinding
  20. {
  21. void BuyArmyAction::execute(const CGHeroInstance * hero) const
  22. {
  23. if(!hero->visitedTown)
  24. {
  25. throw cannotFulfillGoalException(
  26. hero->getNameTranslated() + " being at " + hero->visitablePos().toString() + " has no town to recruit creatures.");
  27. }
  28. ai->recruitCreatures(hero->visitedTown, hero);
  29. }
  30. std::string BuyArmyAction::toString() const
  31. {
  32. return "Buy Army";
  33. }
  34. }
  35. }