From 014a46ae72549355e74612e85bfc52f471c319f7 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 16 Jul 2018 17:43:01 +0200 Subject: [PATCH] * Unexpectedly Absent - Fixed that the target permanent was put to the wrong position in library. --- .../src/mage/cards/u/UnexpectedlyAbsent.java | 3 +- .../oneshot/library/PutToLibraryTest.java | 34 ++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/cards/u/UnexpectedlyAbsent.java b/Mage.Sets/src/mage/cards/u/UnexpectedlyAbsent.java index 3db22ac3366..2fadc33bd9b 100644 --- a/Mage.Sets/src/mage/cards/u/UnexpectedlyAbsent.java +++ b/Mage.Sets/src/mage/cards/u/UnexpectedlyAbsent.java @@ -1,4 +1,3 @@ - package mage.cards.u; import java.util.UUID; @@ -61,7 +60,7 @@ class UnexpectedlyAbsentEffect extends OneShotEffect { if (controller != null) { Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { - controller.putCardOnTopXOfLibrary(permanent, game, source, source.getManaCostsToPay().getX()); + controller.putCardOnTopXOfLibrary(permanent, game, source, source.getManaCostsToPay().getX() + 1); return true; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/library/PutToLibraryTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/library/PutToLibraryTest.java index 7668806acfd..fbaf5f07ad0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/library/PutToLibraryTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/library/PutToLibraryTest.java @@ -36,9 +36,41 @@ public class PutToLibraryTest extends CardTestPlayerBase { ArrayList cardArray = new ArrayList<>(playerB.getLibrary().getCards(currentGame)); Assert.assertTrue("Library has no cards but should have", cardArray.size() > 1); Card secondCard = cardArray.get(1); - Assert.assertTrue("Second card from top should be Dread Wanderer, bnut it isn't", + Assert.assertTrue("Second card from top should be Dread Wanderer, but it isn't", secondCard != null && secondCard.getName().equals("Dread Wanderer")); } + // Unexpectedly Absent doesn't work properly, no matter how much you pay for X the card is always returned on top of the library. + @Test + public void testUnexpectedlyAbsent() { + // Flying + // At the beginning of combat on your turn, you may pay {G}{U}. When you do, put a +1/+1 counter on another target creature you control, and that creature gains flying until end of turn. + addCard(Zone.BATTLEFIELD, playerA, "Skyrider Patrol", 1); + + // Put target nonland permanent into its owner's library just beneath the top X cards of that library. + addCard(Zone.HAND, playerB, "Unexpectedly Absent"); // Instant {X}{W}{W} + addCard(Zone.BATTLEFIELD, playerB, "Plains", 5); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Unexpectedly Absent", "Skyrider Patrol"); + setChoice(playerB, "X=3"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerB, "Unexpectedly Absent", 1); + assertPermanentCount(playerA, "Skyrider Patrol", 0); + assertLibraryCount(playerA, "Skyrider Patrol", 1); + + ArrayList cardArray = new ArrayList<>(playerA.getLibrary().getCards(currentGame)); + Assert.assertTrue("Library has no cards but should have", cardArray.size() > 3); + Card fourthCard = cardArray.get(3);// get the 4th element + Assert.assertTrue("Fourth card from top should be Skyrider Patrol, but it isn't", + fourthCard != null && fourthCard.getName().equals("Skyrider Patrol")); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + } + }