Fix #10442 (Unleash the Inferno)

This commit is contained in:
xenohedron 2023-06-08 08:49:31 -04:00
parent 74920afd71
commit 49075d6893
2 changed files with 48 additions and 10 deletions

View file

@ -70,17 +70,16 @@ class UnleashTheInfernoEffect extends OneShotEffect {
int lethal = Math.min(permanent.getLethalDamage(source.getSourceId(), game), 7); int lethal = Math.min(permanent.getLethalDamage(source.getSourceId(), game), 7);
permanent.damage(7, source, game); permanent.damage(7, source, game);
int excess = 7 - lethal; int excess = 7 - lethal;
if (lethal > 0) { if (excess > 0) {
return true; ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false);
FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent(
"artifact or enchantment an opponent controls with mana value less than or equal to " + excess
);
filter.add(TargetController.OPPONENT.getControllerPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, excess + 1));
ability.addTarget(new TargetPermanent(filter));
game.fireReflexiveTriggeredAbility(ability, source);
} }
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false);
FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent(
"artifact or enchantment an opponent controls with mana value less that or equal to " + excess
);
filter.add(TargetController.OPPONENT.getControllerPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, excess));
ability.addTarget(new TargetPermanent(filter));
game.fireReflexiveTriggeredAbility(ability, source);
return true; return true;
} }
} }

View file

@ -0,0 +1,39 @@
package org.mage.test.cards.single.snc;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class UnleashTheInfernoTest extends CardTestPlayerBase {
/**
* Reported bug: https://github.com/magefree/mage/issues/10442
*/
@Test
public void testExcessDamage() {
addCard(Zone.BATTLEFIELD, playerB, "Stone Golem"); // creature to damage (4 toughness)
addCard(Zone.BATTLEFIELD, playerB, "Crucible of Worlds"); // artifact to destroy (cmc 3)
addCard(Zone.BATTLEFIELD, playerB, "Vedalken Orrery"); // artifact not legal target (cmc 4)
addCard(Zone.HAND, playerA, "Unleash the Inferno"); // spell to test
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 1);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Unleash the Inferno");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Unleash the Inferno", 1);
assertGraveyardCount(playerB, "Stone Golem", 1);
assertGraveyardCount(playerB, "Crucible of Worlds", 1);
assertPermanentCount(playerB, "Vedalken Orrery", 1);
}
}