AbilityCaster.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * AbilityCaster.cpp, 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. #include "StdInc.h"
  11. #include "AbilityCaster.h"
  12. #include "../battle/Unit.h"
  13. namespace spells
  14. {
  15. AbilityCaster::AbilityCaster(const battle::Unit * actualCaster_, int baseSpellLevel_)
  16. : ProxyCaster(actualCaster_),
  17. actualCaster(actualCaster_),
  18. baseSpellLevel(baseSpellLevel_)
  19. {
  20. }
  21. AbilityCaster::~AbilityCaster() = default;
  22. ui8 AbilityCaster::getSpellSchoolLevel(const Spell * spell, int * outSelectedSchool) const
  23. {
  24. int skill = baseSpellLevel;
  25. if(spell->getLevel() > 0)
  26. {
  27. vstd::amax(skill, actualCaster->valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0));
  28. }
  29. vstd::amax(skill, 0);
  30. vstd::amin(skill, 3);
  31. return static_cast<ui8>(skill); //todo: unify spell school level type
  32. }
  33. int AbilityCaster::getEffectLevel(const Spell * spell) const
  34. {
  35. return getSpellSchoolLevel(spell);
  36. }
  37. void AbilityCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit*> & attacked, MetaString & text) const
  38. {
  39. //do nothing
  40. }
  41. void AbilityCaster::spendMana(const PacketSender * server, const int spellCost) const
  42. {
  43. //do nothing
  44. }
  45. } // namespace spells