From 524f46e7e5077a39875d804265486e401f295e34 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 17 Nov 2021 19:23:16 +0400 Subject: [PATCH] * Uba Mask - fixed that it doesn't work with MDF cards (#8222); --- Mage.Sets/src/mage/cards/u/UbaMask.java | 4 +- ...thsWail.java => HorobiDeathsWailTest.java} | 2 +- .../test/cards/single/chk/UbaMaskTest.java | 88 +++++++++++++++++++ 3 files changed, 91 insertions(+), 3 deletions(-) rename Mage.Tests/src/test/java/org/mage/test/cards/single/chk/{Test_HorobiDeathsWail.java => HorobiDeathsWailTest.java} (93%) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/chk/UbaMaskTest.java diff --git a/Mage.Sets/src/mage/cards/u/UbaMask.java b/Mage.Sets/src/mage/cards/u/UbaMask.java index 33c5751767..d51f4b9255 100644 --- a/Mage.Sets/src/mage/cards/u/UbaMask.java +++ b/Mage.Sets/src/mage/cards/u/UbaMask.java @@ -1,4 +1,3 @@ - package mage.cards.u; import mage.MageObject; @@ -14,12 +13,12 @@ import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.players.Player; +import mage.util.CardUtil; import mage.watchers.Watcher; import java.util.*; /** - * * @author LevelX2 */ public final class UbaMask extends CardImpl { @@ -112,6 +111,7 @@ class UbaMaskPlayEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + objectId = CardUtil.getMainCardId(game, objectId); // for split cards Card card = game.getCard(objectId); if (card != null && affectedControllerId.equals(card.getOwnerId()) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/Test_HorobiDeathsWail.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/HorobiDeathsWailTest.java similarity index 93% rename from Mage.Tests/src/test/java/org/mage/test/cards/single/chk/Test_HorobiDeathsWail.java rename to Mage.Tests/src/test/java/org/mage/test/cards/single/chk/HorobiDeathsWailTest.java index 5279f5be79..9b8f2ac984 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/Test_HorobiDeathsWail.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/HorobiDeathsWailTest.java @@ -6,7 +6,7 @@ import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; -public class Test_HorobiDeathsWail extends CardTestPlayerBase { +public class HorobiDeathsWailTest extends CardTestPlayerBase { // issue 7772 @Test diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/UbaMaskTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/UbaMaskTest.java new file mode 100644 index 0000000000..8973bebdab --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/chk/UbaMaskTest.java @@ -0,0 +1,88 @@ +package org.mage.test.cards.single.chk; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.player.TestPlayer; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author JayDi85 + */ +public class UbaMaskTest extends CardTestPlayerBase { + + @Test + public void test_NormalCard() { + skipInitShuffling(); + + // If a player would draw a card, that player exiles that card face up instead. + // Each player may play cards they exiled with Uba Mask this turn. + addCard(Zone.BATTLEFIELD, playerA, "Uba Mask"); + // + addCard(Zone.LIBRARY, playerA, "Grizzly Bears"); // {1}{G} + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + // + addCard(Zone.LIBRARY, playerB, "Bronze Sable"); // {2} + addCard(Zone.BATTLEFIELD, playerB, "Forest", 2); + + // turn 1 - no draws + checkExileCount("no exile on turn 1 for A", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", 0); + checkExileCount("no exile on turn 1 for B", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Bronze Sable", 0); + + // turn 2 - B draw and exile + checkExileCount("no exile on turn 2 for A", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", 0); + checkExileCount("exiled on turn 2 for B", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Bronze Sable", 1); + checkPlayableAbility("A play on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", false); + checkPlayableAbility("A play on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Bronze Sable", false); + checkPlayableAbility("B play on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Grizzly Bears", false); + checkPlayableAbility("B play on 2", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Bronze Sable", true); + + // turn 3 - A draw and exile + checkExileCount("exiled on turn 3 for A", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears", 1); + checkExileCount("no exile on turn 3 for B", 3, PhaseStep.PRECOMBAT_MAIN, playerB, "Bronze Sable", 1); // exiled on prev turn + checkPlayableAbility("A play on 3", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Grizzly Bears", true); + checkPlayableAbility("A play on 3", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Bronze Sable", false); + checkPlayableAbility("B play on 3", 3, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Grizzly Bears", false); + checkPlayableAbility("B play on 3", 3, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Bronze Sable", false); + + // turn 3 - A play + castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Grizzly Bears"); + waitStackResolved(3, PhaseStep.POSTCOMBAT_MAIN); + + setStrictChooseMode(true); + setStopAt(3, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Grizzly Bears", 1); + } + + @Test + public void test_MDF() { + skipInitShuffling(); + + // If a player would draw a card, that player exiles that card face up instead. + // Each player may play cards they exiled with Uba Mask this turn. + addCard(Zone.BATTLEFIELD, playerA, "Uba Mask"); + // + addCard(Zone.LIBRARY, playerB, "Valki, God of Lies"); // {1}{B} + addCard(Zone.BATTLEFIELD, playerB, "Swamp", 2); + + // turn 2 + + // B draw and exile valki + checkExileCount("exiled", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Valki, God of Lies", 1); + checkPlayableAbility("exiled", 2, PhaseStep.PRECOMBAT_MAIN, playerB, "Cast Valki, God of Lies", true); + + // cast valki + castSpell(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "Valki, God of Lies"); + setChoice(playerB, TestPlayer.CHOICE_SKIP); + + setStrictChooseMode(true); + setStopAt(2, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerB, "Valki, God of Lies", 1); + } +}