BattleSpellMechanics.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "ISpellMechanics.h"
  12. #include "effects/Effects.h"
  13. struct BattleSpellCast;
  14. namespace spells
  15. {
  16. class BattleSpellMechanics : public BaseMechanics
  17. {
  18. public:
  19. BattleSpellMechanics(const IBattleCast * event, std::shared_ptr<effects::Effects> effects_, std::shared_ptr<IReceptiveCheck> targetCondition_);
  20. virtual ~BattleSpellMechanics();
  21. void applyEffects(ServerCallback * server, const Target & targets, bool indirect, bool ignoreImmunity) const override;
  22. bool canBeCast(Problem & problem) const override;
  23. bool canBeCastAt(const Target & target, Problem & problem) const override;
  24. void cast(ServerCallback * server, const Target & target) override final;
  25. void castEval(ServerCallback * server, const Target & target) override final;
  26. std::vector<const CStack *> getAffectedStacks(const Target & target) const override final;
  27. std::vector<AimType> getTargetTypes() const override final;
  28. std::vector<Destination> getPossibleDestinations(size_t index, AimType aimType, const Target & current) const override final;
  29. bool isReceptive(const battle::Unit * target) const override;
  30. std::vector<BattleHex> rangeInHexes(BattleHex centralHex, bool * outDroppedHexes = nullptr) const override;
  31. const Spell * getSpell() const override;
  32. bool counteringSelector(const Bonus * bonus) const;
  33. private:
  34. std::shared_ptr<effects::Effects> effects;
  35. std::shared_ptr<IReceptiveCheck> targetCondition;
  36. std::vector<const battle::Unit *> affectedUnits;
  37. effects::Effects::EffectsToApply effectsToApply;
  38. void beforeCast(BattleSpellCast & sc, vstd::RNG & rng, const Target & target);
  39. void addCustomEffect(BattleSpellCast & sc, const battle::Unit * target, ui32 effect);
  40. void addCustomEffect(BattleSpellCast & sc, ui32 targetId, ui32 effect);
  41. std::set<const battle::Unit *> collectTargets() const;
  42. static void doRemoveEffects(ServerCallback * server, const std::vector<const battle::Unit *> & targets, const CSelector & selector);
  43. std::set<BattleHex> spellRangeInHexes(BattleHex centralHex) const;
  44. Target transformSpellTarget(const Target & aimPoint) const;
  45. };
  46. }