Files
vcmi/lib/spells/ObstacleCasterProxy.cpp
T

97 lines
2.1 KiB
C++
Raw Normal View History

2023-03-19 03:44:10 +03:00
/*
* ObstacleCasterProxy.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"
2023-03-19 03:44:10 +03:00
#include "ObstacleCasterProxy.h"
VCMI_LIB_NAMESPACE_BEGIN
namespace spells
{
2023-03-20 14:02:09 +03:00
ObstacleCasterProxy::ObstacleCasterProxy(PlayerColor owner_, const Caster * hero_, const SpellCreatedObstacle & obs_):
SilentCaster(owner_, hero_),
obs(obs_)
2023-03-19 03:44:10 +03:00
{
}
int32_t ObstacleCasterProxy::getSpellSchoolLevel(const Spell * spell, int32_t * outSelectedSchool) const
{
return obs.spellLevel;
}
int32_t ObstacleCasterProxy::getEffectLevel(const Spell * spell) const
{
return obs.spellLevel;
}
int64_t ObstacleCasterProxy::getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const
{
if(actualCaster)
return std::max<int64_t>(actualCaster->getSpellBonus(spell, base, affectedStack), obs.minimalDamage);
2023-03-20 14:02:09 +03:00
return std::max<int64_t>(base, obs.minimalDamage);
2023-03-19 03:44:10 +03:00
}
int32_t ObstacleCasterProxy::getEffectPower(const Spell * spell) const
{
return obs.casterSpellPower;
}
int32_t ObstacleCasterProxy::getEnchantPower(const Spell * spell) const
{
return obs.casterSpellPower;
}
int64_t ObstacleCasterProxy::getEffectValue(const Spell * spell) const
{
if(actualCaster)
return std::max(static_cast<int64_t>(obs.minimalDamage), actualCaster->getEffectValue(spell));
else
return obs.minimalDamage;
}
2023-04-11 19:37:35 +03:00
int32_t SilentCaster::manaLimit() const
{
return 0;
}
2023-03-20 14:02:09 +03:00
SilentCaster::SilentCaster(PlayerColor owner_, const Caster * hero_):
ProxyCaster(hero_),
owner(std::move(owner_))
2023-03-19 03:44:10 +03:00
{
2023-03-20 14:02:09 +03:00
}
void SilentCaster::getCasterName(MetaString & text) const
{
logGlobal->error("Unexpected call to SilentCaster::getCasterName");
}
void SilentCaster::getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const
{
//do nothing
}
void SilentCaster::spendMana(ServerCallback * server, const int spellCost) const
{
//do nothing
}
PlayerColor SilentCaster::getCasterOwner() const
{
if(actualCaster)
return actualCaster->getCasterOwner();
2023-03-19 03:44:10 +03:00
return owner;
}
}
2023-04-11 19:37:35 +03:00
VCMI_LIB_NAMESPACE_END