DigAtTile.cpp 879 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * DigAtTile.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 "DigAtTile.h"
  12. #include "VisitTile.h"
  13. #include "../VCAI.h"
  14. #include "../AIUtility.h"
  15. using namespace Goals;
  16. bool DigAtTile::operator==(const DigAtTile & other) const
  17. {
  18. return other.hero.h == hero.h && other.tile == tile;
  19. }
  20. TSubgoal DigAtTile::whatToDoToAchieve()
  21. {
  22. const CGObjectInstance * firstObj = vstd::frontOrNull(cb->getVisitableObjs(tile));
  23. if(firstObj && firstObj->ID == Obj::HERO && firstObj->tempOwner == ai->playerID) //we have hero at dest
  24. {
  25. const CGHeroInstance * h = dynamic_cast<const CGHeroInstance *>(firstObj);
  26. sethero(h).setisElementar(true);
  27. return sptr(*this);
  28. }
  29. return sptr(VisitTile(tile));
  30. }