From 223c5763594e437138f3c06f309944313fc40a14 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 19 Feb 2021 09:08:14 -0500 Subject: [PATCH] [STX] Implemented Quandrix Command --- .../src/mage/cards/d/DwellOnThePast.java | 78 ++--------------- Mage.Sets/src/mage/cards/g/GaeasBlessing.java | 79 +++--------------- .../src/mage/cards/k/KrosanReclamation.java | 77 ++--------------- Mage.Sets/src/mage/cards/l/LoamingShaman.java | 83 ++----------------- .../src/mage/cards/m/MemorysJourney.java | 78 ++--------------- .../src/mage/cards/q/QuandrixCommand.java | 72 ++++++++++++++++ .../mage/cards/s/StreamOfConsciousness.java | 78 ++--------------- .../mage/sets/StrixhavenSchoolOfMages.java | 1 + ...TargetPlayerShufflesTargetCardsEffect.java | 55 ++++++++++++ .../TargetCardInTargetPlayersGraveyard.java | 36 ++++++++ 10 files changed, 209 insertions(+), 428 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/q/QuandrixCommand.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/TargetPlayerShufflesTargetCardsEffect.java create mode 100644 Mage/src/main/java/mage/target/common/TargetCardInTargetPlayersGraveyard.java diff --git a/Mage.Sets/src/mage/cards/d/DwellOnThePast.java b/Mage.Sets/src/mage/cards/d/DwellOnThePast.java index 7484dbbe82..8121412848 100644 --- a/Mage.Sets/src/mage/cards/d/DwellOnThePast.java +++ b/Mage.Sets/src/mage/cards/d/DwellOnThePast.java @@ -1,36 +1,26 @@ - package mage.cards.d; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInTargetPlayersGraveyard; + +import java.util.UUID; /** - * * @author fireshoes */ public final class DwellOnThePast extends CardImpl { public DwellOnThePast(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}"); // Target player shuffles up to four target cards from their graveyard into their library. - this.getSpellAbility().addEffect(new DwellOnThePastEffect()); + this.getSpellAbility().addEffect(new TargetPlayerShufflesTargetCardsEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addTarget(new DwellOnThePastTarget()); - + this.getSpellAbility().addTarget(new TargetCardInTargetPlayersGraveyard(4)); } private DwellOnThePast(final DwellOnThePast card) { @@ -42,57 +32,3 @@ public final class DwellOnThePast extends CardImpl { return new DwellOnThePast(this); } } - -class DwellOnThePastEffect extends OneShotEffect { - - public DwellOnThePastEffect() { - super(Outcome.Neutral); - this.staticText = "Target player shuffles up to four target cards from their graveyard into their library"; - } - - public DwellOnThePastEffect(final DwellOnThePastEffect effect) { - super(effect); - } - - @Override - public DwellOnThePastEffect copy() { - return new DwellOnThePastEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getFirstTarget()); - if (controller != null) { - return controller.shuffleCardsToLibrary(new CardsImpl(source.getTargets().get(1).getTargets()), game, source); - } - return false; - } -} - -class DwellOnThePastTarget extends TargetCardInGraveyard { - - public DwellOnThePastTarget() { - super(0, 4, new FilterCard("cards from target player's graveyard")); - } - - public DwellOnThePastTarget(final DwellOnThePastTarget target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { - UUID firstTarget = source.getFirstTarget(); - if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) { - return filter.match(card, game); - } - } - return false; - } - - @Override - public DwellOnThePastTarget copy() { - return new DwellOnThePastTarget(this); - } -} diff --git a/Mage.Sets/src/mage/cards/g/GaeasBlessing.java b/Mage.Sets/src/mage/cards/g/GaeasBlessing.java index c6742b3356..c0037e3f25 100644 --- a/Mage.Sets/src/mage/cards/g/GaeasBlessing.java +++ b/Mage.Sets/src/mage/cards/g/GaeasBlessing.java @@ -1,37 +1,34 @@ - package mage.cards.g; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.ZoneChangeTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.cards.Card; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; -import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInTargetPlayersGraveyard; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class GaeasBlessing extends CardImpl { public GaeasBlessing(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}"); // Target player shuffles up to three target cards from their graveyard into their library. - this.getSpellAbility().addEffect(new GaeasBlessingEffect()); + this.getSpellAbility().addEffect(new TargetPlayerShufflesTargetCardsEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addTarget(new GaeasBlessingTarget()); + this.getSpellAbility().addTarget(new TargetCardInTargetPlayersGraveyard(3)); // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); @@ -50,67 +47,13 @@ public final class GaeasBlessing extends CardImpl { } } -class GaeasBlessingEffect extends OneShotEffect { - - public GaeasBlessingEffect() { - super(Outcome.Neutral); - this.staticText = "Target player shuffles up to three target cards from their graveyard into their library"; - } - - public GaeasBlessingEffect(final GaeasBlessingEffect effect) { - super(effect); - } - - @Override - public GaeasBlessingEffect copy() { - return new GaeasBlessingEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { - return targetPlayer.shuffleCardsToLibrary(new CardsImpl(source.getTargets().get(1).getTargets()), game, source); - } - return false; - } -} - -class GaeasBlessingTarget extends TargetCardInGraveyard { - - public GaeasBlessingTarget() { - super(0, 3, new FilterCard()); - } - - public GaeasBlessingTarget(final GaeasBlessingTarget target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { - UUID firstTarget = source.getFirstTarget(); - if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) { - return filter.match(card, game); - } - } - return false; - } - - @Override - public GaeasBlessingTarget copy() { - return new GaeasBlessingTarget(this); - } -} - class GaeasBlessingTriggeredAbility extends ZoneChangeTriggeredAbility { - public GaeasBlessingTriggeredAbility() { + GaeasBlessingTriggeredAbility() { super(Zone.LIBRARY, Zone.GRAVEYARD, new GaeasBlessingGraveToLibraryEffect(), "", false); } - public GaeasBlessingTriggeredAbility(final GaeasBlessingTriggeredAbility ability) { + private GaeasBlessingTriggeredAbility(final GaeasBlessingTriggeredAbility ability) { super(ability); } @@ -127,12 +70,12 @@ class GaeasBlessingTriggeredAbility extends ZoneChangeTriggeredAbility { class GaeasBlessingGraveToLibraryEffect extends OneShotEffect { - public GaeasBlessingGraveToLibraryEffect() { + GaeasBlessingGraveToLibraryEffect() { super(Outcome.GainLife); staticText = "shuffle your graveyard into your library"; } - public GaeasBlessingGraveToLibraryEffect(final GaeasBlessingGraveToLibraryEffect effect) { + private GaeasBlessingGraveToLibraryEffect(final GaeasBlessingGraveToLibraryEffect effect) { super(effect); } diff --git a/Mage.Sets/src/mage/cards/k/KrosanReclamation.java b/Mage.Sets/src/mage/cards/k/KrosanReclamation.java index a7541ec6f4..fb95f86803 100644 --- a/Mage.Sets/src/mage/cards/k/KrosanReclamation.java +++ b/Mage.Sets/src/mage/cards/k/KrosanReclamation.java @@ -1,38 +1,29 @@ - package mage.cards.k; -import java.util.UUID; -import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; import mage.abilities.keyword.FlashbackAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.TimingRule; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInTargetPlayersGraveyard; + +import java.util.UUID; /** - * * @author fireshoes */ public final class KrosanReclamation extends CardImpl { public KrosanReclamation(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); // Target player shuffles up to two target cards from their graveyard into their library. - this.getSpellAbility().addEffect(new KrosanReclamationEffect()); + this.getSpellAbility().addEffect(new TargetPlayerShufflesTargetCardsEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addTarget(new KrosanReclamationTarget()); + this.getSpellAbility().addTarget(new TargetCardInTargetPlayersGraveyard(2)); // Flashback {1}{G} this.addAbility(new FlashbackAbility(new ManaCostsImpl("{1}{G}"), TimingRule.INSTANT)); @@ -47,57 +38,3 @@ public final class KrosanReclamation extends CardImpl { return new KrosanReclamation(this); } } - -class KrosanReclamationEffect extends OneShotEffect { - - public KrosanReclamationEffect() { - super(Outcome.Neutral); - this.staticText = "Target player shuffles up to two target cards from their graveyard into their library"; - } - - public KrosanReclamationEffect(final KrosanReclamationEffect effect) { - super(effect); - } - - @Override - public KrosanReclamationEffect copy() { - return new KrosanReclamationEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { - return targetPlayer.shuffleCardsToLibrary(new CardsImpl(source.getTargets().get(1).getTargets()), game, source); - } - return false; - } -} - -class KrosanReclamationTarget extends TargetCardInGraveyard { - - public KrosanReclamationTarget() { - super(0, 2, new FilterCard()); - } - - public KrosanReclamationTarget(final KrosanReclamationTarget target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { - UUID firstTarget = source.getFirstTarget(); - if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) { - return filter.match(card, game); - } - } - return false; - } - - @Override - public KrosanReclamationTarget copy() { - return new KrosanReclamationTarget(this); - } -} diff --git a/Mage.Sets/src/mage/cards/l/LoamingShaman.java b/Mage.Sets/src/mage/cards/l/LoamingShaman.java index 4bf72ad511..07f172952e 100644 --- a/Mage.Sets/src/mage/cards/l/LoamingShaman.java +++ b/Mage.Sets/src/mage/cards/l/LoamingShaman.java @@ -1,28 +1,19 @@ - package mage.cards.l; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInTargetPlayersGraveyard; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class LoamingShaman extends CardImpl { @@ -36,9 +27,9 @@ public final class LoamingShaman extends CardImpl { this.toughness = new MageInt(2); // When Loaming Shaman enters the battlefield, target player shuffles any number of target cards from their graveyard into their library. - Ability ability = new EntersBattlefieldTriggeredAbility(new LoamingShamanEffect(), false); + Ability ability = new EntersBattlefieldTriggeredAbility(new TargetPlayerShufflesTargetCardsEffect(), false); ability.addTarget(new TargetPlayer()); - ability.addTarget(new LoamingShamanTargetCardsInGraveyard(0, Integer.MAX_VALUE, new FilterCard("cards in target player's graveyard"))); + ability.addTarget(new TargetCardInTargetPlayersGraveyard(Integer.MAX_VALUE)); this.addAbility(ability); } @@ -51,65 +42,3 @@ public final class LoamingShaman extends CardImpl { return new LoamingShaman(this); } } - -class LoamingShamanEffect extends OneShotEffect { - - public LoamingShamanEffect() { - super(Outcome.Benefit); - this.staticText = "target player shuffles any number of target cards from their graveyard into their library"; - } - - public LoamingShamanEffect(final LoamingShamanEffect effect) { - super(effect); - } - - @Override - public LoamingShamanEffect copy() { - return new LoamingShamanEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { - Cards cards = new CardsImpl(source.getTargets().get(1).getTargets()); - targetPlayer.moveCards(cards, Zone.LIBRARY, source, game); - targetPlayer.shuffleLibrary(source, game); - return true; - } - return false; - } -} - -class LoamingShamanTargetCardsInGraveyard extends TargetCardInGraveyard { - - public LoamingShamanTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) { - super(minNumTargets, maxNumTargets, filter); - } - - public LoamingShamanTargetCardsInGraveyard(final LoamingShamanTargetCardsInGraveyard target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - UUID targetPlayerId = source.getFirstTarget(); - UUID firstTarget = this.getFirstTarget(); - Card targetCard = game.getCard(id); - if (firstTarget != null) { - Card card = game.getCard(firstTarget); - if (card == null || targetCard == null - || !card.isOwnedBy(targetCard.getOwnerId())) { - return false; - } - } else if (targetCard == null || !targetCard.isOwnedBy(targetPlayerId)) { - return false; - } - return super.canTarget(id, source, game); - } - - @Override - public LoamingShamanTargetCardsInGraveyard copy() { - return new LoamingShamanTargetCardsInGraveyard(this); - } -} diff --git a/Mage.Sets/src/mage/cards/m/MemorysJourney.java b/Mage.Sets/src/mage/cards/m/MemorysJourney.java index a37ed2e570..cd3dba5db4 100644 --- a/Mage.Sets/src/mage/cards/m/MemorysJourney.java +++ b/Mage.Sets/src/mage/cards/m/MemorysJourney.java @@ -1,38 +1,30 @@ - package mage.cards.m; -import java.util.UUID; -import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; import mage.abilities.keyword.FlashbackAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.TimingRule; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInTargetPlayersGraveyard; + +import java.util.UUID; /** - * * @author North */ public final class MemorysJourney extends CardImpl { public MemorysJourney(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}"); // Target player shuffles up to three target cards from their graveyard into their library. - this.getSpellAbility().addEffect(new MemorysJourneyEffect()); + this.getSpellAbility().addEffect(new TargetPlayerShufflesTargetCardsEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addTarget(new MemorysJourneyTarget()); + this.getSpellAbility().addTarget(new TargetCardInTargetPlayersGraveyard(3)); + // Flashback {G} this.addAbility(new FlashbackAbility(new ManaCostsImpl("{G}"), TimingRule.INSTANT)); } @@ -46,57 +38,3 @@ public final class MemorysJourney extends CardImpl { return new MemorysJourney(this); } } - -class MemorysJourneyEffect extends OneShotEffect { - - public MemorysJourneyEffect() { - super(Outcome.Neutral); - this.staticText = "Target player shuffles up to three target cards from their graveyard into their library"; - } - - public MemorysJourneyEffect(final MemorysJourneyEffect effect) { - super(effect); - } - - @Override - public MemorysJourneyEffect copy() { - return new MemorysJourneyEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { - return targetPlayer.shuffleCardsToLibrary(new CardsImpl(source.getTargets().get(1).getTargets()), game, source); - } - return false; - } -} - -class MemorysJourneyTarget extends TargetCardInGraveyard { - - public MemorysJourneyTarget() { - super(0, 3, new FilterCard()); - } - - public MemorysJourneyTarget(final MemorysJourneyTarget target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { - UUID firstTarget = source.getFirstTarget(); - if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) { - return filter.match(card, game); - } - } - return false; - } - - @Override - public MemorysJourneyTarget copy() { - return new MemorysJourneyTarget(this); - } -} diff --git a/Mage.Sets/src/mage/cards/q/QuandrixCommand.java b/Mage.Sets/src/mage/cards/q/QuandrixCommand.java new file mode 100644 index 0000000000..36f2dd5775 --- /dev/null +++ b/Mage.Sets/src/mage/cards/q/QuandrixCommand.java @@ -0,0 +1,72 @@ +package mage.cards.q; + +import mage.abilities.Mode; +import mage.abilities.effects.common.CounterTargetEffect; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.filter.FilterSpell; +import mage.filter.predicate.Predicates; +import mage.target.TargetPlayer; +import mage.target.TargetSpell; +import mage.target.common.TargetCardInTargetPlayersGraveyard; +import mage.target.common.TargetCreatureOrPlaneswalker; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class QuandrixCommand extends CardImpl { + + private static final FilterSpell filter = new FilterSpell("artifact or enchantment spell"); + + static { + filter.add(Predicates.or( + CardType.ARTIFACT.getPredicate(), + CardType.ENCHANTMENT.getPredicate() + )); + } + + public QuandrixCommand(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}{U}"); + + // Choose two — + this.getSpellAbility().getModes().setMinModes(2); + this.getSpellAbility().getModes().setMaxModes(2); + + // • Return target creature or planeswalker to its owner's hand. + this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); + this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker()); + + // • Counter target artifact or enchantment spell. + Mode mode = new Mode(new CounterTargetEffect()); + mode.addTarget(new TargetSpell(filter)); + this.getSpellAbility().addMode(mode); + + // • Put two +1/+1 counters on target creature. + mode = new Mode(new AddCountersTargetEffect(CounterType.P1P1.createInstance(2))); + mode.addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addMode(mode); + + // • Target player shuffles up to three target cards from their graveyard into their library. + mode = new Mode(new TargetPlayerShufflesTargetCardsEffect()); + mode.addTarget(new TargetPlayer()); + mode.addTarget(new TargetCardInTargetPlayersGraveyard(3)); + this.getSpellAbility().addMode(mode); + } + + private QuandrixCommand(final QuandrixCommand card) { + super(card); + } + + @Override + public QuandrixCommand copy() { + return new QuandrixCommand(this); + } +} diff --git a/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java b/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java index 44922530e4..51ba8deb1c 100644 --- a/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java +++ b/Mage.Sets/src/mage/cards/s/StreamOfConsciousness.java @@ -1,25 +1,16 @@ package mage.cards.s; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.TargetPlayerShufflesTargetCardsEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.Zone; -import mage.filter.FilterCard; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; -import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCardInTargetPlayersGraveyard; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class StreamOfConsciousness extends CardImpl { @@ -29,10 +20,9 @@ public final class StreamOfConsciousness extends CardImpl { this.subtype.add(SubType.ARCANE); // Target player shuffles up to four target cards from their graveyard into their library. - this.getSpellAbility().addEffect(new StreamOfConsciousnessEffect()); + this.getSpellAbility().addEffect(new TargetPlayerShufflesTargetCardsEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addTarget(new StreamOfConsciousnessTarget()); - + this.getSpellAbility().addTarget(new TargetCardInTargetPlayersGraveyard(4)); } private StreamOfConsciousness(final StreamOfConsciousness card) { @@ -44,59 +34,3 @@ public final class StreamOfConsciousness extends CardImpl { return new StreamOfConsciousness(this); } } - -class StreamOfConsciousnessEffect extends OneShotEffect { - - public StreamOfConsciousnessEffect() { - super(Outcome.Neutral); - this.staticText = "Target player shuffles up to four target cards from their graveyard into their library"; - } - - public StreamOfConsciousnessEffect(final StreamOfConsciousnessEffect effect) { - super(effect); - } - - @Override - public StreamOfConsciousnessEffect copy() { - return new StreamOfConsciousnessEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); - if (player != null) { - Cards targets = new CardsImpl(source.getTargets().get(1).getTargets()); - targets.retainAll(player.getGraveyard()); - return player.shuffleCardsToLibrary(targets, game, source); - } - return false; - } -} - -class StreamOfConsciousnessTarget extends TargetCardInGraveyard { - - public StreamOfConsciousnessTarget() { - super(0, 4, new FilterCard("cards from target player's graveyard")); - } - - public StreamOfConsciousnessTarget(final StreamOfConsciousnessTarget target) { - super(target); - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { - UUID firstTarget = source.getFirstTarget(); - if (firstTarget != null && game.getPlayer(firstTarget).getGraveyard().contains(id)) { - return filter.match(card, game); - } - } - return false; - } - - @Override - public StreamOfConsciousnessTarget copy() { - return new StreamOfConsciousnessTarget(this); - } -} diff --git a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java index 1e3d9e7d99..a8cabe2780 100644 --- a/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java +++ b/Mage.Sets/src/mage/sets/StrixhavenSchoolOfMages.java @@ -28,6 +28,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet { this.maxCardNumberInBooster = 275; cards.add(new SetCardInfo("Prismari Command", 214, Rarity.RARE, mage.cards.p.PrismariCommand.class)); + cards.add(new SetCardInfo("Quandrix Command", 217, Rarity.RARE, mage.cards.q.QuandrixCommand.class)); cards.add(new SetCardInfo("Silverquill Command", 232, Rarity.RARE, mage.cards.s.SilverquillCommand.class)); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/TargetPlayerShufflesTargetCardsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TargetPlayerShufflesTargetCardsEffect.java new file mode 100644 index 0000000000..fa1c742c29 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/TargetPlayerShufflesTargetCardsEffect.java @@ -0,0 +1,55 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * @author TheElk801 + */ +public class TargetPlayerShufflesTargetCardsEffect extends OneShotEffect { + + public TargetPlayerShufflesTargetCardsEffect() { + super(Outcome.Neutral); + } + + private TargetPlayerShufflesTargetCardsEffect(final TargetPlayerShufflesTargetCardsEffect effect) { + super(effect); + } + + @Override + public TargetPlayerShufflesTargetCardsEffect copy() { + return new TargetPlayerShufflesTargetCardsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player targetPlayer = game.getPlayer(source.getFirstTarget()); + Cards cards = new CardsImpl(source.getTargets().get(1).getTargets()); + if (targetPlayer != null && !cards.isEmpty()) { + return targetPlayer.shuffleCardsToLibrary(cards, game, source); + } + return false; + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + String rule = "target player shuffles "; + int targetNumber = mode.getTargets().get(1).getMaxNumberOfTargets(); + if (targetNumber == Integer.MAX_VALUE) { + rule += "any number of target cards"; + } else { + rule += "up to " + CardUtil.numberToText(targetNumber, "one") + " target card" + (targetNumber > 1 ? "s" : ""); + } + return rule + " from their graveyard into their library"; + } +} diff --git a/Mage/src/main/java/mage/target/common/TargetCardInTargetPlayersGraveyard.java b/Mage/src/main/java/mage/target/common/TargetCardInTargetPlayersGraveyard.java new file mode 100644 index 0000000000..419fcd4472 --- /dev/null +++ b/Mage/src/main/java/mage/target/common/TargetCardInTargetPlayersGraveyard.java @@ -0,0 +1,36 @@ +package mage.target.common; + +import mage.abilities.Ability; +import mage.cards.Card; +import mage.filter.StaticFilters; +import mage.game.Game; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class TargetCardInTargetPlayersGraveyard extends TargetCardInGraveyard { + + public TargetCardInTargetPlayersGraveyard(int targets) { + super(0, targets, StaticFilters.FILTER_CARD); + } + + private TargetCardInTargetPlayersGraveyard(final TargetCardInTargetPlayersGraveyard target) { + super(target); + } + + @Override + public boolean canTarget(UUID id, Ability source, Game game) { + if (!super.canTarget(id, source, game)) { + return false; + } + Card card = game.getCard(id); + return card != null && card.isOwnedBy(source.getFirstTarget()); + } + + @Override + public TargetCardInTargetPlayersGraveyard copy() { + return new TargetCardInTargetPlayersGraveyard(this); + } +}