From c563d6f701cadb542a60bebe8128341c285a148e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 9 Aug 2016 10:20:59 +0200 Subject: [PATCH] * Fixed zone handling of meld cards that left the battlefield (fixes that coninuous effects of meld cards didn't stop to be applied after the meld card left the battlefield) fixes #2140. --- .../cards/abilities/keywords/MeldTest.java | 48 ++++++++++++++++++- .../mage/game/permanent/PermanentMeld.java | 16 +++---- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MeldTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MeldTest.java index f7b0d73b22..d6a617ec4d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MeldTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/MeldTest.java @@ -74,7 +74,7 @@ public class MeldTest extends CardTestPlayerBase { } /** - * brisela is bugged she is still "active" when dead + * Brisela is bugged she is still "active" when dead */ @Test public void testMeldAndStopRestrictIfMeldCreatureLeftBattlefield() { @@ -117,4 +117,50 @@ public class MeldTest extends CardTestPlayerBase { assertHandCount(playerB, 2 + 9); } + + /** + * Check that if the exiled parts return Brisela is created again + */ + @Test + public void testMeld3() { + addCard(Zone.BATTLEFIELD, playerA, "Plains", 7); + // When you cast Bruna, the Fading Light, you may return target Angel or Human creature card from your graveyard to the battlefield. + // Flying, Vigilance + // (Melds with Gisela, the Broken Blade.) + addCard(Zone.HAND, playerA, "Bruna, the Fading Light"); // {5}{W}{W} + // Flying, First strike, Lifelink + // At the beginning of your end step, if you both own and control Gisela, the Broken Blade and a + // creature named Bruna, the Fading Light, exile them, then meld them into Brisela, Voice of Nightmares. + addCard(Zone.HAND, playerA, "Gisela, the Broken Blade"); // {2}{W}{W} + // Brisela, Voice of Nightmares 9/10 + // Flying, First strike, Vigilance, Lifelink + // Your opponents can't cast spells with converted mana cost 3 or less. + + addCard(Zone.BATTLEFIELD, playerB, "Plains", 4); + addCard(Zone.BATTLEFIELD, playerB, "Island", 2); + addCard(Zone.HAND, playerB, "Silvercoat Lion", 2); + // Exile target creature. You draw cards equal to that creature's power. + // At the beginning of your next upkeep, return that card to the battlefield under its owner's control. + // If you do, discard cards equal to that creature's toughness. + addCard(Zone.HAND, playerB, "Vanish into Memory", 1); // Instant {2}{W}{U} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Bruna, the Fading Light"); + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Silvercoat Lion"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Gisela, the Broken Blade"); + castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, "Vanish into Memory", "Brisela, Voice of Nightmares"); + castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, "Silvercoat Lion"); + + // End step turn 7 the meld takes place again + setStopAt(8, PhaseStep.UPKEEP); + execute(); + + assertExileCount("Bruna, the Fading Light", 0); + assertExileCount("Gisela, the Broken Blade", 0); + assertPermanentCount(playerA, "Brisela, Voice of Nightmares", 1); + + assertGraveyardCount(playerB, "Vanish into Memory", 1); + assertPermanentCount(playerB, "Silvercoat Lion", 2); + assertHandCount(playerB, 0); + + } } diff --git a/Mage/src/main/java/mage/game/permanent/PermanentMeld.java b/Mage/src/main/java/mage/game/permanent/PermanentMeld.java index e933cfe62c..337ac11f01 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentMeld.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentMeld.java @@ -51,8 +51,7 @@ public class PermanentMeld extends PermanentCard { public int getConvertedManaCost() { if (this.isCopy()) { return 0; - } - else { + } else { return this.getCard().getConvertedManaCost(); } } @@ -87,8 +86,7 @@ public class PermanentMeld extends PermanentCard { cardsToMove.add(bottomHalfCard); if (flag) { controller.putCardsOnTopOfLibrary(cardsToMove, game, null, true); - } - else { + } else { controller.putCardsOnBottomOfLibrary(cardsToMove, game, null, true); } break; @@ -131,8 +129,7 @@ public class PermanentMeld extends PermanentCard { if (exileId == null) { game.getExile().getPermanentExile().add(topHalfCard); game.getExile().getPermanentExile().add(bottomHalfCard); - } - else { + } else { game.getExile().createZone(exileId, name).add(topHalfCard); game.getExile().getExileZone(exileId).add(bottomHalfCard); } @@ -143,8 +140,7 @@ public class PermanentMeld extends PermanentCard { cardsToMove.add(bottomHalfCard); if (event.getFlag()) { controller.putCardsOnTopOfLibrary(cardsToMove, game, null, true); - } - else { + } else { controller.putCardsOnBottomOfLibrary(cardsToMove, game, null, true); } break; @@ -152,6 +148,7 @@ public class PermanentMeld extends PermanentCard { return false; } meldCard.setMelded(false); + game.setZone(meldCard.getId(), Zone.OUTSIDE); game.setZone(topHalfCard.getId(), event.getToZone()); game.setZone(bottomHalfCard.getId(), event.getToZone()); meldCard.setTopLastZoneChangeCounter(topHalfCard.getZoneChangeCounter(game)); @@ -168,8 +165,7 @@ public class PermanentMeld extends PermanentCard { MeldCard meldCard = (MeldCard) this.getCard(); if (meldCard.isMelded()) { super.addCounters(name, amount, game, appliedEffects); - } - else { + } else { meldCard.getTopHalfCard().addCounters(name, amount, game, appliedEffects); meldCard.getBottomHalfCard().addCounters(name, amount, game, appliedEffects); }