Effects.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Effects.h, 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. #pragma once
  11. #include "Effect.h"
  12. #include "../../GameConstants.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace spells
  15. {
  16. namespace effects
  17. {
  18. class DLL_LINKAGE Effects
  19. {
  20. public:
  21. using EffectsToApply = std::vector<std::pair<const Effect *, EffectTarget>>;
  22. using EffectsMap = std::map<std::string, std::shared_ptr<Effect>>;
  23. using EffectData = std::array<EffectsMap, GameConstants::SPELL_SCHOOL_LEVELS>;
  24. EffectData data;
  25. Effects();
  26. virtual ~Effects();
  27. void add(const std::string & name, const std::shared_ptr<Effect>& effect, const int level);
  28. bool applicable(Problem & problem, const Mechanics * m) const;
  29. bool applicable(Problem & problem, const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const;
  30. void forEachEffect(const int level, const std::function<void(const Effect *, bool &)> & callback) const;
  31. EffectsToApply prepare(const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const;
  32. void serializeJson(const Registry * registry, JsonSerializeFormat & handler, const int level);
  33. };
  34. }
  35. }
  36. VCMI_LIB_NAMESPACE_END