LocationEffect.cpp 1.2 KB

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