Effect.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Effect.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 "../Magic.h"
  12. struct BattleHex;
  13. class CBattleInfoCallback;
  14. class JsonSerializeFormat;
  15. class IBattleState;
  16. namespace vstd
  17. {
  18. class RNG;
  19. }
  20. namespace spells
  21. {
  22. using EffectTarget = Target;
  23. class BattleStateProxy;
  24. namespace effects
  25. {
  26. using RNG = ::vstd::RNG;
  27. class Effects;
  28. class Effect;
  29. class Registry;
  30. template<typename F>
  31. class RegisterEffect;
  32. using TargetType = ::spells::AimType;
  33. class DLL_LINKAGE Effect
  34. {
  35. public:
  36. bool indirect;
  37. bool optional;
  38. std::string name;
  39. Effect();
  40. virtual ~Effect();
  41. virtual void adjustTargetTypes(std::vector<TargetType> & types) const = 0;
  42. virtual void adjustAffectedHexes(std::set<BattleHex> & hexes, const Mechanics * m, const Target & spellTarget) const = 0;
  43. virtual bool applicable(Problem & problem, const Mechanics * m) const;
  44. virtual bool applicable(Problem & problem, const Mechanics * m, const EffectTarget & target) const;
  45. virtual void apply(BattleStateProxy * battleState, RNG & rng, const Mechanics * m, const EffectTarget & target) const = 0;
  46. virtual EffectTarget filterTarget(const Mechanics * m, const EffectTarget & target) const = 0;
  47. virtual EffectTarget transformTarget(const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const = 0;
  48. void serializeJson(JsonSerializeFormat & handler);
  49. static std::shared_ptr<Effect> create(const std::string & type);
  50. protected:
  51. virtual void serializeJsonEffect(JsonSerializeFormat & handler) = 0;
  52. };
  53. }
  54. }