diff --git a/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java b/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java index d9cdc571ff..580cbdc595 100644 --- a/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java +++ b/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java @@ -17,6 +17,7 @@ import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; import java.util.UUID; @@ -88,7 +89,7 @@ class YorvoLordOfGarenbrigEffect extends OneShotEffect { return false; } sourcePerm.addCounters(CounterType.P1P1.createInstance(), source, game); - Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent permanent = ((FixedTarget) targetPointer).getTargetedPermanentOrLKIBattlefield(game); if (permanent == null) { return true; } diff --git a/Mage.Tests/src/test/java/org/mage/test/commander/duel/YorvoLordOfGarenbrigOnCommandersTest.java b/Mage.Tests/src/test/java/org/mage/test/commander/duel/YorvoLordOfGarenbrigOnCommandersTest.java new file mode 100644 index 0000000000..a9e7e1ed57 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/commander/duel/YorvoLordOfGarenbrigOnCommandersTest.java @@ -0,0 +1,82 @@ +package org.mage.test.commander.duel; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestCommanderDuelBase; + +/** + * @author JayDi85 + */ +public class YorvoLordOfGarenbrigOnCommandersTest extends CardTestCommanderDuelBase { + + @Test + public void test_TriggerOnSimpleCommander() { + // Yorvo, Lord of Garenbrig enters the battlefield with four +1/+1 counters on it. + // Whenever another green creature enters the battlefield under your control, put a +1/+1 counter on Yorvo. Then if that creature’s power is greater than Yorvo’s power, put another +1/+1 counter on Yorvo. + addCard(Zone.HAND, playerA, "Yorvo, Lord of Garenbrig", 5); // {G}{G}{G} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); + // + addCard(Zone.COMMAND, playerA, "Aggressive Mammoth"); // {3}{G}{G}{G} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 6); + + // prepare yorvo + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Yorvo, Lord of Garenbrig"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + + // cast commander + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Aggressive Mammoth"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + checkPermanentCounters("must get +2", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Yorvo, Lord of Garenbrig", CounterType.P1P1, 4 + 2); + checkPermanentCount("must play commander", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Aggressive Mammoth", 1); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } + + @Test + public void test_TriggerOnUroTitalOfNaturesWrath() { + // Yorvo, Lord of Garenbrig enters the battlefield with four +1/+1 counters on it. + // Whenever another green creature enters the battlefield under your control, put a +1/+1 counter on Yorvo. Then if that creature’s power is greater than Yorvo’s power, put another +1/+1 counter on Yorvo. + addCard(Zone.HAND, playerA, "Yorvo, Lord of Garenbrig", 5); // {G}{G}{G} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 3); + // + // When Uro enters the battlefield, sacrifice it unless it escaped. + // Whenever Uro enters the battlefield or attacks, you gain 3 life and draw a card, then you may put a land card from your hand onto the battlefield. + // Escape-{G}{G}{U}{U}, Exile five other cards from your graveyard. (You may cast this card from your graveyard for its escape cost.) + addCard(Zone.COMMAND, playerA, "Uro, Titan of Nature's Wrath"); // {1}{G}{U} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + addCard(Zone.BATTLEFIELD, playerA, "Island", 1); + + // prepare yorvo + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Yorvo, Lord of Garenbrig"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + + // cast commander + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Uro, Titan of Nature's Wrath"); + + // If the entering green creature dies before Yorvo’s triggered ability resolves, use its power as it last + // existed on the battlefield to determine whether Yorvo gets a second +1/+1 counter. + // (2019-10-04) + + // order triggers to remove commander first + setChoice(playerA, "Whenever {this} enters the battlefield or attacks"); // draw trigger + setChoice(playerA, "Whenever another green creature enters the battlefield"); // get counters trigger + //setChoice(playerA, "When {this} enters the battlefield, sacrifice it"); // sacrifice trigger must be on top + + setChoice(playerA, "Yes"); // return commander to command zone + setChoice(playerA, "No"); // do not put land to battlefield + + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + checkPermanentCounters("must get +2", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Yorvo, Lord of Garenbrig", CounterType.P1P1, 4 + 2); + checkCommandCardCount("return commander", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Uro, Titan of Nature's Wrath", 1); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + } +}