* Emergent Sequence - fixed that it doesn't put counters if no land play before (#8208);

This commit is contained in:
Oleg Agafonov 2021-09-04 18:45:32 +04:00
parent 0f4a1f65ca
commit b56aef9341
2 changed files with 86 additions and 6 deletions

View file

@ -72,6 +72,8 @@ class EmergentSequenceEffect extends OneShotEffect {
if (player == null) { if (player == null) {
return false; return false;
} }
// put land
TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND_A); TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND_A);
player.searchLibrary(target, source, game); player.searchLibrary(target, source, game);
Card card = player.getLibrary().getCard(target.getFirstTarget(), game); Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
@ -84,12 +86,18 @@ class EmergentSequenceEffect extends OneShotEffect {
if (permanent == null) { if (permanent == null) {
return true; return true;
} }
// boost land
game.addEffect(new BecomesCreatureTargetEffect( game.addEffect(new BecomesCreatureTargetEffect(
new FractalToken(), false, true, Duration.Custom new FractalToken(), false, true, Duration.Custom
).setTargetPointer(new FixedTarget(permanent, game)), source); ).setTargetPointer(new FixedTarget(permanent, game)), source);
permanent.addCounters(CounterType.P1P1.createInstance(
EmergentSequenceWatcher.getAmount(source.getControllerId(), game) // rules
), source.getControllerId(), source, game); // The last sentence of Emergent Sequences 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; return true;
} }
} }
@ -104,9 +112,8 @@ class EmergentSequenceWatcher extends Watcher {
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.PLAY_LAND || if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD
(event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && ((EntersTheBattlefieldEvent) event).getTarget().isLand(game)) {
&& ((EntersTheBattlefieldEvent) event).getTarget().isLand(game))) {
playerMap.compute(event.getPlayerId(), (u, i) -> i == null ? 1 : Integer.sum(i, 1)); playerMap.compute(event.getPlayerId(), (u, i) -> i == null ? 1 : Integer.sum(i, 1));
} }
} }

View file

@ -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);
}
}