AdventureSpellEffect.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * AdventureSpellEffect.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 "../ISpellMechanics.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. enum class ESpellCastResult : int8_t
  14. {
  15. OK, // cast successful
  16. CANCEL, // cast failed but it is not an error, no mana has been spent
  17. PENDING,
  18. ERROR // error occurred, for example invalid request from player
  19. };
  20. class AdventureSpellMechanics;
  21. class IAdventureSpellEffect
  22. {
  23. public:
  24. virtual ~IAdventureSpellEffect() = default;
  25. virtual ESpellCastResult applyAdventureEffects(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters) const {return ESpellCastResult::OK;};
  26. virtual ESpellCastResult beginCast(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters, const AdventureSpellMechanics & mechanics) const {return ESpellCastResult::OK;};
  27. virtual void endCast(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters) const {};
  28. virtual bool canBeCastImpl(spells::Problem & problem, const IGameInfoCallback * cb, const spells::Caster * caster) const {return true;};
  29. virtual bool canBeCastAtImpl(spells::Problem & problem, const IGameInfoCallback * cb, const spells::Caster * caster, const int3 & pos) const {return true;};
  30. virtual bool isTargetInRange(spells::Problem & problem, const IGameInfoCallback * cb, const spells::Caster * caster, const int3 & pos) const {return true;};
  31. };
  32. class AdventureSpellEffect final : public IAdventureSpellEffect
  33. {
  34. public:
  35. AdventureSpellEffect() = default;
  36. };
  37. class AdventureSpellRangedEffect : public IAdventureSpellEffect
  38. {
  39. int rangeX;
  40. int rangeY;
  41. bool ignoreFow;
  42. public:
  43. AdventureSpellRangedEffect(const JsonNode & config);
  44. bool isTargetInRange(spells::Problem & problem, const IGameInfoCallback * cb, const spells::Caster * caster, const int3 & pos) const override;
  45. };
  46. VCMI_LIB_NAMESPACE_END