From f06e6a7bbb2cb2b86a03cb781b5af9ffa3ddab96 Mon Sep 17 00:00:00 2001 From: Kranken Date: Wed, 25 May 2016 20:26:23 +0200 Subject: [PATCH 1/2] Make it possible to play lands using hideaway Previously lands were not playable due to the ignoreTimings flag being set to false. Added checks for the hideaway rulings regarding lands. --- .../abilities/keywords/HideawayTest.java | 74 +++++++++++++++++++ .../effects/common/HideawayPlayEffect.java | 14 +++- 2 files changed, 87 insertions(+), 1 deletion(-) 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 e5d312cbaf0..940bd6416fd 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 @@ -118,6 +118,80 @@ public class HideawayTest extends CardTestPlayerBase { 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)); + } + @Test + public void testCannotPlayLandIfPlayedLand() { + addCard(Zone.HAND, playerA, "Windbrisk Heights"); + addCard(Zone.HAND, playerA, "Plains"); + addCard(Zone.LIBRARY, playerA, "Ghost Quarter"); + skipInitShuffling(); + + addCard(Zone.BATTLEFIELD, playerA, "Plains", 1); + addCard(Zone.BATTLEFIELD, playerA, "Auriok Champion", 3); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Windbrisk Heights"); + setChoice(playerA, "Ghost Quarter"); + + playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Plains"); + + attack(3, playerA, "Auriok Champion"); + attack(3, playerA, "Auriok Champion"); + attack(3, playerA, "Auriok Champion"); + + activateAbility(3, PhaseStep.DECLARE_BLOCKERS, playerA, "{W},"); + + setStopAt(3, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, "Ghost Quarter", 0); + assertTapped("Windbrisk Heights", true); + } + + @Test + public void testCannotPlayLandIfNotOwnTurn() { + addCard(Zone.HAND, playerA, "Mosswort Bridge"); + addCard(Zone.LIBRARY, playerA, "Ghost Quarter"); + 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, "Ghost Quarter"); + + activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerA, "{G},"); + + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Ghost Quarter", 0); + assertTapped("Mosswort Bridge", true); + } + + @Test + public void testCanPlayLandIfNotPlayedLand() { + addCard(Zone.HAND, playerA, "Windbrisk Heights"); + addCard(Zone.LIBRARY, playerA, "Ghost Quarter"); + skipInitShuffling(); + + addCard(Zone.BATTLEFIELD, playerA, "Plains", 1); + addCard(Zone.BATTLEFIELD, playerA, "Auriok Champion", 3); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Windbrisk Heights"); + setChoice(playerA, "Ghost Quarter"); + + attack(3, playerA, "Auriok Champion"); + attack(3, playerA, "Auriok Champion"); + attack(3, playerA, "Auriok Champion"); + + activateAbility(3, PhaseStep.DECLARE_BLOCKERS, playerA, "{W},"); + + setStopAt(3, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, "Ghost Quarter", 1); + assertTapped("Windbrisk Heights", true); + Assert.assertEquals(playerA.getLandsPlayed(), 1); } } 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 9edec1c41e6..ba04b0d7d62 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java @@ -30,6 +30,7 @@ package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.CardType; import mage.constants.Outcome; import mage.game.ExileZone; import mage.game.Game; @@ -68,7 +69,18 @@ public class HideawayPlayEffect extends OneShotEffect { if (controller.chooseUse(Outcome.PlayForFree, "Do you want to play " + card.getIdName() + " for free now?", source, game)) { card.setFaceDown(false, game); int zcc = card.getZoneChangeCounter(game); - if (!controller.playCard(card, game, true, false)) { + + /* 702.74. Hideaway, rulings: + * If the removed card is a land, you may play it as a result of the last ability only if it's your turn + * and you haven't already played a land that turn. This counts as your land play for the turn. + */ + if (card.getCardType().contains(CardType.LAND)) { + if (controller.getLandsPlayed() > 0 || !game.getActivePlayerId().equals(controller.getId())) { + return false; + } + } + + if (!controller.playCard(card, game, true, true)) { if (card.getZoneChangeCounter(game) == zcc) { card.setFaceDown(true, game); } From 5f7d710b5e858c01e46c7649930599dc56827696 Mon Sep 17 00:00:00 2001 From: Kranken Date: Sat, 28 May 2016 14:07:29 +0200 Subject: [PATCH 2/2] Make sure lands via hideaway respects 305.2 --- .../abilities/keywords/HideawayTest.java | 30 +++++++++++++++++++ .../effects/common/HideawayPlayEffect.java | 5 +++- 2 files changed, 34 insertions(+), 1 deletion(-) 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 940bd6416fd..ad61e158769 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 @@ -194,4 +194,34 @@ public class HideawayTest extends CardTestPlayerBase { assertTapped("Windbrisk Heights", true); Assert.assertEquals(playerA.getLandsPlayed(), 1); } + + @Test + public void testCanPlayMoreLandsIfAble() { + addCard(Zone.HAND, playerA, "Windbrisk Heights"); + addCard(Zone.LIBRARY, playerA, "Ghost Quarter"); + addCard(Zone.HAND, playerA, "Plains"); + skipInitShuffling(); + + addCard(Zone.BATTLEFIELD, playerA, "Plains", 1); + addCard(Zone.BATTLEFIELD, playerA, "Auriok Champion", 3); + addCard(Zone.BATTLEFIELD, playerA, "Fastbond", 1); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Windbrisk Heights"); + setChoice(playerA, "Ghost Quarter"); + + playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Plains"); + + attack(3, playerA, "Auriok Champion"); + attack(3, playerA, "Auriok Champion"); + attack(3, playerA, "Auriok Champion"); + + activateAbility(3, PhaseStep.DECLARE_BLOCKERS, playerA, "{W},"); + + setStopAt(3, PhaseStep.END_COMBAT); + execute(); + + assertPermanentCount(playerA, "Ghost Quarter", 1); + assertTapped("Windbrisk Heights", true); + Assert.assertEquals(playerA.getLandsPlayed(), 2); + } } 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 ba04b0d7d62..98eeeb1231e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/HideawayPlayEffect.java @@ -37,6 +37,8 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; +import java.util.UUID; + /** * @author LevelX2 * @@ -75,7 +77,8 @@ public class HideawayPlayEffect extends OneShotEffect { * and you haven't already played a land that turn. This counts as your land play for the turn. */ if (card.getCardType().contains(CardType.LAND)) { - if (controller.getLandsPlayed() > 0 || !game.getActivePlayerId().equals(controller.getId())) { + UUID playerId = controller.getId(); + if (!game.getActivePlayerId().equals(playerId) || !game.getPlayer(playerId).canPlayLand()) { return false; } }