From b012e66eea0300e7dc0646aba9fe22c074151c0f Mon Sep 17 00:00:00 2001 From: drmDev Date: Fri, 22 Jul 2016 15:56:36 -0400 Subject: [PATCH] Platinum Angel bounced test added for issue #2074. Test passes so unconfirmed. Added a new assertLibraryCount method to just assert the library count. --- .../cards/replacement/WinLoseEffectsTest.java | 40 +++++++++++++++++-- .../base/impl/CardTestPlayerAPIImpl.java | 15 ++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/WinLoseEffectsTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/WinLoseEffectsTest.java index eb72a6a4c7b..fab4f28f896 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/WinLoseEffectsTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/WinLoseEffectsTest.java @@ -46,13 +46,16 @@ public class WinLoseEffectsTest extends CardTestPlayerBase { * game loss rather than the card draw. */ @Test - public void testCard() { + public void testPlatinumAngelAndLaboratoryManiac() { + // Platinum Angel {7} - Flying - 4/4 + // You can't lose the game and your opponents can't win the game. addCard(Zone.BATTLEFIELD, playerA, "Platinum Angel"); + // Laboratory Maniac {2}{U} - Creature Wizard - 2/3 + // If you would draw a card while your library has no cards in it, you win the game instead. addCard(Zone.BATTLEFIELD, playerA, "Laboratory Maniac", 1); // If you would draw a card, draw two cards instead. addCard(Zone.BATTLEFIELD, playerA, "Thought Reflection", 4); - setStopAt(40, PhaseStep.END_TURN); execute(); @@ -60,8 +63,39 @@ public class WinLoseEffectsTest extends CardTestPlayerBase { Assert.assertTrue("Player A has not won but should have", playerA.hasWon()); assertLife(playerA, 20); assertLife(playerB, 20); - } + + /* + * Reported bug: My library was empty and I controlled Platinum Angel. I had already "drawn" from an empty library but hadn't lost due to the angel's effect. + * My opponent cast Set Adrift on the Angel, and I lost immediately when it resolved. + */ + @Test + public void testPlatinumAngelBouncedWithEmptyLibrary() { + + // Platinum Angel {7} - Flying - 4/4 + // You can't lose the game and your opponents can't win the game. + addCard(Zone.BATTLEFIELD, playerA, "Platinum Angel"); + + // Set Adrift {5}{U} - Sorcery + // Delve (Each card you exile from your graveyard while casting this spell pays for {1} + // Put target nonland permanent on top of its owner's library. + addCard(Zone.HAND, playerB, "Set Adrift", 1); + removeAllCardsFromLibrary(playerA); + addCard(Zone.BATTLEFIELD, playerB, "Island", 6); + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Set Adrift"); + addTarget(playerB, "Platinum Angel"); + + setStopAt(2, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerB, "Set Adrift", 1); + assertPermanentCount(playerA, "Platinum Angel", 0); + assertLibraryCount(playerA, 1); // Angel returned to top of library + assertLibraryCount(playerA, "Platinum Angel", 1); + Assert.assertFalse("Player A should not have lost yet", playerA.hasLost()); + } + /** * If I have resolved an Angel's Grace this turn, have an empty library, a Laboratory Maniac on * the battlefield, and would draw a card, nothing happens. I should win the game if the card drawing effect resolves. diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index 6c44d64fe5b..c9686df11ca 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -872,9 +872,22 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement Assert.assertEquals("(Graveyard " + player.getName() + ") Card counts are not equal (" + cardName + ")", count, actualCount); } + + /** + * Assert library card count. + * + * @param player {@link Player} who's library should be counted. + * @param count Expected count. + */ + public void assertLibraryCount(Player player, int count) throws AssertionError { + + List libraryList = player.getLibrary().getCards(currentGame); + int actualCount = libraryList != null && !libraryList.isEmpty() ? libraryList.size() : 0; + Assert.assertEquals("(Library " + player.getName() + ") counts are not equal", count, actualCount); + } /** - * Assert card count in player's library. + * Assert specific card count in player's library. * * @param player {@link Player} who's library should be counted. * @param cardName Name of the cards that should be counted.