BattleSpellMechanics.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. VCMI_LIB_NAMESPACE_BEGIN
  14. struct BattleSpellCast;
  15. namespace spells
  16. {
  17. class BattleSpellMechanics : public BaseMechanics
  18. {
  19. public:
  20. BattleSpellMechanics(const IBattleCast * event, std::shared_ptr<effects::Effects> effects_, std::shared_ptr<IReceptiveCheck> targetCondition_);
  21. virtual ~BattleSpellMechanics();
  22. // TODO: ??? (what's the difference compared to cast?)
  23. void applyEffects(ServerCallback * server, const Target & targets, bool indirect, bool ignoreImmunity) const override;
  24. /// Returns false if spell can not be cast at all, e.g. due to not having any possible target on battlefield
  25. bool canBeCast(Problem & problem) const override;
  26. /// Returns false if spell can not be cast at specifid target
  27. bool canBeCastAt(const Target & target, Problem & problem) const override;
  28. // TODO: ??? (what's the difference compared to applyEffects?)
  29. void cast(ServerCallback * server, const Target & target) override final;
  30. // TODO: ??? (what's the difference compared to cast?)
  31. void castEval(ServerCallback * server, const Target & target) override final;
  32. /// Returns list of affected stack using currently configured target
  33. std::vector<const CStack *> getAffectedStacks(const Target & target) const override final;
  34. /// Returns list of target types that can be targeted by spell
  35. std::vector<AimType> getTargetTypes() const override final;
  36. /// Returns vector of all possible destinations for specified aim type
  37. /// index - ???
  38. /// current - ???
  39. std::vector<Destination> getPossibleDestinations(size_t index, AimType aimType, const Target & current, bool fast) const override final;
  40. /// Returns true if spell can be cast on unit
  41. bool isReceptive(const battle::Unit * target) const override;
  42. /// Returns list of hexes that are affected by spell assuming cast at centralHex
  43. std::vector<BattleHex> rangeInHexes(BattleHex centralHex) const override;
  44. const Spell * getSpell() const override;
  45. bool counteringSelector(const Bonus * bonus) const;
  46. private:
  47. std::shared_ptr<effects::Effects> effects;
  48. std::shared_ptr<IReceptiveCheck> targetCondition;
  49. std::vector<const battle::Unit *> affectedUnits;
  50. effects::Effects::EffectsToApply effectsToApply;
  51. void beforeCast(BattleSpellCast & sc, vstd::RNG & rng, const Target & target);
  52. std::set<const battle::Unit *> collectTargets() const;
  53. void doRemoveEffects(ServerCallback * server, const std::vector<const battle::Unit *> & targets, const CSelector & selector);
  54. std::set<BattleHex> spellRangeInHexes(BattleHex centralHex) const;
  55. Target transformSpellTarget(const Target & aimPoint) const;
  56. };
  57. }
  58. VCMI_LIB_NAMESPACE_END