From 044b25415554b8fdf2ac5be1b8fa762ab386518b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 18 Jun 2020 19:11:02 +0200 Subject: [PATCH] * Some more rework/clean up of the PlayFromNotOwnHandZone effects (fixes #6580). --- Mage.Sets/src/mage/cards/s/SinsOfThePast.java | 39 ++------------ Mage.Sets/src/mage/cards/s/Spelljack.java | 51 ++----------------- 2 files changed, 6 insertions(+), 84 deletions(-) diff --git a/Mage.Sets/src/mage/cards/s/SinsOfThePast.java b/Mage.Sets/src/mage/cards/s/SinsOfThePast.java index 05441948f1..35177017ea 100644 --- a/Mage.Sets/src/mage/cards/s/SinsOfThePast.java +++ b/Mage.Sets/src/mage/cards/s/SinsOfThePast.java @@ -20,6 +20,7 @@ import mage.target.common.TargetCardInYourGraveyard; import mage.target.targetpointer.FixedTarget; import java.util.UUID; +import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect; /** * @author emerald000 @@ -65,8 +66,8 @@ class SinsOfThePastEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); if (card != null) { - ContinuousEffect effect = new SinsOfThePastCastFromGraveyardEffect(); - effect.setTargetPointer(new FixedTarget(card.getId())); + ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.GRAVEYARD, TargetController.YOU, Duration.EndOfTurn, true);; + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); effect = new SinsOfThePastReplacementEffect(card.getId()); game.addEffect(effect, source); @@ -76,40 +77,6 @@ class SinsOfThePastEffect extends OneShotEffect { } } -class SinsOfThePastCastFromGraveyardEffect extends AsThoughEffectImpl { - - SinsOfThePastCastFromGraveyardEffect() { - super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.PlayForFree); - } - - SinsOfThePastCastFromGraveyardEffect(final SinsOfThePastCastFromGraveyardEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public SinsOfThePastCastFromGraveyardEffect copy() { - return new SinsOfThePastCastFromGraveyardEffect(this); - } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - if (objectId.equals(this.getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { - Player player = game.getPlayer(affectedControllerId); - Card cardToCast = game.getCard(objectId); - if(player != null && cardToCast != null) { - player.setCastSourceIdWithAlternateMana(objectId, null, cardToCast.getSpellAbility().getCosts()); - return true; - } - } - return false; - } -} - class SinsOfThePastReplacementEffect extends ReplacementEffectImpl { private final UUID cardId; diff --git a/Mage.Sets/src/mage/cards/s/Spelljack.java b/Mage.Sets/src/mage/cards/s/Spelljack.java index d15fcb8045..7ea471aee7 100644 --- a/Mage.Sets/src/mage/cards/s/Spelljack.java +++ b/Mage.Sets/src/mage/cards/s/Spelljack.java @@ -6,6 +6,7 @@ import mage.abilities.Ability; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -13,6 +14,7 @@ import mage.constants.AsThoughEffectType; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.TargetController; import mage.constants.Zone; import mage.constants.ZoneDetail; import mage.game.Game; @@ -71,7 +73,7 @@ class SpelljackEffect extends OneShotEffect { if (stackObject != null && game.getStack().counter(targetId, source.getSourceId(), game, Zone.EXILED, false, ZoneDetail.NONE)) { Card card = ((Spell) stackObject).getCard(); if (card != null) { - ContinuousEffect effect = new SpelljackCastFromExileEffect(); + ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, TargetController.YOU, Duration.Custom, true); effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId()))); game.addEffect(effect, source); } @@ -81,50 +83,3 @@ class SpelljackEffect extends OneShotEffect { return false; } } - -class SpelljackCastFromExileEffect extends AsThoughEffectImpl { - - SpelljackCastFromExileEffect() { - super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit); - staticText = "You may cast that card without paying its mana cost as long as it remains exiled"; - } - - SpelljackCastFromExileEffect(final SpelljackCastFromExileEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public SpelljackCastFromExileEffect copy() { - return new SpelljackCastFromExileEffect(this); - } - - @Override - public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { - if (affectedControllerId.equals(source.getControllerId())) { - if (getTargetPointer().getFirst(game, source) == null) { - this.discard(); - return false; - } - if (sourceId.equals(getTargetPointer().getFirst(game, source))) { - Card card = game.getCard(sourceId); - if (card != null) { - if (game.getState().getZone(sourceId) == Zone.EXILED) { - Player player = game.getPlayer(affectedControllerId); - if(player != null) { - player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); - } - return true; - } else { - this.discard(); - } - } - } - } - return false; - } -}