mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
tweak [BLB] Salvation Swan's effect, and add test with Meld.
This commit is contained in:
parent
2bdf27897f
commit
2709614508
3 changed files with 65 additions and 30 deletions
|
|
@ -41,4 +41,34 @@ public class SalvationSwanTest extends CardTestPlayerBase {
|
|||
assertPermanentCount(playerA, "Grizzly Bears", 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,38 +44,43 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
|
|||
return new ReturnToBattlefieldUnderOwnerControlTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Cards cardsToBattlefield = new CardsImpl();
|
||||
if (returnFromExileZoneOnly) {
|
||||
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
|
||||
if (game.getExile().containsId(targetId, game)) {
|
||||
cardsToBattlefield.add(targetId);
|
||||
} else {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card instanceof MeldCard) {
|
||||
MeldCard meldCard = (MeldCard) card;
|
||||
Card topCard = meldCard.getTopHalfCard();
|
||||
Card bottomCard = meldCard.getBottomHalfCard();
|
||||
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter() && game.getExile().containsId(topCard.getId(), game)) {
|
||||
cardsToBattlefield.add(topCard);
|
||||
}
|
||||
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter() && game.getExile().containsId(bottomCard.getId(), game)) {
|
||||
cardsToBattlefield.add(bottomCard);
|
||||
}
|
||||
protected Cards getCardsToReturn(Game game, Ability source) {
|
||||
Cards cardsToBattlefield = new CardsImpl();
|
||||
if (returnFromExileZoneOnly) {
|
||||
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
|
||||
if (game.getExile().containsId(targetId, game)) {
|
||||
cardsToBattlefield.add(targetId);
|
||||
} else {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card instanceof MeldCard) {
|
||||
MeldCard meldCard = (MeldCard) card;
|
||||
Card topCard = meldCard.getTopHalfCard();
|
||||
Card bottomCard = meldCard.getBottomHalfCard();
|
||||
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter() && game.getExile().containsId(topCard.getId(), game)) {
|
||||
cardsToBattlefield.add(topCard);
|
||||
}
|
||||
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()) {
|
||||
controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, true, null);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
cardsToBattlefield.addAll(getTargetPointer().getTargets(game, source));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public class ReturnToBattlefieldUnderOwnerControlWithCounterTargetEffect extends
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
game.setEnterWithCounters(targetId, counters.copy());
|
||||
for (UUID cardId : getCardsToReturn(game, source)) {
|
||||
game.setEnterWithCounters(cardId, counters.copy());
|
||||
}
|
||||
return super.apply(game, source);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue