AdventureSpellMechanics.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * AdventureSpellMechanics.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. VCMI_LIB_NAMESPACE_BEGIN
  13. class IAdventureSpellEffect;
  14. class AdventureSpellMechanics final : public IAdventureSpellMechanics, boost::noncopyable
  15. {
  16. struct LevelOptions
  17. {
  18. std::unique_ptr<IAdventureSpellEffect> effect;
  19. std::vector<std::shared_ptr<Bonus>> bonuses;
  20. int castsPerDay;
  21. int castsPerDayXL;
  22. };
  23. std::array<LevelOptions, GameConstants::SPELL_SCHOOL_LEVELS> levelOptions;
  24. const LevelOptions & getLevel(const spells::Caster * caster) const;
  25. void giveBonuses(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters) const;
  26. public:
  27. AdventureSpellMechanics(const CSpell * s);
  28. ~AdventureSpellMechanics();
  29. bool canBeCast(spells::Problem & problem, const IGameInfoCallback * cb, const spells::Caster * caster) const final;
  30. bool canBeCastAt(spells::Problem & problem, const IGameInfoCallback * cb, const spells::Caster * caster, const int3 & pos) const final;
  31. bool adventureCast(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters) const final;
  32. const IAdventureSpellEffect * getEffect(const spells::Caster * caster) const final;
  33. bool givesBonus(const spells::Caster * caster, BonusType which) const final;
  34. void performCast(SpellCastEnvironment * env, const AdventureSpellCastParameters & parameters) const;
  35. };
  36. VCMI_LIB_NAMESPACE_END