From b56aef9341853313cdf76cfc5fa465b903a700ee Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 4 Sep 2021 18:45:32 +0400 Subject: [PATCH] * Emergent Sequence - fixed that it doesn't put counters if no land play before (#8208); --- .../src/mage/cards/e/EmergentSequence.java | 19 +++-- .../single/stx/EmergentSequenceTest.java | 73 +++++++++++++++++++ 2 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/stx/EmergentSequenceTest.java diff --git a/Mage.Sets/src/mage/cards/e/EmergentSequence.java b/Mage.Sets/src/mage/cards/e/EmergentSequence.java index d73a381e70..6d24719b88 100644 --- a/Mage.Sets/src/mage/cards/e/EmergentSequence.java +++ b/Mage.Sets/src/mage/cards/e/EmergentSequence.java @@ -72,6 +72,8 @@ class EmergentSequenceEffect extends OneShotEffect { if (player == null) { return false; } + + // put land TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND_A); player.searchLibrary(target, source, game); Card card = player.getLibrary().getCard(target.getFirstTarget(), game); @@ -84,12 +86,18 @@ class EmergentSequenceEffect extends OneShotEffect { if (permanent == null) { return true; } + + // boost land game.addEffect(new BecomesCreatureTargetEffect( new FractalToken(), false, true, Duration.Custom ).setTargetPointer(new FixedTarget(permanent, game)), source); - permanent.addCounters(CounterType.P1P1.createInstance( - EmergentSequenceWatcher.getAmount(source.getControllerId(), game) - ), source.getControllerId(), source, game); + + // rules + // The last sentence of Emergent Sequence’s ability counts the land it put onto the battlefield. + // (2021-04-16) + // no ETB yet, so add +1 manually + int amount = 1 + EmergentSequenceWatcher.getAmount(source.getControllerId(), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game); return true; } } @@ -104,9 +112,8 @@ class EmergentSequenceWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.PLAY_LAND || - (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD - && ((EntersTheBattlefieldEvent) event).getTarget().isLand(game))) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + && ((EntersTheBattlefieldEvent) event).getTarget().isLand(game)) { playerMap.compute(event.getPlayerId(), (u, i) -> i == null ? 1 : Integer.sum(i, 1)); } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/stx/EmergentSequenceTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/stx/EmergentSequenceTest.java new file mode 100644 index 0000000000..1d2147a350 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/stx/EmergentSequenceTest.java @@ -0,0 +1,73 @@ +package org.mage.test.cards.single.stx; + +import mage.constants.CardType; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author JayDi85 + */ +public class EmergentSequenceTest extends CardTestPlayerBase { + + @Test + public void test_PlayFirst() { + removeAllCardsFromLibrary(playerA); + + // Search your library for a basic land card, put it onto the battlefield tapped, then shuffle. + // That land becomes a 0/0 green and blue Fractal creature that's still a land. Put a +1/+1 counter on + // it for each land you had enter the battlefield under your control this turn. + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); // land goes first to ignore cheated etb + addCard(Zone.HAND, playerA, "Emergent Sequence"); // {1}{G} + // + addCard(Zone.LIBRARY, playerA, "Swamp", 1); + addCard(Zone.LIBRARY, playerA, "Mountain", 1); + + // cast and etb land with 1x counter (counts from land) + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Emergent Sequence"); + addTarget(playerA, "Swamp"); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertType("Swamp", CardType.CREATURE, true); + assertCounterCount(playerA, "Swamp", CounterType.P1P1, 1); + assertPowerToughness(playerA, "Swamp", 1, 1); + } + + @Test + public void test_PlayAfterLand() { + removeAllCardsFromLibrary(playerA); + + // Search your library for a basic land card, put it onto the battlefield tapped, then shuffle. + // That land becomes a 0/0 green and blue Fractal creature that's still a land. Put a +1/+1 counter on + // it for each land you had enter the battlefield under your control this turn. + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); // land goes first to ignore cheated etb + addCard(Zone.HAND, playerA, "Emergent Sequence"); // {1}{G} + // + addCard(Zone.HAND, playerA, "Island", 1); + addCard(Zone.LIBRARY, playerA, "Swamp", 1); + addCard(Zone.LIBRARY, playerA, "Mountain", 1); + + // play land first + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Island"); + + // cast and etb land with 2x counter (counts from etb land + land before) + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Emergent Sequence"); + addTarget(playerA, "Swamp"); + + setStrictChooseMode(true); + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Island", 1); + assertType("Swamp", CardType.CREATURE, true); + assertCounterCount(playerA, "Swamp", CounterType.P1P1, 2); + assertPowerToughness(playerA, "Swamp", 2, 2); + } +}