1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Made onlyAlive flag a part of TargetInfo

This commit is contained in:
AlexVinS
2014-05-18 13:20:36 +04:00
parent 6bf4140145
commit 7cf64a0628
3 changed files with 6 additions and 5 deletions

View File

@@ -2029,7 +2029,6 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
const ui8 attackerSide = playerToSide(attackerOwner) == 1;
const auto attackedHexes = spell->rangeInHexes(destinationTile, skillLevel, attackerSide);
const bool onlyAlive = !spell->isRisingSpell(); //when casting resurrection or animate dead we should be allow to select dead stack
const CSpell::TargetInfo ti = spell->getTargetInfo(skillLevel);
//TODO: more generic solution for mass spells
@@ -2068,7 +2067,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
{
for(BattleHex hex : attackedHexes)
{
if(const CStack * st = battleGetStackByPos(hex, onlyAlive))
if(const CStack * st = battleGetStackByPos(hex, ti.onlyAlive))
{
if (spell->id == SpellID::DEATH_CLOUD) //Death Cloud //TODO: fireball and fire immunity
{
@@ -2087,7 +2086,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
auto predicate = [=](const CStack * s){
const bool positiveToAlly = spell->isPositive() && s->owner == attackerOwner;
const bool negativeToEnemy = spell->isNegative() && s->owner != attackerOwner;
const bool validTarget = s->isValidTarget(!onlyAlive); //todo: this should be handled by spell class
const bool validTarget = s->isValidTarget(!ti.onlyAlive); //todo: this should be handled by spell class
//for single target spells select stacks covering destination tile
const bool rangeCovers = ti.massive || s->coversPos(destinationTile);
@@ -2128,7 +2127,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
{
for(BattleHex hex : attackedHexes)
{
if(const CStack * st = battleGetStackByPos(hex, onlyAlive))
if(const CStack * st = battleGetStackByPos(hex, ti.onlyAlive))
attackedCres.insert(st);
}
}

View File

@@ -287,6 +287,7 @@ const CSpell::TargetInfo CSpell::getTargetInfo(const int level) const
info.type = getTargetType();
info.smart = levelInfo.smartTarget;
info.massive = levelInfo.range == "X";
info.onlyAlive = !isRisingSpell();
return info;
}

View File

@@ -60,6 +60,7 @@ public:
ETargetType type;
bool smart;
bool massive;
bool onlyAlive;
};
SpellID id;