1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

SpellSchool: use identifier instead of int

Needs redifinition of MAGIC_SCHOOL_SKILL in all mods
This commit is contained in:
Konstantin P
2023-05-05 21:28:07 +03:00
committed by Konstantin
parent 8600e3035a
commit 057a33c508
24 changed files with 93 additions and 65 deletions

View File

@@ -38,7 +38,7 @@ namespace SpellConfig
{
static const std::string LEVEL_NAMES[] = {"none", "basic", "advanced", "expert"};
static const spells::SchoolInfo SCHOOL[4] =
const spells::SchoolInfo SCHOOL[4] =
{
{
ESpellSchool::AIR,
@@ -63,7 +63,7 @@ static const spells::SchoolInfo SCHOOL[4] =
};
//order as described in http://bugs.vcmi.eu/view.php?id=91
static const ESpellSchool SCHOOL_ORDER[4] =
static const SpellSchool SCHOOL_ORDER[4] =
{
ESpellSchool::AIR, //=0
ESpellSchool::FIRE, //=1
@@ -150,9 +150,9 @@ spells::AimType CSpell::getTargetType() const
void CSpell::forEachSchool(const std::function<void(const spells::SchoolInfo &, bool &)>& cb) const
{
bool stop = false;
for(ESpellSchool iter : SpellConfig::SCHOOL_ORDER)
for(auto iter : SpellConfig::SCHOOL_ORDER)
{
const spells::SchoolInfo & cnf = SpellConfig::SCHOOL[static_cast<ui8>(iter)];
const spells::SchoolInfo & cnf = SpellConfig::SCHOOL[iter];
if(school.at(cnf.id))
{
cb(cnf, stop);
@@ -381,15 +381,15 @@ int64_t CSpell::adjustRawDamage(const spells::Caster * caster, const battle::Uni
//applying protections - when spell has more then one elements, only one protection should be applied (I think)
forEachSchool([&](const spells::SchoolInfo & cnf, bool & stop)
{
if(bearer->hasBonusOfType(BonusType::SPELL_DAMAGE_REDUCTION, static_cast<ui8>(cnf.id)))
if(bearer->hasBonusOfType(BonusType::SPELL_DAMAGE_REDUCTION, cnf.id))
{
ret *= 100 - bearer->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, static_cast<ui8>(cnf.id));
ret *= 100 - bearer->valOfBonuses(BonusType::SPELL_DAMAGE_REDUCTION, cnf.id);
ret /= 100;
stop = true; //only bonus from one school is used
}
});
CSelector selector = Selector::type()(BonusType::SPELL_DAMAGE_REDUCTION).And(Selector::subtype()(-1));
CSelector selector = Selector::typeSubtype(BonusType::SPELL_DAMAGE_REDUCTION, SpellSchool(ESpellSchool::ANY));
//general spell dmg reduction, works only on magical effects
if(bearer->hasBonus(selector) && isMagical())