ISpellMechanics.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * ISpellMechanics.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 "CSpellHandler.h"
  12. #include "../BattleHex.h"
  13. class DLL_LINKAGE ISpellMechanics
  14. {
  15. public:
  16. struct DLL_LINKAGE SpellTargetingContext
  17. {
  18. const CBattleInfoCallback * cb;
  19. CSpell::TargetInfo ti;
  20. ECastingMode::ECastingMode mode;
  21. BattleHex destination;
  22. PlayerColor casterColor;
  23. int schoolLvl;
  24. SpellTargetingContext(const CSpell * s, const CBattleInfoCallback * c, ECastingMode::ECastingMode m, PlayerColor cc, int lvl, BattleHex dest)
  25. : cb(c), ti(s,lvl, m), mode(m), destination(dest), casterColor(cc), schoolLvl(lvl)
  26. {};
  27. };
  28. public:
  29. ISpellMechanics(CSpell * s);
  30. virtual ~ISpellMechanics(){};
  31. virtual std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool * outDroppedHexes = nullptr) const = 0;
  32. virtual std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const = 0;
  33. virtual ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const = 0;
  34. virtual bool adventureCast(const SpellCastEnvironment * env, AdventureSpellCastParameters & parameters) const = 0;
  35. virtual void battleCast(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters) const = 0;
  36. virtual void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const = 0;
  37. static ISpellMechanics * createMechanics(CSpell * s);
  38. protected:
  39. CSpell * owner;
  40. };