1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00
This commit is contained in:
AlexVinS 2016-09-29 10:45:22 +03:00
parent 921d2f6210
commit e91a6d45e8

View File

@ -788,14 +788,23 @@ bool SacrificeMechanics::requiresCreatureTarget() const
///SpecialRisingSpellMechanics
ESpellCastProblem::ESpellCastProblem SpecialRisingSpellMechanics::canBeCast(const CBattleInfoCallback * cb, const SpellTargetingContext & ctx) const
{
const CStack * stack = cb->getStackIf([ctx](const CStack * s)
//find our possible target here
const CStack * stackToHeal = cb->getStackIf([ctx](const CStack * s)
{
const bool ownerMatches = !ctx.ti.smart || s->getOwner() == ctx.caster->getOwner();
return ownerMatches && s->isValidTarget(!ctx.ti.onlyAlive) && s->coversPos(ctx.destination);
});
if(nullptr == stack)
//find if there is stack preventing cast
const CStack * enemyStack = cb->getStackIf([ctx](const CStack * s)
{
const bool ownerMatches = ctx.ti.smart && s->getOwner() != ctx.caster->getOwner();
return ownerMatches && s->isValidTarget(true) && s->coversPos(ctx.destination);
});
if(nullptr == stackToHeal || nullptr != enemyStack)
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
return ESpellCastProblem::OK;