DismissHero.cpp 1.1 KB

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