DismissHero.cpp 880 B

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