Skip to content
Permalink
Browse files
* Fixed exile and return back under owner control handling (e.g. Nori…
…n the Wary did not return from command zone when commander replacement effect was used).
  • Loading branch information
LevelX2 committed Jul 3, 2015
1 parent cea7bb4 commit 8e0907c90c96bf5216bcf402dbe91260eb45c95c
@@ -25,26 +25,18 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/

package mage.sets.championsofkamigawa;

import java.util.UUID;

import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ExileReturnToBattlefieldOwnerNextEndStepEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterSpiritOrArcaneCard;
import mage.game.Game;
import mage.game.permanent.Permanent;

/**
*
@@ -54,7 +46,7 @@

private static final FilterSpiritOrArcaneCard filter = new FilterSpiritOrArcaneCard();

public HikariTwilightGuardian (UUID ownerId) {
public HikariTwilightGuardian(UUID ownerId) {
super(ownerId, 12, "Hikari, Twilight Guardian", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{W}{W}");
this.expansionSetCode = "CHK";
this.supertype.add("Legendary");
@@ -66,10 +58,12 @@ public HikariTwilightGuardian (UUID ownerId) {
this.addAbility(FlyingAbility.getInstance());

// Whenever you cast a Spirit or Arcane spell, you may exile Hikari, Twilight Guardian. If you do, return it to the battlefield under its owner's control at the beginning of the next end step.
this.addAbility(new SpellCastControllerTriggeredAbility(new HikariTwilightGuardianEffect(), filter, true));
Effect effect = new ExileReturnToBattlefieldOwnerNextEndStepEffect();
effect.setText("you may exile {this}. If you do, return it to the battlefield under its owner's control at the beginning of the next end step");
this.addAbility(new SpellCastControllerTriggeredAbility(effect, filter, true));
}

public HikariTwilightGuardian (final HikariTwilightGuardian card) {
public HikariTwilightGuardian(final HikariTwilightGuardian card) {
super(card);
}

@@ -79,41 +73,3 @@ public HikariTwilightGuardian copy() {
}

}

class HikariTwilightGuardianEffect extends OneShotEffect {

private static final String effectText = "Exile {this}. Return it to the battlefield under your control at the beginning of the next end step";

HikariTwilightGuardianEffect ( ) {
super(Outcome.Benefit);
staticText = effectText;
}

HikariTwilightGuardianEffect(HikariTwilightGuardianEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Hikari, Twilight Guardian", source.getSourceId(), game)) {
//create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
}
return false;
}

@Override
public HikariTwilightGuardianEffect copy() {
return new HikariTwilightGuardianEffect(this);
}

}
@@ -25,38 +25,28 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/

package mage.sets.dragonsmaze;

import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.effects.common.ExileReturnToBattlefieldOwnerNextEndStepEffect;
import mage.abilities.effects.common.combat.CantBeBlockedSourceEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;

import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;

/**
*
* @author LevelX2
*/


public class AEtherling extends CardImpl {

public AEtherling (UUID ownerId) {
public AEtherling(UUID ownerId) {
super(ownerId, 11, "AEtherling", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{U}{U}");
this.expansionSetCode = "DGM";
this.subtype.add("Shapeshifter");
@@ -65,7 +55,7 @@ public AEtherling (UUID ownerId) {
this.toughness = new MageInt(5);

// {U}: Exile AEtherling. Return it to the battlefield under its owner's control at the beginning of the next end step.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AEherlingRemovingEffect(), new ManaCostsImpl("{U}")));
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileReturnToBattlefieldOwnerNextEndStepEffect(), new ManaCostsImpl("{U}")));
// {U}: AEtherling can't be blocked this turn
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedSourceEffect(), new ManaCostsImpl("{U}")));
// {1}: AEtherling gets +1/-1 until end of turn.
@@ -74,7 +64,7 @@ public AEtherling (UUID ownerId) {
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(-1, 1, Duration.EndOfTurn), new ManaCostsImpl("{1}")));
}

public AEtherling (final AEtherling card) {
public AEtherling(final AEtherling card) {
super(card);
}

@@ -84,40 +74,3 @@ public AEtherling copy() {
}

}
class AEherlingRemovingEffect extends OneShotEffect {

private static final String effectText = "Exile {this}. Return it to the battlefield under its owner's control at the beginning of the next end step";

AEherlingRemovingEffect () {
super(Outcome.Benefit);
staticText = effectText;
}

AEherlingRemovingEffect(AEherlingRemovingEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "AEherling Exile", source.getSourceId(), game)) {
//create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
}
return false;
}

