1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Formatting

This commit is contained in:
AlexVinS
2015-04-03 03:02:16 +03:00
parent 9d0b29b973
commit e4220fef82
2 changed files with 19 additions and 20 deletions

View File

@ -142,7 +142,7 @@ void DispellMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast *
for(auto stackID : packet->affectedCres) for(auto stackID : packet->affectedCres)
{ {
if(vstd::contains(packet->resisted, stackID)) if(vstd::contains(packet->resisted, stackID))
logGlobal->errorStream() << "Resistance to DISPELL"; logGlobal->errorStream() << "Resistance to DISPELL";
continue; continue;
CStack *s = battle->getStack(stackID); CStack *s = battle->getStack(stackID);
@ -165,9 +165,9 @@ ESpellCastProblem::ESpellCastProblem DispellMechanics::canBeCasted(const CBattle
if(s->hasBonus(Selector::sourceType(Bonus::SPELL_EFFECT), cachingStr.str())) if(s->hasBonus(Selector::sourceType(Bonus::SPELL_EFFECT), cachingStr.str()))
{ {
return ESpellCastProblem::OK; return ESpellCastProblem::OK;
} }
} }
return ESpellCastProblem::NO_APPROPRIATE_TARGET; return ESpellCastProblem::NO_APPROPRIATE_TARGET;
} }
@ -175,34 +175,33 @@ ESpellCastProblem::ESpellCastProblem DispellMechanics::isImmuneByStack(const CGH
{ {
//DISPELL ignores all immunities, so do not call default //DISPELL ignores all immunities, so do not call default
std::stringstream cachingStr; std::stringstream cachingStr;
cachingStr << "source_" << Bonus::SPELL_EFFECT; cachingStr << "source_" << Bonus::SPELL_EFFECT;
if(obj->hasBonus(Selector::sourceType(Bonus::SPELL_EFFECT), cachingStr.str())) if(obj->hasBonus(Selector::sourceType(Bonus::SPELL_EFFECT), cachingStr.str()))
{ {
return ESpellCastProblem::OK; return ESpellCastProblem::OK;
} }
return ESpellCastProblem::WRONG_SPELL_TARGET; return ESpellCastProblem::WRONG_SPELL_TARGET;
} }
void DispellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const void DispellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
{ {
DefaultSpellMechanics::applyBattleEffects(env, parameters, ctx); DefaultSpellMechanics::applyBattleEffects(env, parameters, ctx);
if(parameters.spellLvl > 2) if(parameters.spellLvl > 2)
{ {
//expert DISPELL also removes spell-created obstacles //expert DISPELL also removes spell-created obstacles
ObstaclesRemoved packet; ObstaclesRemoved packet;
for(const auto obstacle : parameters.cb->obstacles) for(const auto obstacle : parameters.cb->obstacles)
{ {
if(obstacle->obstacleType == CObstacleInstance::FIRE_WALL if(obstacle->obstacleType == CObstacleInstance::FIRE_WALL
|| obstacle->obstacleType == CObstacleInstance::FORCE_FIELD || obstacle->obstacleType == CObstacleInstance::FORCE_FIELD
|| obstacle->obstacleType == CObstacleInstance::LAND_MINE) || obstacle->obstacleType == CObstacleInstance::LAND_MINE)
packet.obstacles.insert(obstacle->uniqueID); packet.obstacles.insert(obstacle->uniqueID);
} }
if(!packet.obstacles.empty()) if(!packet.obstacles.empty())
env->sendAndApply(&packet); env->sendAndApply(&packet);
} }
@ -477,7 +476,7 @@ void RemoveObstacleMechanics::applyBattleEffects(const SpellCastEnvironment * en
ESpellCastProblem::ESpellCastProblem SacrificeMechanics::canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const ESpellCastProblem::ESpellCastProblem SacrificeMechanics::canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const
{ {
// for sacrifice we have to check for 2 targets (one dead to resurrect and one living to destroy) // for sacrifice we have to check for 2 targets (one dead to resurrect and one living to destroy)
bool targetExists = false; bool targetExists = false;
bool targetToSacrificeExists = false; bool targetToSacrificeExists = false;
@ -498,9 +497,9 @@ ESpellCastProblem::ESpellCastProblem SacrificeMechanics::canBeCasted(const CBatt
if(targetExists && targetToSacrificeExists) if(targetExists && targetToSacrificeExists)
break; break;
} }
} }
if(targetExists && targetToSacrificeExists) if(targetExists && targetToSacrificeExists)
return ESpellCastProblem::OK; return ESpellCastProblem::OK;
else else

View File

@ -41,20 +41,20 @@ class DLL_LINKAGE DispellMechanics : public DefaultSpellMechanics
public: public:
DispellMechanics(CSpell * s): DefaultSpellMechanics(s){}; DispellMechanics(CSpell * s): DefaultSpellMechanics(s){};
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override; ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;
void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final; void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override; ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
protected: protected:
void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override; void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
}; };
class DLL_LINKAGE EarthquakeMechanics : public DefaultSpellMechanics class DLL_LINKAGE EarthquakeMechanics : public DefaultSpellMechanics
{ {
public: public:
EarthquakeMechanics(CSpell * s): DefaultSpellMechanics(s){}; EarthquakeMechanics(CSpell * s): DefaultSpellMechanics(s){};
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override; ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
protected: protected:
void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override; void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
}; };
class DLL_LINKAGE HypnotizeMechanics : public DefaultSpellMechanics class DLL_LINKAGE HypnotizeMechanics : public DefaultSpellMechanics
@ -119,7 +119,7 @@ class DLL_LINKAGE SummonMechanics : public DefaultSpellMechanics
public: public:
SummonMechanics(CSpell * s): DefaultSpellMechanics(s){}; SummonMechanics(CSpell * s): DefaultSpellMechanics(s){};
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override; ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
protected: protected:
void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override; void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
}; };