BuyArmyAction.cpp 870 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. namespace NKAI
  15. {
  16. extern boost::thread_specific_ptr<CCallback> cb;
  17. extern boost::thread_specific_ptr<AIGateway> ai;
  18. namespace AIPathfinding
  19. {
  20. void BuyArmyAction::execute(const CGHeroInstance * hero) const
  21. {
  22. if(!hero->visitedTown)
  23. {
  24. throw cannotFulfillGoalException(
  25. hero->getNameTranslated() + " being at " + hero->visitablePos().toString() + " has no town to recruit creatures.");
  26. }
  27. ai->recruitCreatures(hero->visitedTown, hero);
  28. }
  29. std::string BuyArmyAction::toString() const
  30. {
  31. return "Buy Army";
  32. }
  33. }
  34. }