ISpellMechanics.h 1.8 KB

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