From 470fd4c75a9212de89ee0a131c2d1394f35450b2 Mon Sep 17 00:00:00 2001 From: Quercitron Date: Sat, 1 Sep 2018 15:06:12 +0300 Subject: [PATCH] * Reality Scramble - fix that the last matching card is put onto the battlefield instead of the first matching card (fixes #5290). --- .../src/mage/cards/r/RealityScramble.java | 7 +++- .../cards/single/c18/RealityScrambleTest.java | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/c18/RealityScrambleTest.java diff --git a/Mage.Sets/src/mage/cards/r/RealityScramble.java b/Mage.Sets/src/mage/cards/r/RealityScramble.java index f3f8096971..6eeacc43ed 100644 --- a/Mage.Sets/src/mage/cards/r/RealityScramble.java +++ b/Mage.Sets/src/mage/cards/r/RealityScramble.java @@ -38,7 +38,9 @@ public final class RealityScramble extends CardImpl { public RealityScramble(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}{R}"); - // Put target permanent you own on the bottom of your library. Reveal cards from the top of your library until you reveal a card that shares a card type with that permanent. Put that card onto the battlefield and the rest on the bottom of your library in a random order. + // Put target permanent you own on the bottom of your library. Reveal cards from the top of your library + // until you reveal a card that shares a card type with that permanent. Put that card onto the battlefield + // and the rest on the bottom of your library in a random order. this.getSpellAbility().addEffect(new RealityScrambleEffect()); this.getSpellAbility().addTarget(new TargetPermanent(filter)); @@ -99,6 +101,9 @@ class RealityScrambleEffect extends OneShotEffect { break; } } + if (cardToPlay != null) { + break; + } } controller.revealCards(source, toReveal, game); if (cardToPlay != null) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/c18/RealityScrambleTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/c18/RealityScrambleTest.java new file mode 100644 index 0000000000..a72bea1811 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/c18/RealityScrambleTest.java @@ -0,0 +1,32 @@ +package org.mage.test.cards.single.c18; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author Quercitron + */ +public class RealityScrambleTest extends CardTestPlayerBase { + + @Test + public void testFirstCardIsCast() { + // Put target permanent you own on the bottom of your library. Reveal cards from the top of your library until + // you reveal a card that shares a card type with that permanent. Put that card onto the battlefield and + // the rest on the bottom of your library in a random order. + addCard(Zone.HAND, playerA, "Reality Scramble"); + addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.LIBRARY, playerA, "Storm Crow"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Reality Scramble", "Grizzly Bears"); + + execute(); + + assertPermanentCount(playerA, "Grizzly Bears", 0); + assertPermanentCount(playerA, "Storm Crow", 1); + } + +}