From 1adcdd3b62d5b0f061797ac7c0d7678f24264656 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Thu, 21 Jun 2018 13:10:08 -0400 Subject: [PATCH] Implement Thought Dissector --- .../src/mage/cards/t/ThoughtDissector.java | 106 ++++++++++++++++++ Mage.Sets/src/mage/sets/Darksteel.java | 1 + 2 files changed, 107 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/ThoughtDissector.java diff --git a/Mage.Sets/src/mage/cards/t/ThoughtDissector.java b/Mage.Sets/src/mage/cards/t/ThoughtDissector.java new file mode 100644 index 0000000000..523217f235 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/ThoughtDissector.java @@ -0,0 +1,106 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.VariableManaCost; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.OneShotEffect; +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.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +import java.util.UUID; + +/** + * + * @author noahg + */ +public final class ThoughtDissector extends CardImpl { + + public ThoughtDissector(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + + // {X}, {tap}: Target opponent reveals cards from the top of his or her library until an artifact card or X cards are revealed, whichever comes first. If an artifact card is revealed this way, put it onto the battlefield under your control and sacrifice Thought Dissector. Put the rest of the revealed cards into that player's graveyard. + SimpleActivatedAbility abilitiy = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ThoughtDissectorEffect(), new VariableManaCost()); + abilitiy.addCost(new TapSourceCost()); + abilitiy.addTarget(new TargetOpponent()); + this.addAbility(abilitiy); + } + + public ThoughtDissector(final ThoughtDissector card) { + super(card); + } + + @Override + public ThoughtDissector copy() { + return new ThoughtDissector(this); + } +} + +class ThoughtDissectorEffect extends OneShotEffect { + + private static final ManacostVariableValue amount = new ManacostVariableValue(); + + public ThoughtDissectorEffect() { + super(Outcome.Detriment); + staticText = "Target opponent reveals cards from the top of his or her library until an artifact card or X cards are revealed, whichever comes first. If an artifact card is revealed this way, put it onto the battlefield under your control and sacrifice {this}. Put the rest of the revealed cards into that player's graveyard."; + } + + public ThoughtDissectorEffect(final ThoughtDissectorEffect effect) { + super(effect); + } + + @Override + public ThoughtDissectorEffect copy() { + return new ThoughtDissectorEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source)); + int max = amount.calculate(game, source, this); + if (targetOpponent != null && controller != null && max > 0) { + int numberOfCard = 0; + Card artifact = null; + CardsImpl nonArtifacts = new CardsImpl(); + CardsImpl reveal = new CardsImpl(); + for (Card card : targetOpponent.getLibrary().getCards(game)) { + reveal.add(card); + if (card.isArtifact()) { + artifact = card; + break; + } else { + numberOfCard++; + if (numberOfCard > max){ + break; + } + nonArtifacts.add(card); + } + } + targetOpponent.revealCards(source, reveal, game); + if (artifact != null) { + game.applyEffects(); + controller.moveCards(artifact, Zone.BATTLEFIELD, source, game); + Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); + if (sourcePermanent != null) { + sourcePermanent.sacrifice(source.getSourceId(), game); + } + } + targetOpponent.moveCards(nonArtifacts, Zone.GRAVEYARD, source, game); + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Darksteel.java b/Mage.Sets/src/mage/sets/Darksteel.java index 7624752521..dc188d9d8a 100644 --- a/Mage.Sets/src/mage/sets/Darksteel.java +++ b/Mage.Sets/src/mage/sets/Darksteel.java @@ -169,6 +169,7 @@ public final class Darksteel extends ExpansionSet { cards.add(new SetCardInfo("Tel-Jilad Outrider", 87, Rarity.COMMON, mage.cards.t.TelJiladOutrider.class)); cards.add(new SetCardInfo("Tel-Jilad Wolf", 88, Rarity.COMMON, mage.cards.t.TelJiladWolf.class)); cards.add(new SetCardInfo("Test of Faith", 17, Rarity.UNCOMMON, mage.cards.t.TestOfFaith.class)); + cards.add(new SetCardInfo("Thought Dissector", 152, Rarity.RARE, mage.cards.t.ThoughtDissector.class)); cards.add(new SetCardInfo("Thunderstaff", 153, Rarity.UNCOMMON, mage.cards.t.Thunderstaff.class)); cards.add(new SetCardInfo("Trinisphere", 154, Rarity.RARE, mage.cards.t.Trinisphere.class)); cards.add(new SetCardInfo("Turn the Tables", 18, Rarity.RARE, mage.cards.t.TurnTheTables.class));