DismissHero.cpp 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * DismissHero.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 "DismissHero.h"
  12. #include "../AIGateway.h"
  13. #include "../../../lib/mapping/CMap.h" //for victory conditions
  14. #include "../../../lib/CPathfinder.h"
  15. namespace NKAI
  16. {
  17. extern boost::thread_specific_ptr<CCallback> cb;
  18. extern boost::thread_specific_ptr<AIGateway> ai;
  19. using namespace Goals;
  20. bool DismissHero::operator==(const DismissHero & other) const
  21. {
  22. return hero.h == other.hero.h;
  23. }
  24. void DismissHero::accept(AIGateway * ai)
  25. {
  26. if(!hero.validAndSet())
  27. throw cannotFulfillGoalException("Invalid hero!");
  28. cb->dismissHero(hero.h);
  29. throw goalFulfilledException(sptr(*this));
  30. }
  31. std::string DismissHero::toString() const
  32. {
  33. return "DismissHero " + hero.name;
  34. }
  35. }