LocationEffect.cpp 1.2 KB

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