diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/CommanderAsIndomitableCreativityCastTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/CommanderAsIndomitableCreativityCastTest.java new file mode 100644 index 00000000000..5b946292e44 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/CommanderAsIndomitableCreativityCastTest.java @@ -0,0 +1,66 @@ +package org.mage.test.cards.continuous; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestCommander4Players; + +/** + * @author JayDi85 + */ +public class CommanderAsIndomitableCreativityCastTest extends CardTestCommander4Players { + + // target adjusters test in command zone + + // Player order: A -> D -> C -> B + + // https://github.com/magefree/mage/issues/5852 + // Indomitable Creativity + // Destroy X target artifacts and/or creatures. For each permanent destroyed this way, + // its controller reveals cards from the top of their library until an artifact or creature card is revealed + // and exiles that card. Those players put the exiled cards onto the battlefield, then shuffle their libraries. + + @Test + public void test_CastFromHand() { + addCard(Zone.HAND, playerA, "Indomitable Creativity", 1); // {X}{R}{R}{R} + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); + + checkPermanentCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 1); + + // cast with X=1 and exile + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Indomitable Creativity"); + setChoice(playerA, "X=1"); + addTarget(playerA, "Balduvian Bears"); + + checkPermanentCount("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Balduvian Bears", 0); + + setStopAt(1, PhaseStep.END_TURN); + setStrictChooseMode(true); + execute(); + assertAllCommandsUsed(); + } + + @Test + public void test_CastFromCommand() { + addCard(Zone.COMMAND, playerA, "Indomitable Creativity", 1); // {X}{R}{R}{R} + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.BATTLEFIELD, playerA, "Balduvian Bears", 1); + + checkPermanentCount("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 1); + + // cast with X=1 and exile + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Indomitable Creativity"); + setChoice(playerA, "X=1"); + addTarget(playerA, "Balduvian Bears"); + setChoice(playerA, "Yes"); // return spell as commander + + checkPermanentCount("after", 1, PhaseStep.BEGIN_COMBAT, playerA, "Balduvian Bears", 0); + + setStopAt(1, PhaseStep.END_TURN); + setStrictChooseMode(true); + execute(); + assertAllCommandsUsed(); + } + +} diff --git a/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java b/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java index 397c4dfd158..bf16207f279 100644 --- a/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java +++ b/Mage/src/main/java/mage/abilities/common/CastCommanderAbility.java @@ -16,6 +16,8 @@ public class CastCommanderAbility extends SpellAbility { this.getCosts().addAll(card.getSpellAbility().getCosts().copy()); this.getEffects().addAll(card.getSpellAbility().getEffects().copy()); this.getTargets().addAll(card.getSpellAbility().getTargets().copy()); + this.setTargetAdjuster(card.getSpellAbility().getTargetAdjuster()); + this.setCostAdjuster(card.getSpellAbility().getCostAdjuster()); this.timing = card.getSpellAbility().getTiming(); } else { throw new IllegalStateException("Cast commander ability must be used with spell ability only: " + card.getName());