AbilityCaster.cpp 1.4 KB

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