fixed Aethergeode Miner and Flickering Spirit returning to the battlefield even if they die before their abilities resolve

This commit is contained in:
Evan Kranzler 2017-10-02 19:36:48 -04:00
parent 1a61b657b7
commit ced243df0a
2 changed files with 77 additions and 13 deletions

View file

@ -33,14 +33,17 @@ import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.PayEnergyCost; import mage.abilities.costs.common.PayEnergyCost;
import mage.abilities.effects.common.ExileSourceEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlSourceEffect;
import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect; import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect;
import mage.cards.Card;
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.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/** /**
* *
@ -60,9 +63,7 @@ public class AethergeodeMiner extends CardImpl {
this.addAbility(new AttacksTriggeredAbility(new GetEnergyCountersControllerEffect(2), false)); this.addAbility(new AttacksTriggeredAbility(new GetEnergyCountersControllerEffect(2), false));
// Pay {E}{E}: Exile Aethergeode Miner, then return it to the battlefield under its owner's control. // Pay {E}{E}: Exile Aethergeode Miner, then return it to the battlefield under its owner's control.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileSourceEffect(true), new PayEnergyCost(2)); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AethergeodeMinerEffect(), new PayEnergyCost(2)));
ability.addEffect(new ReturnToBattlefieldUnderOwnerControlSourceEffect());
this.addAbility(ability);
} }
public AethergeodeMiner(final AethergeodeMiner card) { public AethergeodeMiner(final AethergeodeMiner card) {
@ -74,3 +75,34 @@ public class AethergeodeMiner extends CardImpl {
return new AethergeodeMiner(this); return new AethergeodeMiner(this);
} }
} }
class AethergeodeMinerEffect extends OneShotEffect {
public AethergeodeMinerEffect() {
super(Outcome.Neutral);
this.staticText = "Exile {this}, then return it to the battlefield under its owner's control";
}
public AethergeodeMinerEffect(final AethergeodeMinerEffect effect) {
super(effect);
}
@Override
public AethergeodeMinerEffect copy() {
return new AethergeodeMinerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Aethergeode Miner", source.getSourceId(), game)) {
Card card = game.getExile().getCard(source.getSourceId(), game);
if (card != null) {
return card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
}
}
}
return false;
}
}

View file

@ -32,14 +32,17 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.ExileSourceEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
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.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/** /**
* *
@ -48,7 +51,7 @@ import mage.constants.Zone;
public class FlickeringSpirit extends CardImpl { public class FlickeringSpirit extends CardImpl {
public FlickeringSpirit(UUID ownerId, CardSetInfo setInfo) { public FlickeringSpirit(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add(SubType.SPIRIT); this.subtype.add(SubType.SPIRIT);
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
@ -57,9 +60,7 @@ public class FlickeringSpirit extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// {3}{W}: Exile Flickering Spirit, then return it to the battlefield under its owner's control. // {3}{W}: Exile Flickering Spirit, then return it to the battlefield under its owner's control.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileSourceEffect(true), new ManaCostsImpl("{3}{W}")); this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new FlickeringSpiritEffect(), new ManaCostsImpl("{3}{W}")));
ability.addEffect(new ReturnToBattlefieldUnderOwnerControlSourceEffect());
this.addAbility(ability);
} }
@ -72,3 +73,34 @@ public class FlickeringSpirit extends CardImpl {
return new FlickeringSpirit(this); return new FlickeringSpirit(this);
} }
} }
class FlickeringSpiritEffect extends OneShotEffect {
public FlickeringSpiritEffect() {
super(Outcome.Neutral);
this.staticText = "Exile {this}, then return it to the battlefield under its owner's control";
}
public FlickeringSpiritEffect(final FlickeringSpiritEffect effect) {
super(effect);
}
@Override
public FlickeringSpiritEffect copy() {
return new FlickeringSpiritEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Flickering Spirit", source.getSourceId(), game)) {
Card card = game.getExile().getCard(source.getSourceId(), game);
if (card != null) {
return card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
}
}
}
return false;
}
}