From 3a681d565aed10140a52d74d320d9017595384c5 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Tue, 14 Jan 2020 19:15:42 +0400 Subject: [PATCH] * Displace - fixed that it return cards under your control instead owner; --- Mage.Sets/src/mage/cards/d/Displace.java | 14 ++++----- ...tlefieldUnderOwnerControlTargetEffect.java | 30 +++++++++++++++---- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/Displace.java b/Mage.Sets/src/mage/cards/d/Displace.java index 966ed93159..e7cfe8012d 100644 --- a/Mage.Sets/src/mage/cards/d/Displace.java +++ b/Mage.Sets/src/mage/cards/d/Displace.java @@ -1,32 +1,30 @@ - package mage.cards.d; -import java.util.UUID; import mage.abilities.effects.Effect; import mage.abilities.effects.common.ExileTargetForSourceEffect; -import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect; +import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.filter.common.FilterControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class Displace extends CardImpl { public Displace(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); // Exile up to two target creatures you control, then return those cards to the battlefield under their owner's control. this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(0, 2, new FilterControlledCreaturePermanent("creatures you control"), false)); Effect effect = new ExileTargetForSourceEffect(); - effect.setText("Exile up to two target creatures you control"); this.getSpellAbility().addEffect(effect); - effect = new ReturnToBattlefieldUnderYourControlTargetEffect(true); - effect.setText(", then return those cards to the battlefield under their owner's control"); + effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect() + .withReturnNames("those cards", "their owner's").concatBy(", then"); this.getSpellAbility().addEffect(effect); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java index 657a347d2b..24963b1ee0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToBattlefieldUnderOwnerControlTargetEffect.java @@ -1,7 +1,5 @@ - package mage.abilities.effects.common; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; @@ -15,14 +13,17 @@ import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; +import java.util.UUID; + /** - * * @author LevelX2 */ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEffect { private boolean tapped; protected boolean fromExileZone; + private String returnName = "that card"; + private String returnUnderControlName = "its owner's"; public ReturnToBattlefieldUnderOwnerControlTargetEffect() { this(false); @@ -34,15 +35,26 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff public ReturnToBattlefieldUnderOwnerControlTargetEffect(boolean tapped, boolean fromExileZone) { super(Outcome.Benefit); - staticText = "return that card to the battlefield under its owner's control"; this.tapped = tapped; this.fromExileZone = fromExileZone; + + updateText(); } public ReturnToBattlefieldUnderOwnerControlTargetEffect(final ReturnToBattlefieldUnderOwnerControlTargetEffect effect) { super(effect); this.tapped = effect.tapped; this.fromExileZone = effect.fromExileZone; + this.returnName = effect.returnName; + this.returnUnderControlName = effect.returnUnderControlName; + + updateText(); + } + + private void updateText() { + this.staticText = "return " + this.returnName + + " to the battlefield under " + this.returnUnderControlName + " control" + + (tapped ? " tapped" : ""); } @Override @@ -63,8 +75,7 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { if (exileZone.contains(targetId)) { cardsToBattlefield.add(targetId); - } - else { + } else { Card card = game.getCard(targetId); if (card instanceof MeldCard) { MeldCard meldCard = (MeldCard) card; @@ -91,4 +102,11 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff } return false; } + + public ReturnToBattlefieldUnderOwnerControlTargetEffect withReturnNames(String returnName, String returnUnderControlName) { + this.returnName = returnName; + this.returnUnderControlName = returnUnderControlName; + updateText(); + return this; + } }