From 554e81a462fddb1d171deb83edac6acc6f494608 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 31 Dec 2015 12:05:08 +0100 Subject: [PATCH] * Hideaway - Fixed that the face down card played by hideaway was not correctly set face up again. --- .../sets/commander2013/MosswortBridge.java | 4 +- .../abilities/keywords/HideawayTest.java | 83 ++++++++++++++----- .../java/org/mage/test/player/TestPlayer.java | 38 +++++++++ .../effects/common/HideawayPlayEffect.java | 8 +- 4 files changed, 108 insertions(+), 25 deletions(-) diff --git a/Mage.Sets/src/mage/sets/commander2013/MosswortBridge.java b/Mage.Sets/src/mage/sets/commander2013/MosswortBridge.java index 67a79cfed71..307a5d5ce6b 100644 --- a/Mage.Sets/src/mage/sets/commander2013/MosswortBridge.java +++ b/Mage.Sets/src/mage/sets/commander2013/MosswortBridge.java @@ -57,10 +57,10 @@ public class MosswortBridge extends CardImpl { // Hideaway (This land enters the battlefield tapped. When it does, look at the top four cards of your library, exile one face down, then put the rest on the bottom of your library.) this.addAbility(new HideawayAbility()); - // {tap}: Add {G} to your mana pool. + // {T}: Add {G} to your mana pool. this.addAbility(new GreenManaAbility()); - // {G}, {tap}: You may play the exiled card without paying its mana cost if creatures you control have total power 10 or greater. + // {G}, {T}: You may play the exiled card without paying its mana cost if creatures you control have total power 10 or greater. Ability ability = new ActivateIfConditionActivatedAbility( Zone.BATTLEFIELD, new HideawayPlayEffect(), new ManaCostsImpl("{G}"), MosswortBridgeTotalPowerCondition.getInstance()); ability.addCost(new TapSourceCost()); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HideawayTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HideawayTest.java index 3bf79b639d2..e5d312cbaf0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HideawayTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HideawayTest.java @@ -25,12 +25,12 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package org.mage.test.cards.abilities.keywords; import mage.cards.Card; import mage.constants.PhaseStep; import mage.constants.Zone; +import mage.game.permanent.Permanent; import org.junit.Assert; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -42,27 +42,23 @@ import org.mage.test.serverside.base.CardTestPlayerBase; public class HideawayTest extends CardTestPlayerBase { /** - * 702.74. Hideaway - * 702.74a Hideaway represents a static ability and a triggered ability. “Hideaway” means “This - * permanent enters the battlefield tapped” and “When this permanent enters the battlefield, look at - * the top four cards of your library. Exile one of them face down and put the rest on the bottom of - * your library in any order. The exiled card gains ‘Any player who has controlled the permanent - * that exiled this card may look at this card in the exile zone.’” - * - */ - - /** - * Shelldock Isle - * Land - * Hideaway (This land enters the battlefield tapped. When it does, look at - * the top four cards of your library, exile one face down, then put the - * rest on the bottom of your library.) - * {T}: Add {U} to your mana pool. - * {U}, {T}: You may play the exiled card without paying its mana cost if a - * library has twenty or fewer cards in it. + * 702.74. Hideaway 702.74a Hideaway represents a static ability and a + * triggered ability. “Hideaway” means “This permanent enters the + * battlefield tapped” and “When this permanent enters the battlefield, look + * at the top four cards of your library. Exile one of them face down and + * put the rest on the bottom of your library in any order. The exiled card + * gains ‘Any player who has controlled the permanent that exiled this card + * may look at this card in the exile zone.’” + * + */ + /** + * Shelldock Isle Land Hideaway (This land enters the battlefield tapped. + * When it does, look at the top four cards of your library, exile one face + * down, then put the rest on the bottom of your library.) {T}: Add {U} to + * your mana pool. {U}, {T}: You may play the exiled card without paying its + * mana cost if a library has twenty or fewer cards in it. * */ - @Test public void testHideaway() { addCard(Zone.HAND, playerA, "Shelldock Isle"); @@ -74,11 +70,54 @@ public class HideawayTest extends CardTestPlayerBase { assertPermanentCount(playerA, "Shelldock Isle", 1); assertExileCount(playerA, 1); - for (Card card :currentGame.getExile().getAllCards(currentGame)){ + for (Card card : currentGame.getExile().getAllCards(currentGame)) { Assert.assertTrue("Exiled card is not face down", card.isFaceDown(currentGame)); } - } + /** + * In commander, an opponent cast Ulamog, the Ceaseless Hunger off of + * Mosswort Bridge. After it resolved, another opponent exile Ulamog with a + * Quarantine Field. Ulamog was shown as exile face down, as it had been + * from the Mosswort Bridge. + */ + @Test + public void testMosswortBridge() { + // Hideaway (This land enters the battlefield tapped. When it does, look at the top four cards of your library, exile one face down, then put the rest on the bottom of your library.) + // {T}: Add {G} to your mana pool. + // {G}, {T}: You may play the exiled card without paying its mana cost if creatures you control have total power 10 or greater. + addCard(Zone.HAND, playerA, "Mosswort Bridge"); + // When you cast Ulamog, the Ceaseless Hunger, exile two target permanents. + // Indestructible + // Whenever Ulamog attacks, defending player exiles the top twenty cards of his or her library. + addCard(Zone.LIBRARY, playerA, "Ulamog, the Ceaseless Hunger"); + skipInitShuffling(); + + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + addCard(Zone.BATTLEFIELD, playerA, "Dross Crocodile", 2);// 5/1 + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Mosswort Bridge"); + setChoice(playerA, "Ulamog, the Ceaseless Hunger"); + + activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{G},"); + addTarget(playerA, "Dross Crocodile^Dross Crocodile"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + execute(); + + assertExileCount("Dross Crocodile", 2); + assertPermanentCount(playerA, "Mosswort Bridge", 1); + assertExileCount(playerA, 2); + assertExileCount("Ulamog, the Ceaseless Hunger", 0); + + assertPermanentCount(playerA, "Ulamog, the Ceaseless Hunger", 1); + + assertTapped("Mosswort Bridge", true); + + Permanent permanent = getPermanent("Ulamog, the Ceaseless Hunger", playerA); + Card card = currentGame.getCard(permanent.getId()); + Assert.assertFalse("Previous exiled card may be no longer face down", card.isFaceDown(currentGame)); + + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 3d43f773edf..280c227ac81 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -1947,6 +1947,44 @@ public class TestPlayer implements Player { @Override public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) { + if (!choices.isEmpty()) { + for (String choose2 : choices) { + String[] targetList = choose2.split("\\^"); + boolean targetFound = false; + for (String targetName : targetList) { + boolean originOnly = false; + boolean copyOnly = false; + if (targetName.endsWith("]")) { + if (targetName.endsWith("[no copy]")) { + originOnly = true; + targetName = targetName.substring(0, targetName.length() - 9); + } + if (targetName.endsWith("[only copy]")) { + copyOnly = true; + targetName = targetName.substring(0, targetName.length() - 11); + } + } + for (Card card : cards.getCards(game)) { + if (target.getTargets().contains(card.getId())) { + continue; + } + if (card.getName().equals(targetName)) { + if (target.isNotTarget() || target.canTarget(card.getId(), game)) { + if ((card.isCopy() && !originOnly) || (!card.isCopy() && !copyOnly)) { + target.add(card.getId(), game); + targetFound = true; + break; + } + } + } + } + } + if (targetFound) { + choices.remove(choose2); + return true; + } + } + } return computerPlayer.choose(outcome, cards, target, game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java b/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java index 6c757284942..3328fa10c95 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java @@ -66,7 +66,13 @@ public class HideawayPlayEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (card != null && controller != null) { if (controller.chooseUse(Outcome.PlayForFree, "Do you want to play " + card.getIdName() + " for free now?", source, game)) { - controller.playCard(card, game, true, false); + card.setFaceDown(false, game); + int zcc = card.getZoneChangeCounter(game); + if (!controller.playCard(card, game, true, false)) { + if (card.getZoneChangeCounter(game) == zcc) { + card.setFaceDown(true, game); + } + } } return true; }