mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Fix Sacrifice spell
This commit is contained in:
@@ -264,6 +264,7 @@ void BattleActionsController::reorderPossibleActionsPriority(const CStack * stac
|
|||||||
case PossiblePlayerBattleAction::NO_LOCATION:
|
case PossiblePlayerBattleAction::NO_LOCATION:
|
||||||
case PossiblePlayerBattleAction::FREE_LOCATION:
|
case PossiblePlayerBattleAction::FREE_LOCATION:
|
||||||
case PossiblePlayerBattleAction::OBSTACLE:
|
case PossiblePlayerBattleAction::OBSTACLE:
|
||||||
|
case PossiblePlayerBattleAction::SACRIFICE:
|
||||||
if(!stack->hasBonusOfType(BonusType::NO_SPELLCAST_BY_DEFAULT) && targetStack != nullptr)
|
if(!stack->hasBonusOfType(BonusType::NO_SPELLCAST_BY_DEFAULT) && targetStack != nullptr)
|
||||||
{
|
{
|
||||||
PlayerColor stackOwner = owner.getBattle()->battleGetOwner(targetStack);
|
PlayerColor stackOwner = owner.getBattle()->battleGetOwner(targetStack);
|
||||||
@@ -698,7 +699,14 @@ bool BattleActionsController::actionIsLegal(PossiblePlayerBattleAction action, c
|
|||||||
return selectedStack && isCastingPossibleHere(action.spell().toSpell(), selectedStack, targetHex);
|
return selectedStack && isCastingPossibleHere(action.spell().toSpell(), selectedStack, targetHex);
|
||||||
|
|
||||||
case PossiblePlayerBattleAction::SACRIFICE: //choose our living stack to sacrifice
|
case PossiblePlayerBattleAction::SACRIFICE: //choose our living stack to sacrifice
|
||||||
return targetStack && targetStack != selectedStack && targetStackOwned && targetStack->alive();
|
{
|
||||||
|
if(!targetStack)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto unit = targetStack->acquire();
|
||||||
|
return targetStack != selectedStack && targetStackOwned && targetStack->alive()
|
||||||
|
&& unit->isLiving() && !unit->hasBonusOfType(BonusType::MECHANICAL);
|
||||||
|
}
|
||||||
|
|
||||||
case PossiblePlayerBattleAction::OBSTACLE:
|
case PossiblePlayerBattleAction::OBSTACLE:
|
||||||
case PossiblePlayerBattleAction::FREE_LOCATION:
|
case PossiblePlayerBattleAction::FREE_LOCATION:
|
||||||
|
|||||||
@@ -59,9 +59,10 @@ bool Sacrifice::applicable(Problem & problem, const Mechanics * m) const
|
|||||||
bool targetExists = false;
|
bool targetExists = false;
|
||||||
bool targetToSacrificeExists = false;
|
bool targetToSacrificeExists = false;
|
||||||
|
|
||||||
for(auto & target : targets)
|
for(const battle::Unit * target : targets)
|
||||||
{
|
{
|
||||||
if(target->alive())
|
auto unit = target->acquire();
|
||||||
|
if(target->alive() && unit->isLiving() && !unit->hasBonusOfType(BonusType::MECHANICAL))
|
||||||
targetToSacrificeExists = true;
|
targetToSacrificeExists = true;
|
||||||
else if(target->isDead())
|
else if(target->isDead())
|
||||||
targetExists = true;
|
targetExists = true;
|
||||||
@@ -89,12 +90,15 @@ bool Sacrifice::applicable(Problem & problem, const Mechanics * m, const EffectT
|
|||||||
if(!Heal::applicable(problem, m, healTarget))
|
if(!Heal::applicable(problem, m, healTarget))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if(healTarget.front().unitValue->alive())
|
||||||
|
return false;
|
||||||
|
|
||||||
if(target.size() == 2)
|
if(target.size() == 2)
|
||||||
{
|
{
|
||||||
const auto *victim = target.at(1).unitValue;
|
const auto *victim = target.at(1).unitValue;
|
||||||
if(!victim)
|
if(!victim)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return victim->alive() && getStackFilter(m, false, victim) && isReceptive(m, victim);
|
return victim->alive() && getStackFilter(m, false, victim) && isReceptive(m, victim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user