From 28b524ca1389cfa93005ab89629fcbd22f833a12 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 23 Jul 2018 13:42:31 -0400 Subject: [PATCH] Implemented Saheeli's Directive --- .../src/mage/cards/s/SaheelisDirective.java | 91 +++++++++++++++++++ Mage.Sets/src/mage/sets/Commander2018.java | 4 +- Utils/known-sets.txt | 2 +- 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/s/SaheelisDirective.java diff --git a/Mage.Sets/src/mage/cards/s/SaheelisDirective.java b/Mage.Sets/src/mage/cards/s/SaheelisDirective.java new file mode 100644 index 00000000000..4f3c0b21c89 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SaheelisDirective.java @@ -0,0 +1,91 @@ +package mage.cards.s; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.ImproviseAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.common.FilterArtifactCard; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +/** + * + * @author TheElk801 + */ +public final class SaheelisDirective extends CardImpl { + + public SaheelisDirective(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}{R}"); + + + // Improvise + this.addAbility(new ImproviseAbility()); + + // Reveal the top X cards of your library. You may put any number of artifact cards with converted mana cost X or less from among them onto the battlefield. Then put all cards revealed this way that weren't put onto the battlefield into your graveyard. + this.getSpellAbility().addEffect(new SaheelisDirectiveEffect()); + } + + public SaheelisDirective(final SaheelisDirective card) { + super(card); + } + + @Override + public SaheelisDirective copy() { + return new SaheelisDirective(this); + } +} +class SaheelisDirectiveEffect extends OneShotEffect { + + public SaheelisDirectiveEffect() { + super(Outcome.PutCardInPlay); + staticText = "Reveal the top X cards of your library. " + + "You may put any number of artifact cards with " + + "converted mana cost X or less from among them onto the battlefield. " + + "Then put all cards revealed this way that weren't " + + "put onto the battlefield into your graveyard."; + } + + public SaheelisDirectiveEffect(final SaheelisDirectiveEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + int xValue = source.getManaCostsToPay().getX(); + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue)); + if (!cards.isEmpty()) { + controller.revealCards(source, cards, game); + FilterCard filter = new FilterArtifactCard("artifact cards with converted mana cost " + xValue + " or less to put onto the battlefield"); + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, xValue + 1)); + TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, filter); + target1.setNotTarget(true); + controller.choose(Outcome.PutCardInPlay, cards, target1, game); + Cards toBattlefield = new CardsImpl(target1.getTargets()); + cards.removeAll(toBattlefield); + controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, false, null); + controller.moveCards(cards, Zone.GRAVEYARD, source, game); + } + return true; + } + + @Override + public SaheelisDirectiveEffect copy() { + return new SaheelisDirectiveEffect(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/Commander2018.java b/Mage.Sets/src/mage/sets/Commander2018.java index 342b15c6259..fa3ff924dab 100644 --- a/Mage.Sets/src/mage/sets/Commander2018.java +++ b/Mage.Sets/src/mage/sets/Commander2018.java @@ -1,7 +1,7 @@ - package mage.sets; import mage.cards.ExpansionSet; +import mage.constants.Rarity; import mage.constants.SetType; /** @@ -19,5 +19,7 @@ public final class Commander2018 extends ExpansionSet { private Commander2018() { super("Commander 2018 Edition", "C18", ExpansionSet.buildDate(2018, 8, 10), SetType.SUPPLEMENTAL); this.blockName = "Command Zone"; + + cards.add(new SetCardInfo("Saheeli's Directive", 26, Rarity.RARE, mage.cards.s.SaheelisDirective.class)); } } diff --git a/Utils/known-sets.txt b/Utils/known-sets.txt index 14ab5b66b4e..896efb1671f 100644 --- a/Utils/known-sets.txt +++ b/Utils/known-sets.txt @@ -25,7 +25,7 @@ Commander 2014 Edition|Commander2014| Commander 2015 Edition|Commander2015| Commander 2016 Edition|Commander2016| Commander 2017 Edition|Commander2017| -Commander 2018 Edition|Commander2018| +Commander 2018|Commander2018| Commander Anthology|CommanderAnthology| Commander Anthology 2018|CommanderAnthology2018| Commander's Arsenal|CommandersArsenal|