AbilityCaster.cpp 1.3 KB

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