1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00
This commit is contained in:
DjWarmonger 2013-07-28 10:32:01 +00:00
parent 257be7a968
commit aa6626bc35

View File

@ -1617,22 +1617,21 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
if(!spell->combatSpell)
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
//TODO?
//if(NBonus::hasOfType(heroes[1-cside], Bonus::SPELL_IMMUNITY, spell->id)) //non - casting hero provides immunity for this spell
// return ESpellCastProblem::SECOND_HEROS_SPELL_IMMUNITY;
if(spell->isNegative())
if(spell->isNegative() || spell->hasEffects())
{
bool allEnemiesImmune = true;
for(auto enemyStack : battleAliveStacks(!side))
bool allStacksImmune = true;
//we are interested only in enemy stacks when casting offensive spells
auto stacks = spell->isNegative() ? battleAliveStacks(!side) : battleAliveStacks();
for(auto stack : stacks)
{
if(!enemyStack->hasBonusOfType(Bonus::SPELL_IMMUNITY, spell->id))
if(!battleIsImmune(castingHero, spell, mode, stack->position))
{
allEnemiesImmune = false;
allStacksImmune = false;
break;
}
}
if(allEnemiesImmune)
if(allStacksImmune)
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
}