BuyArmyAction.cpp 900 B

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