TownPortalAction.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * TownPortalAction.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 "../../Goals/AdventureSpellCast.h"
  12. #include "../../../../lib/mapObjects/MapObjects.h"
  13. #include "TownPortalAction.h"
  14. namespace NKAI
  15. {
  16. using namespace AIPathfinding;
  17. void TownPortalAction::execute(AIGateway * ai, const CGHeroInstance * hero) const
  18. {
  19. auto goal = Goals::AdventureSpellCast(hero, usedSpell);
  20. goal.town = target;
  21. goal.tile = target->visitablePos();
  22. goal.accept(ai);
  23. }
  24. std::string TownPortalAction::toString() const
  25. {
  26. return "Town Portal to " + target->getNameTranslated();
  27. }
  28. /*
  29. bool TownPortalAction::canAct(const CGHeroInstance * hero, const AIPathNode * source) const
  30. {
  31. #ifdef VCMI_TRACE_PATHFINDER
  32. logAi->trace(
  33. "Hero %s has %d mana and needed %d and already spent %d",
  34. hero->name,
  35. hero->mana,
  36. getManaCost(hero),
  37. source->manaCost);
  38. #endif
  39. return hero->mana >= source->manaCost + getManaCost(hero);
  40. }
  41. uint32_t TownPortalAction::getManaCost(const CGHeroInstance * hero) const
  42. {
  43. SpellID summonBoat = SpellID::TOWN_PORTAL;
  44. return hero->getSpellCost(summonBoat.toSpell());
  45. }*/
  46. }