* Unexpectedly Absent - Fixed that the target permanent was put to the wrong position in library.

This commit is contained in:
LevelX2 2018-07-16 17:43:01 +02:00
parent 711c34b34f
commit 014a46ae72
2 changed files with 34 additions and 3 deletions

View file

@ -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;
}
}

View file

@ -36,9 +36,41 @@ public class PutToLibraryTest extends CardTestPlayerBase {
ArrayList<Card> 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<Card> 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);
}
}