diff --git a/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java b/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java index cc0445d5f83..c8a4b1d4ed6 100644 --- a/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java +++ b/Mage.Sets/src/mage/cards/x/XanatharGuildKingpin.java @@ -163,12 +163,19 @@ class XanatharPlayFromTopOfTargetLibraryEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { - if (!(affectedAbility instanceof SpellAbility) || !playerId.equals(source.getControllerId())) { + Card cardToCheck = game.getCard(objectId); + if (cardToCheck == null) { return false; } - SpellAbility spell = (SpellAbility) affectedAbility; - Card cardToCheck = spell.getCharacteristics(game); - if (spell.getManaCosts().isEmpty()) { + if (affectedAbility instanceof SpellAbility) { + SpellAbility spell = (SpellAbility) affectedAbility; + cardToCheck = spell.getCharacteristics(game); + if (spell.getManaCosts().isEmpty()) { + return false; // prevent casting cards without mana cost? + } + } + // only permits you to cast + if (!playerId.equals(source.getControllerId())) { return false; } Player controller = game.getPlayer(source.getControllerId()); @@ -176,7 +183,7 @@ class XanatharPlayFromTopOfTargetLibraryEffect extends AsThoughEffectImpl { if (controller == null || opponent == null) { return false; } - // main card of spell must be on top of the opponent's library + // main card of spell/land must be on top of the opponent's library Card topCard = opponent.getLibrary().getFromTop(game); return topCard != null && topCard.getId().equals(cardToCheck.getMainCard().getId()); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/XanatharGuildKingpinTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/XanatharGuildKingpinTest.java index bd66e904a82..c7ab25d624f 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/XanatharGuildKingpinTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/afr/XanatharGuildKingpinTest.java @@ -57,4 +57,28 @@ public class XanatharGuildKingpinTest extends CardTestPlayerBase { setStopAt(2, PhaseStep.END_TURN); execute(); } + + @Test + public void test_PlayLand() { + setStrictChooseMode(true); + skipInitShuffling(); + + // At the beginning of your upkeep, choose target opponent. + // Until end of turn, that player can’t cast spells, you may look at the top card of their library any time, + // you may play the top card of their library, and you may spend mana as though it were mana of any color + // to cast spells this way. + addCard(Zone.BATTLEFIELD, playerA, "Xanathar, Guild Kingpin"); + addCard(Zone.LIBRARY, playerB, "Taiga"); + + // activate on opponent + addTarget(playerA, playerB); + + // play from B + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Taiga"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Taiga", 1); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayFromTopOfLibraryEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayFromTopOfLibraryEffect.java index e1c58df4cbc..32a577fdf4a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayFromTopOfLibraryEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayFromTopOfLibraryEffect.java @@ -68,15 +68,15 @@ public class PlayFromTopOfLibraryEffect extends AsThoughEffectImpl { public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { // can play lands/spells (must check specific part and allows specific part) - Card cardToCheck = game.getCard(objectId); // maybe this should be removed and only check SpellAbility characteristics + Card cardToCheck = game.getCard(objectId); // maybe this should be removed and only check SpellAbility characteristics -- No! don't forget PlayLandAbility if (cardToCheck == null) { return false; } if (affectedAbility instanceof SpellAbility) { SpellAbility spell = (SpellAbility) affectedAbility; cardToCheck = spell.getCharacteristics(game); - if (spell.getManaCosts().isEmpty()){ - return false; + if (spell.getManaCosts().isEmpty()) { + return false; // prevent casting cards without mana cost? } } // only permits you to cast