BattleSpellMechanics.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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(BattleStateProxy * battleState, vstd::RNG & rng, const Target & targets, bool indirect, bool ignoreImmunity) const override;
  22. bool canBeCast(Problem & problem) const override;
  23. bool canBeCastAt(const Target & target) const override;
  24. void cast(const PacketSender * server, vstd::RNG & rng, const Target & target) override final;
  25. void cast(IBattleState * battleState, vstd::RNG & rng, 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. bool counteringSelector(const Bonus * bonus) const;
  32. private:
  33. std::shared_ptr<effects::Effects> effects;
  34. std::shared_ptr<IReceptiveCheck> targetCondition;
  35. std::vector<const battle::Unit *> affectedUnits;
  36. effects::Effects::EffectsToApply effectsToApply;
  37. void beforeCast(BattleSpellCast & sc, vstd::RNG & rng, const Target & target);
  38. void addCustomEffect(BattleSpellCast & sc, const battle::Unit * target, ui32 effect);
  39. void addCustomEffect(BattleSpellCast & sc, ui32 targetId, ui32 effect);
  40. std::set<const battle::Unit *> collectTargets() const;
  41. static void doRemoveEffects(const PacketSender * server, const std::vector<const battle::Unit *> & targets, const CSelector & selector);
  42. std::set<BattleHex> spellRangeInHexes(BattleHex centralHex) const;
  43. Target transformSpellTarget(const Target & aimPoint) const;
  44. };
  45. }