From 49075d6893504dc780e57a744bbb618a3e0a3f0e Mon Sep 17 00:00:00 2001 From: xenohedron Date: Thu, 8 Jun 2023 08:49:31 -0400 Subject: [PATCH] Fix #10442 (Unleash the Inferno) --- .../src/mage/cards/u/UnleashTheInferno.java | 19 +++++---- .../single/snc/UnleashTheInfernoTest.java | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/snc/UnleashTheInfernoTest.java diff --git a/Mage.Sets/src/mage/cards/u/UnleashTheInferno.java b/Mage.Sets/src/mage/cards/u/UnleashTheInferno.java index 4f116178aa5..33ccf27b203 100644 --- a/Mage.Sets/src/mage/cards/u/UnleashTheInferno.java +++ b/Mage.Sets/src/mage/cards/u/UnleashTheInferno.java @@ -70,17 +70,16 @@ class UnleashTheInfernoEffect extends OneShotEffect { int lethal = Math.min(permanent.getLethalDamage(source.getSourceId(), game), 7); permanent.damage(7, source, game); int excess = 7 - lethal; - if (lethal > 0) { - return true; + if (excess > 0) { + 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; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/snc/UnleashTheInfernoTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/snc/UnleashTheInfernoTest.java new file mode 100644 index 00000000000..c480a052ccb --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/snc/UnleashTheInfernoTest.java @@ -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); + + } + +}