2018-03-02 13:22:51 +03:00
|
|
|
/*
|
|
|
|
|
* AbilityCaster.cpp, part of VCMI engine
|
|
|
|
|
*
|
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
|
*
|
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
|
|
#include "AbilityCaster.h"
|
|
|
|
|
|
2018-03-17 17:58:30 +03:00
|
|
|
#include <vcmi/spells/Spell.h>
|
|
|
|
|
|
2018-03-02 13:22:51 +03:00
|
|
|
#include "../battle/Unit.h"
|
|
|
|
|
|
2022-07-26 16:07:42 +03:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
2018-03-02 13:22:51 +03:00
|
|
|
namespace spells
|
|
|
|
|
{
|
|
|
|
|
|
2018-03-17 17:58:30 +03:00
|
|
|
AbilityCaster::AbilityCaster(const battle::Unit * actualCaster_, int32_t baseSpellLevel_)
|
2018-03-02 13:22:51 +03:00
|
|
|
: ProxyCaster(actualCaster_),
|
|
|
|
|
baseSpellLevel(baseSpellLevel_)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbilityCaster::~AbilityCaster() = default;
|
|
|
|
|
|
2023-11-05 18:58:07 +02:00
|
|
|
int32_t AbilityCaster::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
2018-03-02 13:22:51 +03:00
|
|
|
{
|
2018-03-17 17:58:30 +03:00
|
|
|
auto skill = baseSpellLevel;
|
2023-03-19 02:30:06 +03:00
|
|
|
const auto * unit = dynamic_cast<const battle::Unit*>(actualCaster);
|
2018-03-02 13:22:51 +03:00
|
|
|
|
|
|
|
|
if(spell->getLevel() > 0)
|
|
|
|
|
{
|
2023-10-21 14:50:42 +03:00
|
|
|
vstd::amax(skill, unit->valOfBonuses(BonusType::MAGIC_SCHOOL_SKILL, BonusSubtypeID(SpellSchool::ANY)));
|
2018-03-02 13:22:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vstd::amax(skill, 0);
|
|
|
|
|
vstd::amin(skill, 3);
|
|
|
|
|
|
|
|
|
|
return static_cast<ui8>(skill); //todo: unify spell school level type
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-17 17:58:30 +03:00
|
|
|
int32_t AbilityCaster::getEffectLevel(const Spell * spell) const
|
2018-03-02 13:22:51 +03:00
|
|
|
{
|
|
|
|
|
return getSpellSchoolLevel(spell);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbilityCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit*> & attacked, MetaString & text) const
|
|
|
|
|
{
|
|
|
|
|
//do nothing
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-17 17:58:30 +03:00
|
|
|
void AbilityCaster::spendMana(ServerCallback * server, const int32_t spellCost) const
|
2018-03-02 13:22:51 +03:00
|
|
|
{
|
|
|
|
|
//do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace spells
|
2022-07-26 16:07:42 +03:00
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|