BattleSpellMechanics.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * BattleSpellMechanics.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 "CDefaultSpellMechanics.h"
  12. class CObstacleInstance;
  13. class DLL_LINKAGE HealingSpellMechanics : public DefaultSpellMechanics
  14. {
  15. public:
  16. enum class EHealLevel
  17. {
  18. HEAL,
  19. RESURRECT,
  20. TRUE_RESURRECT
  21. };
  22. HealingSpellMechanics(CSpell * s): DefaultSpellMechanics(s){};
  23. protected:
  24. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  25. virtual int calculateHealedHP(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const;
  26. virtual EHealLevel getHealLevel(int effectLevel) const = 0;
  27. };
  28. class DLL_LINKAGE AntimagicMechanics : public DefaultSpellMechanics
  29. {
  30. public:
  31. AntimagicMechanics(CSpell * s): DefaultSpellMechanics(s){};
  32. void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
  33. };
  34. class DLL_LINKAGE ChainLightningMechanics : public DefaultSpellMechanics
  35. {
  36. public:
  37. ChainLightningMechanics(CSpell * s): DefaultSpellMechanics(s){};
  38. std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const override;
  39. };
  40. class DLL_LINKAGE CloneMechanics : public DefaultSpellMechanics
  41. {
  42. public:
  43. CloneMechanics(CSpell * s): DefaultSpellMechanics(s){};
  44. ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
  45. protected:
  46. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  47. };
  48. class DLL_LINKAGE CureMechanics : public HealingSpellMechanics
  49. {
  50. public:
  51. CureMechanics(CSpell * s): HealingSpellMechanics(s){};
  52. void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
  53. EHealLevel getHealLevel(int effectLevel) const override final;
  54. };
  55. class DLL_LINKAGE DispellMechanics : public DefaultSpellMechanics
  56. {
  57. public:
  58. DispellMechanics(CSpell * s): DefaultSpellMechanics(s){};
  59. ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
  60. void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
  61. protected:
  62. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  63. };
  64. class DLL_LINKAGE EarthquakeMechanics : public DefaultSpellMechanics
  65. {
  66. public:
  67. EarthquakeMechanics(CSpell * s): DefaultSpellMechanics(s){};
  68. ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ISpellCaster * caster) const override;
  69. protected:
  70. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  71. };
  72. class DLL_LINKAGE HypnotizeMechanics : public DefaultSpellMechanics
  73. {
  74. public:
  75. HypnotizeMechanics(CSpell * s): DefaultSpellMechanics(s){};
  76. ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
  77. };
  78. class DLL_LINKAGE ObstacleMechanics : public DefaultSpellMechanics
  79. {
  80. public:
  81. ObstacleMechanics(CSpell * s): DefaultSpellMechanics(s){};
  82. protected:
  83. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  84. };
  85. class DLL_LINKAGE WallMechanics : public ObstacleMechanics
  86. {
  87. public:
  88. WallMechanics(CSpell * s): ObstacleMechanics(s){};
  89. std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = nullptr) const override;
  90. };
  91. class DLL_LINKAGE RemoveObstacleMechanics : public DefaultSpellMechanics
  92. {
  93. public:
  94. RemoveObstacleMechanics(CSpell * s): DefaultSpellMechanics(s){};
  95. ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ISpellCaster * caster) const override;
  96. ESpellCastProblem::ESpellCastProblem canBeCast(const SpellTargetingContext & ctx) const override;
  97. protected:
  98. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  99. private:
  100. bool canRemove(const CObstacleInstance * obstacle, const int spellLevel) const;
  101. };
  102. ///all rising spells
  103. class DLL_LINKAGE RisingSpellMechanics : public HealingSpellMechanics
  104. {
  105. public:
  106. RisingSpellMechanics(CSpell * s): HealingSpellMechanics(s){};
  107. EHealLevel getHealLevel(int effectLevel) const override;
  108. };
  109. class DLL_LINKAGE SacrificeMechanics : public RisingSpellMechanics
  110. {
  111. public:
  112. SacrificeMechanics(CSpell * s): RisingSpellMechanics(s){};
  113. ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ISpellCaster * caster) const override;
  114. protected:
  115. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  116. int calculateHealedHP(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  117. };
  118. ///ANIMATE_DEAD and RESURRECTION
  119. class DLL_LINKAGE SpecialRisingSpellMechanics : public RisingSpellMechanics
  120. {
  121. public:
  122. SpecialRisingSpellMechanics(CSpell * s): RisingSpellMechanics(s){};
  123. ESpellCastProblem::ESpellCastProblem canBeCast(const SpellTargetingContext & ctx) const override;
  124. ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
  125. };
  126. class DLL_LINKAGE SummonMechanics : public DefaultSpellMechanics
  127. {
  128. public:
  129. SummonMechanics(CSpell * s, CreatureID cre): DefaultSpellMechanics(s), creatureToSummon(cre){};
  130. ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, const ISpellCaster * caster) const override;
  131. protected:
  132. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  133. private:
  134. CreatureID creatureToSummon;
  135. };
  136. class DLL_LINKAGE TeleportMechanics: public DefaultSpellMechanics
  137. {
  138. public:
  139. TeleportMechanics(CSpell * s): DefaultSpellMechanics(s){};
  140. protected:
  141. void applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
  142. };