tweak [BLB] Salvation Swan's effect, and add test with Meld.

This commit is contained in:
Susucre 2024-06-30 13:57:14 +02:00
parent 2bdf27897f
commit 2709614508
3 changed files with 65 additions and 30 deletions

View file

@ -41,4 +41,34 @@ public class SalvationSwanTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Grizzly Bears", 1); assertPermanentCount(playerA, "Grizzly Bears", 1);
assertCounterCount(playerA, "Grizzly Bears", CounterType.FLYING, 1); assertCounterCount(playerA, "Grizzly Bears", CounterType.FLYING, 1);
} }
@Test
public void test_Meld() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Plateau", 4 + 5);
addCard(Zone.BATTLEFIELD, playerA, "Hanweir Battlements");
addCard(Zone.BATTLEFIELD, playerA, "Hanweir Garrison");
addCard(Zone.HAND, playerA, swan);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{3}{R}{R}, {T}: If you both own and control");
setChoice(playerA, "Hanweir Garrison");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, swan);
addTarget(playerA, "Hanweir, the Writhing Township");
checkExileCount("Battlements in exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Hanweir Battlements", 1);
checkExileCount("Garrison in exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Hanweir Garrison", 1);
// Only 1 trigger to return both meld parts.
setStopAt(2, PhaseStep.UPKEEP);
execute();
assertPermanentCount(playerA, "Hanweir Battlements", 1);
assertCounterCount(playerA, "Hanweir Battlements", CounterType.FLYING, 1);
assertPermanentCount(playerA, "Hanweir Garrison", 1);
assertCounterCount(playerA, "Hanweir Garrison", CounterType.FLYING, 1);
}
} }

View file

@ -44,38 +44,43 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
return new ReturnToBattlefieldUnderOwnerControlTargetEffect(this); return new ReturnToBattlefieldUnderOwnerControlTargetEffect(this);
} }
@Override protected Cards getCardsToReturn(Game game, Ability source) {
public boolean apply(Game game, Ability source) { Cards cardsToBattlefield = new CardsImpl();
Player controller = game.getPlayer(source.getControllerId()); if (returnFromExileZoneOnly) {
if (controller != null) { for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
Cards cardsToBattlefield = new CardsImpl(); if (game.getExile().containsId(targetId, game)) {
if (returnFromExileZoneOnly) { cardsToBattlefield.add(targetId);
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { } else {
if (game.getExile().containsId(targetId, game)) { Card card = game.getCard(targetId);
cardsToBattlefield.add(targetId); if (card instanceof MeldCard) {
} else { MeldCard meldCard = (MeldCard) card;
Card card = game.getCard(targetId); Card topCard = meldCard.getTopHalfCard();
if (card instanceof MeldCard) { Card bottomCard = meldCard.getBottomHalfCard();
MeldCard meldCard = (MeldCard) card; if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter() && game.getExile().containsId(topCard.getId(), game)) {
Card topCard = meldCard.getTopHalfCard(); cardsToBattlefield.add(topCard);
Card bottomCard = meldCard.getBottomHalfCard(); }
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter() && game.getExile().containsId(topCard.getId(), game)) { if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter() && game.getExile().containsId(bottomCard.getId(), game)) {
cardsToBattlefield.add(topCard); cardsToBattlefield.add(bottomCard);
}
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter() && game.getExile().containsId(bottomCard.getId(), game)) {
cardsToBattlefield.add(bottomCard);
}
} }
} }
} }
} else {
cardsToBattlefield.addAll(getTargetPointer().getTargets(game, source));
} }
if (!cardsToBattlefield.isEmpty()) { } else {
controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, true, null); cardsToBattlefield.addAll(getTargetPointer().getTargets(game, source));
}
return true;
} }
return false; return cardsToBattlefield;
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cardsToBattlefield = getCardsToReturn(game, source);
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, true, null);
}
return true;
} }
} }

View file

@ -41,8 +41,8 @@ public class ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect extends
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (UUID targetId : getTargetPointer().getTargets(game, source)) { for (UUID cardId : getCardsToReturn(game, source)) {
game.setEnterWithCounters(targetId, counters.copy()); game.setEnterWithCounters(cardId, counters.copy());
} }
return super.apply(game, source); return super.apply(game, source);
} }