* Displace - fixed that it return cards under your control instead owner;

This commit is contained in:
Oleg Agafonov 2020-01-14 19:15:42 +04:00
parent 748d14e55e
commit 3a681d565a
2 changed files with 30 additions and 14 deletions

View file

@ -1,32 +1,30 @@
package mage.cards.d; package mage.cards.d;
import java.util.UUID;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ExileTargetForSourceEffect; 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.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class Displace extends CardImpl { public final class Displace extends CardImpl {
public Displace(UUID ownerId, CardSetInfo setInfo) { 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. // 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)); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent(0, 2, new FilterControlledCreaturePermanent("creatures you control"), false));
Effect effect = new ExileTargetForSourceEffect(); Effect effect = new ExileTargetForSourceEffect();
effect.setText("Exile up to two target creatures you control");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
effect = new ReturnToBattlefieldUnderYourControlTargetEffect(true); effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect()
effect.setText(", then return those cards to the battlefield under their owner's control"); .withReturnNames("those cards", "their owner's").concatBy(", then");
this.getSpellAbility().addEffect(effect); this.getSpellAbility().addEffect(effect);
} }

View file

@ -1,7 +1,5 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
@ -15,14 +13,17 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEffect { public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEffect {
private boolean tapped; private boolean tapped;
protected boolean fromExileZone; protected boolean fromExileZone;
private String returnName = "that card";
private String returnUnderControlName = "its owner's";
public ReturnToBattlefieldUnderOwnerControlTargetEffect() { public ReturnToBattlefieldUnderOwnerControlTargetEffect() {
this(false); this(false);
@ -34,15 +35,26 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
public ReturnToBattlefieldUnderOwnerControlTargetEffect(boolean tapped, boolean fromExileZone) { public ReturnToBattlefieldUnderOwnerControlTargetEffect(boolean tapped, boolean fromExileZone) {
super(Outcome.Benefit); super(Outcome.Benefit);
staticText = "return that card to the battlefield under its owner's control";
this.tapped = tapped; this.tapped = tapped;
this.fromExileZone = fromExileZone; this.fromExileZone = fromExileZone;
updateText();
} }
public ReturnToBattlefieldUnderOwnerControlTargetEffect(final ReturnToBattlefieldUnderOwnerControlTargetEffect effect) { public ReturnToBattlefieldUnderOwnerControlTargetEffect(final ReturnToBattlefieldUnderOwnerControlTargetEffect effect) {
super(effect); super(effect);
this.tapped = effect.tapped; this.tapped = effect.tapped;
this.fromExileZone = effect.fromExileZone; 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 @Override
@ -63,8 +75,7 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
if (exileZone.contains(targetId)) { if (exileZone.contains(targetId)) {
cardsToBattlefield.add(targetId); cardsToBattlefield.add(targetId);
} } else {
else {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card instanceof MeldCard) { if (card instanceof MeldCard) {
MeldCard meldCard = (MeldCard) card; MeldCard meldCard = (MeldCard) card;
@ -91,4 +102,11 @@ public class ReturnToBattlefieldUnderOwnerControlTargetEffect extends OneShotEff
} }
return false; return false;
} }
public ReturnToBattlefieldUnderOwnerControlTargetEffect withReturnNames(String returnName, String returnUnderControlName) {
this.returnName = returnName;
this.returnUnderControlName = returnUnderControlName;
updateText();
return this;
}
} }