* 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.

This commit is contained in:
LevelX2 2016-08-09 10:20:59 +02:00
parent a2a540c2b4
commit c563d6f701
2 changed files with 53 additions and 11 deletions

View file

@ -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 @Test
public void testMeldAndStopRestrictIfMeldCreatureLeftBattlefield() { public void testMeldAndStopRestrictIfMeldCreatureLeftBattlefield() {
@ -117,4 +117,50 @@ public class MeldTest extends CardTestPlayerBase {
assertHandCount(playerB, 2 + 9); 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
// <i>(Melds with Gisela, the Broken Blade.)</i>
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);
}
} }

View file

@ -51,8 +51,7 @@ public class PermanentMeld extends PermanentCard {
public int getConvertedManaCost() { public int getConvertedManaCost() {
if (this.isCopy()) { if (this.isCopy()) {
return 0; return 0;
} } else {
else {
return this.getCard().getConvertedManaCost(); return this.getCard().getConvertedManaCost();
} }
} }
@ -87,8 +86,7 @@ public class PermanentMeld extends PermanentCard {
cardsToMove.add(bottomHalfCard); cardsToMove.add(bottomHalfCard);
if (flag) { if (flag) {
controller.putCardsOnTopOfLibrary(cardsToMove, game, null, true); controller.putCardsOnTopOfLibrary(cardsToMove, game, null, true);
} } else {
else {
controller.putCardsOnBottomOfLibrary(cardsToMove, game, null, true); controller.putCardsOnBottomOfLibrary(cardsToMove, game, null, true);
} }
break; break;
@ -131,8 +129,7 @@ public class PermanentMeld extends PermanentCard {
if (exileId == null) { if (exileId == null) {
game.getExile().getPermanentExile().add(topHalfCard); game.getExile().getPermanentExile().add(topHalfCard);
game.getExile().getPermanentExile().add(bottomHalfCard); game.getExile().getPermanentExile().add(bottomHalfCard);
} } else {
else {
game.getExile().createZone(exileId, name).add(topHalfCard); game.getExile().createZone(exileId, name).add(topHalfCard);
game.getExile().getExileZone(exileId).add(bottomHalfCard); game.getExile().getExileZone(exileId).add(bottomHalfCard);
} }
@ -143,8 +140,7 @@ public class PermanentMeld extends PermanentCard {
cardsToMove.add(bottomHalfCard); cardsToMove.add(bottomHalfCard);
if (event.getFlag()) { if (event.getFlag()) {
controller.putCardsOnTopOfLibrary(cardsToMove, game, null, true); controller.putCardsOnTopOfLibrary(cardsToMove, game, null, true);
} } else {
else {
controller.putCardsOnBottomOfLibrary(cardsToMove, game, null, true); controller.putCardsOnBottomOfLibrary(cardsToMove, game, null, true);
} }
break; break;
@ -152,6 +148,7 @@ public class PermanentMeld extends PermanentCard {
return false; return false;
} }
meldCard.setMelded(false); meldCard.setMelded(false);
game.setZone(meldCard.getId(), Zone.OUTSIDE);
game.setZone(topHalfCard.getId(), event.getToZone()); game.setZone(topHalfCard.getId(), event.getToZone());
game.setZone(bottomHalfCard.getId(), event.getToZone()); game.setZone(bottomHalfCard.getId(), event.getToZone());
meldCard.setTopLastZoneChangeCounter(topHalfCard.getZoneChangeCounter(game)); meldCard.setTopLastZoneChangeCounter(topHalfCard.getZoneChangeCounter(game));
@ -168,8 +165,7 @@ public class PermanentMeld extends PermanentCard {
MeldCard meldCard = (MeldCard) this.getCard(); MeldCard meldCard = (MeldCard) this.getCard();
if (meldCard.isMelded()) { if (meldCard.isMelded()) {
super.addCounters(name, amount, game, appliedEffects); super.addCounters(name, amount, game, appliedEffects);
} } else {
else {
meldCard.getTopHalfCard().addCounters(name, amount, game, appliedEffects); meldCard.getTopHalfCard().addCounters(name, amount, game, appliedEffects);
meldCard.getBottomHalfCard().addCounters(name, amount, game, appliedEffects); meldCard.getBottomHalfCard().addCounters(name, amount, game, appliedEffects);
} }