Midnight Ritual - Changes to card movement handling.

This commit is contained in:
LevelX2 2016-01-08 14:02:02 +01:00
parent 3ed457e705
commit 0f4294a66c
3 changed files with 30 additions and 31 deletions

View file

@ -32,13 +32,16 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterCreatureCard;
import mage.cards.Card;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.token.ZombieToken; import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
/** /**
@ -60,10 +63,8 @@ public class MidnightRitual extends CardImpl {
} }
@Override @Override
public void adjustTargets(Ability ability, Game game) public void adjustTargets(Ability ability, Game game) {
{ if (ability instanceof SpellAbility) {
if (ability instanceof SpellAbility)
{
ability.getTargets().clear(); ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(ability.getManaCostsToPay().getX(), filter)); ability.addTarget(new TargetCardInYourGraveyard(ability.getManaCostsToPay().getX(), filter));
} }
@ -86,8 +87,7 @@ class MidnightRitualEffect extends OneShotEffect {
this.staticText = "Exile X target creature cards from your graveyard. For each creature card exiled this way, put a 2/2 black Zombie creature token onto the battlefield"; this.staticText = "Exile X target creature cards from your graveyard. For each creature card exiled this way, put a 2/2 black Zombie creature token onto the battlefield";
} }
public MidnightRitualEffect(final MidnightRitualEffect effect) public MidnightRitualEffect(final MidnightRitualEffect effect) {
{
super(effect); super(effect);
} }
@ -97,16 +97,16 @@ class MidnightRitualEffect extends OneShotEffect {
} }
@Override @Override
public boolean apply(Game game, Ability source) public boolean apply(Game game, Ability source) {
{ Player controller = game.getPlayer(source.getControllerId());
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) { if (controller != null) {
Card card = game.getCard(targetId); Cards cardsToExile = new CardsImpl(getTargetPointer().getTargets(game, source));
if (card != null) { controller.moveCards(cardsToExile, Zone.EXILED, source, game);
if (card.moveToExile(null, null, source.getSourceId(), game)) { if (!cardsToExile.isEmpty()) {
new ZombieToken().putOntoBattlefield(1, game, source.getSourceId(), card.getOwnerId()); new ZombieToken().putOntoBattlefield(cardsToExile.size(), game, source.getSourceId(), controller.getId());
}
}
} }
return true; return true;
} }
return false;
}
} }

View file

@ -28,13 +28,13 @@
package mage.sets.saviorsofkamigawa; package mage.sets.saviorsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
import mage.target.Target; import mage.target.Target;
@ -51,7 +51,6 @@ public class DeathDenied extends CardImpl {
this.expansionSetCode = "SOK"; this.expansionSetCode = "SOK";
this.subtype.add("Arcane"); this.subtype.add("Arcane");
// Return X target creature cards from your graveyard to your hand. // Return X target creature cards from your graveyard to your hand.
Effect effect = new ReturnFromGraveyardToHandTargetEffect(); Effect effect = new ReturnFromGraveyardToHandTargetEffect();
effect.setText("Return X target creature cards from your graveyard to your hand"); effect.setText("Return X target creature cards from your graveyard to your hand");
@ -65,7 +64,7 @@ public class DeathDenied extends CardImpl {
if (ability instanceof SpellAbility) { if (ability instanceof SpellAbility) {
ability.getTargets().clear(); ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX(); int xValue = ability.getManaCostsToPay().getX();
Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1?" creature cards":"creature card").append(" from your graveyard").toString())); Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1 ? " creature cards" : "creature card").append(" from your graveyard").toString()));
ability.addTarget(target); ability.addTarget(target);
} }
} }

View file

@ -61,7 +61,7 @@ public class ReturnFromGraveyardToHandTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), null, Zone.HAND, source, game); return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)), Zone.HAND, source, game);
} }
return false; return false;
} }