BuyArmyAction.cpp 797 B

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