From c8ddd62e3be82cce2da9d1c6c819fab3a53017b7 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 22 Jun 2020 15:38:36 +0200 Subject: [PATCH] * Reworked some card movement to player methods (#4866). --- .../src/mage/cards/d/DireFleetDaredevil.java | 9 ++-- .../src/mage/cards/d/DistantMemories.java | 12 +++-- .../src/mage/cards/t/ToshiroUmezawa.java | 45 ++++++++++--------- .../replacement/DiesReplacementEffect.java | 2 +- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DireFleetDaredevil.java b/Mage.Sets/src/mage/cards/d/DireFleetDaredevil.java index eee9cd1434..664420628b 100644 --- a/Mage.Sets/src/mage/cards/d/DireFleetDaredevil.java +++ b/Mage.Sets/src/mage/cards/d/DireFleetDaredevil.java @@ -49,7 +49,9 @@ public final class DireFleetDaredevil extends CardImpl { // First strike this.addAbility(FirstStrikeAbility.getInstance()); - // When this enters the battlefield, exile target instant or sorcery card from an opponent's graveyard. You may cast that card this turn and you may spend mana as though it were mana of any color. If that card would be put into a graveyard this turn, exile it instead. + // When Dire Fleet Daredevil enters the battlefield, exile target instant or sorcery card from an opponent's graveyard. + // You may cast it this turn, and you may spend mana as though it were mana of any type to cast that spell. + // If that spell would be put into a graveyard this turn, exile it instead. Ability ability = new EntersBattlefieldTriggeredAbility(new DireFleetDaredevilEffect()); ability.addTarget(new TargetCardInOpponentsGraveyard(filter)); this.addAbility(ability); @@ -167,8 +169,9 @@ class DireFleetDaredevilReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getTargetId()); - if (card != null) { - return card.moveToZone(Zone.EXILED, source.getSourceId(), game, false); + Player controller = game.getPlayer(source.getControllerId()); + if (card != null && controller != null) { + return controller.moveCards(card, Zone.EXILED, source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/d/DistantMemories.java b/Mage.Sets/src/mage/cards/d/DistantMemories.java index 1869d6ba37..3833a540a9 100644 --- a/Mage.Sets/src/mage/cards/d/DistantMemories.java +++ b/Mage.Sets/src/mage/cards/d/DistantMemories.java @@ -65,7 +65,7 @@ class DistantMemoriesEffect extends OneShotEffect { if (controller.searchLibrary(target, source, game)) { Card card = controller.getLibrary().remove(target.getFirstTarget(), game); if (card != null) { - card.moveToZone(Zone.EXILED, source.getSourceId(), game, false); + controller.moveCards(card, Zone.EXILED, source, game); controller.shuffleLibrary(source, game); StringBuilder sb = new StringBuilder(); @@ -76,9 +76,13 @@ class DistantMemoriesEffect extends OneShotEffect { Set opponents = game.getOpponents(source.getControllerId()); for (UUID opponentUuid : opponents) { Player opponent = game.getPlayer(opponentUuid); - if (opponent != null - && opponent.chooseUse(Outcome.Detriment, sb.toString(), source, game)) { - putInHand = true; + if (opponent != null) { + if (opponent.chooseUse(Outcome.Detriment, sb.toString(), source, game)) { + putInHand = true; + game.informPlayers(opponent.getName() + " decides to put the selected card into the player's hand."); + } else { + game.informPlayers(opponent.getName() + " decides to leave the card in exile."); + } } } diff --git a/Mage.Sets/src/mage/cards/t/ToshiroUmezawa.java b/Mage.Sets/src/mage/cards/t/ToshiroUmezawa.java index 6b9c5c8582..3d6c22d1a8 100644 --- a/Mage.Sets/src/mage/cards/t/ToshiroUmezawa.java +++ b/Mage.Sets/src/mage/cards/t/ToshiroUmezawa.java @@ -5,8 +5,10 @@ import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.DiesCreatureTriggeredAbility; +import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.replacement.PutToGraveyardReplacementEffect; import mage.abilities.keyword.BushidoAbility; import mage.cards.Card; import mage.cards.CardImpl; @@ -22,28 +24,29 @@ import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.players.Player; import mage.target.common.TargetCardInYourGraveyard; +import mage.target.targetpointer.FixedTarget; /** * * @author LevelX2 */ public final class ToshiroUmezawa extends CardImpl { - + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature an opponent controls"); private static final FilterCard filterInstant = new FilterCard("instant card from your graveyard"); - + static { filter.add(TargetController.OPPONENT.getControllerPredicate()); filterInstant.add(CardType.INSTANT.getPredicate()); } - + public ToshiroUmezawa(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}"); this.addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.SAMURAI); - + this.power = new MageInt(2); this.toughness = new MageInt(2); @@ -55,13 +58,13 @@ public final class ToshiroUmezawa extends CardImpl { Ability ability = new DiesCreatureTriggeredAbility(new ToshiroUmezawaEffect(), true, filter); ability.addTarget(new TargetCardInYourGraveyard(1, 1, filterInstant)); this.addAbility(ability); - + } - + public ToshiroUmezawa(final ToshiroUmezawa card) { super(card); } - + @Override public ToshiroUmezawa copy() { return new ToshiroUmezawa(this); @@ -69,22 +72,22 @@ public final class ToshiroUmezawa extends CardImpl { } class ToshiroUmezawaEffect extends OneShotEffect { - + public ToshiroUmezawaEffect() { super(Outcome.Benefit); this.staticText = "cast target instant card from your graveyard. " + "If that card would be put into a graveyard this turn, exile it instead"; } - + public ToshiroUmezawaEffect(final ToshiroUmezawaEffect effect) { super(effect); } - + @Override public ToshiroUmezawaEffect copy() { return new ToshiroUmezawaEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); @@ -104,45 +107,45 @@ class ToshiroUmezawaEffect extends OneShotEffect { } class ToshiroUmezawaReplacementEffect extends ReplacementEffectImpl { - + private final UUID cardId; - + public ToshiroUmezawaReplacementEffect(UUID cardId) { super(Duration.EndOfTurn, Outcome.Exile); this.cardId = cardId; } - + public ToshiroUmezawaReplacementEffect(final ToshiroUmezawaReplacementEffect effect) { super(effect); this.cardId = effect.cardId; } - + @Override public ToshiroUmezawaReplacementEffect copy() { return new ToshiroUmezawaReplacementEffect(this); } - + @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { UUID eventObject = event.getTargetId(); StackObject stackObject = game.getStack().getStackObject(eventObject); - if (stackObject != null) { + Player controller = game.getPlayer(source.getControllerId()); + if (stackObject != null && controller != null) { if (stackObject instanceof Spell) { game.rememberLKI(stackObject.getId(), Zone.STACK, stackObject); } if (stackObject instanceof Card && eventObject.equals(cardId)) { - ((Card) stackObject).moveToExile(null, null, source.getSourceId(), game); - return true; + return controller.moveCards((Card) stackObject, Zone.EXILED, source, game); } } return false; } - + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == EventType.ZONE_CHANGE; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; diff --git a/Mage/src/main/java/mage/abilities/effects/common/replacement/DiesReplacementEffect.java b/Mage/src/main/java/mage/abilities/effects/common/replacement/DiesReplacementEffect.java index 12ece0c7b5..48c2d0a67f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/replacement/DiesReplacementEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/replacement/DiesReplacementEffect.java @@ -52,7 +52,7 @@ public class DiesReplacementEffect extends ReplacementEffectImpl { Permanent permanent = ((ZoneChangeEvent) event).getTarget(); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && permanent != null) { - return controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); + return controller.moveCards(permanent, Zone.EXILED, source, game); } return false; }