@Override
public AEherlingRemovingEffect copy() {
return new AEherlingRemovingEffect(this);
}

}
@@ -28,20 +28,18 @@
package mage.sets.gatecrash;

import java.util.UUID;

import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CipherEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.cards.Card;
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.Rarity;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;

/**
@@ -54,7 +52,6 @@ public Voidwalk(UUID ownerId) {
super(ownerId, 55, "Voidwalk", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{3}{U}");
this.expansionSetCode = "GTC";


// Exile target creature. Return it to the battlefield under its owner's control at the beginning of the next end step.
this.getSpellAbility().addEffect(new VoidwalkEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
@@ -88,21 +85,23 @@ public Voidwalk copy() {

@Override
public boolean apply(Game game, Ability source) {
if (getTargetPointer().getFirst(game, source) != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Voidwalk", source.getSourceId(), game)) {
if (card != null) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (getTargetPointer().getFirst(game, source) != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
int zcc = game.getState().getZoneChangeCounter(permanent.getId());
if (permanent.moveToExile(null, "", source.getSourceId(), game)) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new ReturnToBattlefieldUnderOwnerControlSourceEffect(false, zcc + 1));
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(card.getOwnerId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
}
}
return true;
}
return false;
}
@@ -111,4 +110,4 @@ public boolean apply(Game game, Ability source) {
public VoidwalkEffect copy() {
return new VoidwalkEffect(this);
}
}
}
@@ -25,26 +25,23 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/

package mage.sets.guildpact;

import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromExileEffect;
import mage.abilities.effects.common.ExileReturnToBattlefieldOwnerNextEndStepEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetOpponent;
@@ -55,28 +52,27 @@
*/
public class GhostCouncilOfOrzhova extends CardImpl {

public GhostCouncilOfOrzhova (UUID ownerId) {
public GhostCouncilOfOrzhova(UUID ownerId) {
super(ownerId, 114, "Ghost Council of Orzhova", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{W}{W}{B}{B}");
this.expansionSetCode = "GPT";
this.supertype.add("Legendary");
this.subtype.add("Spirit");


this.power = new MageInt(4);
this.toughness = new MageInt(4);

// When Ghost Council of Orzhova enters the battlefield, target opponent loses 1 life and you gain 1 life.
Ability ability = new EntersBattlefieldTriggeredAbility(new GhostCouncilOfOrzhovaEffect());
ability.addTarget(new TargetOpponent());
this.addAbility(ability);

// {1}, Sacrifice a creature: Exile Ghost Council of Orzhova. Return it to the battlefield under its owner's control at the beginning of the next end step.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GhostCouncilOfOrzhovaRemovingEffect(), new GenericManaCost(1));
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileReturnToBattlefieldOwnerNextEndStepEffect(), new GenericManaCost(1));
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
this.addAbility(ability);
}

public GhostCouncilOfOrzhova (final GhostCouncilOfOrzhova card) {
public GhostCouncilOfOrzhova(final GhostCouncilOfOrzhova card) {
super(card);
}

@@ -88,6 +84,7 @@ public GhostCouncilOfOrzhova copy() {
}

class GhostCouncilOfOrzhovaEffect extends OneShotEffect {

GhostCouncilOfOrzhovaEffect() {
super(Outcome.Damage);
staticText = "target opponent loses 1 life and you gain 1 life";
@@ -114,44 +111,3 @@ public GhostCouncilOfOrzhovaEffect copy() {
}

}

class GhostCouncilOfOrzhovaRemovingEffect extends OneShotEffect {

private static final String effectText = "Exile {this}. Return it to the battlefield under its owner's control at the beginning of the next end step";

GhostCouncilOfOrzhovaRemovingEffect () {
super(Outcome.Benefit);
staticText = effectText;
}

GhostCouncilOfOrzhovaRemovingEffect(GhostCouncilOfOrzhovaRemovingEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (controller.moveCardToExileWithInfo(permanent, source.getSourceId(), permanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
//create delayed triggered ability
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
}
}
return false;
}

@Override
public GhostCouncilOfOrzhovaRemovingEffect copy() {
return new GhostCouncilOfOrzhovaRemovingEffect(this);
}

}

0 comments on commit 8e0907c

Please sign in to comment.