1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

simplify a bit

This commit is contained in:
AlexVinS 2015-03-18 14:28:34 +03:00
parent 729855ff60
commit cff8ecda46

View File

@ -167,7 +167,7 @@ void EarthquakeMechanics::applyBattleEffects(const SpellCastEnvironment * env, B
return;
}
//start with all damagable parts
//start with all destructible parts
std::set<EWallPart::EWallPart> possibleTargets =
{
EWallPart::KEEP,
@ -182,25 +182,14 @@ void EarthquakeMechanics::applyBattleEffects(const SpellCastEnvironment * env, B
assert(possibleTargets.size() == EWallPart::PARTS_COUNT);
int targetsToAttack = 2;
switch(parameters.spellLvl)
{
case 2:
targetsToAttack = 3;
break;
case 3:
targetsToAttack = 4;
break;
default:
break;
}
const int targetsToAttack = 2 + std::max<int>(parameters.spellLvl - 1, 0);
CatapultAttack ca;
ca.attacker = -1;
do
for(int i = 0; i < targetsToAttack; i++)
{
//Any destructible part can be hit regardless of its HP. Multiple hit on same target is allowed.
EWallPart::EWallPart target = *RandomGeneratorUtil::nextItem(possibleTargets, env->getRandomGenerator());
CatapultAttack::AttackInfo attackInfo;
@ -241,11 +230,8 @@ void EarthquakeMechanics::applyBattleEffects(const SpellCastEnvironment * env, B
}
if(bsr.stackIDs.size()>0)
env->sendAndApply(&bsr);
}
targetsToAttack--;
}
while(targetsToAttack > 0);
}
};
env->sendAndApply(&ca);
}