* 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,18 +1,17 @@
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 {
@ -23,10 +22,9 @@ public final class Displace extends CardImpl {
// 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);
}

View file

@ -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;
}
}