浏览代码

Made onlyAlive flag a part of TargetInfo

AlexVinS 11 年之前
父节点
当前提交
7cf64a0628
共有 3 个文件被更改,包括 6 次插入5 次删除
  1. 4 5
      lib/CBattleCallback.cpp
  2. 1 0
      lib/CSpellHandler.cpp
  3. 1 0
      lib/CSpellHandler.h

+ 4 - 5
lib/CBattleCallback.cpp

@@ -2029,8 +2029,7 @@ 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
 	if (spell->id == SpellID::CHAIN_LIGHTNING)
@@ -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);
 		}
 	}

+ 1 - 0
lib/CSpellHandler.cpp

@@ -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;
 }

+ 1 - 0
lib/CSpellHandler.h

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