LocationEffect.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * LocationEffect.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 "LocationEffect.h"
  12. #include "../ISpellMechanics.h"
  13. namespace spells
  14. {
  15. namespace effects
  16. {
  17. LocationEffect::LocationEffect()
  18. : Effect()
  19. {
  20. }
  21. LocationEffect::~LocationEffect() = default;
  22. void LocationEffect::adjustTargetTypes(std::vector<TargetType> & types) const
  23. {
  24. }
  25. void LocationEffect::adjustAffectedHexes(std::set<BattleHex> & hexes, const Mechanics * m, const Target & spellTarget) const
  26. {
  27. for(auto & destnation : spellTarget)
  28. hexes.insert(destnation.hexValue);
  29. }
  30. EffectTarget LocationEffect::filterTarget(const Mechanics * m, const EffectTarget & target) const
  31. {
  32. EffectTarget res;
  33. vstd::copy_if(target, std::back_inserter(res), [](const Destination & d)
  34. {
  35. return !d.unitValue && (d.hexValue.isValid());
  36. });
  37. return res;
  38. }
  39. EffectTarget LocationEffect::transformTarget(const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const
  40. {
  41. //by default effect covers exactly spell range
  42. return EffectTarget(spellTarget);
  43. }
  44. }
  45. }