Effect.h 1.6 KB

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