From aed61d0265fe23ba134c57d939df6793dcab3dd1 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 25 May 2019 15:08:23 -0400 Subject: [PATCH] Implemented Collected Conjuring --- .../src/mage/cards/c/CollectedConjuring.java | 101 ++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons.java | 3 +- 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/c/CollectedConjuring.java diff --git a/Mage.Sets/src/mage/cards/c/CollectedConjuring.java b/Mage.Sets/src/mage/cards/c/CollectedConjuring.java new file mode 100644 index 00000000000..4ddf4443212 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CollectedConjuring.java @@ -0,0 +1,101 @@ +package mage.cards.c; + +import mage.MageObject; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CollectedConjuring extends CardImpl { + + public CollectedConjuring(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}{R}"); + + // Exile the top six cards of your library. You may cast up to two sorcery cards with converted mana costs 3 or less from among them without paying their mana cost. Put the exiled cards not cast this way on the bottom of your library in a random order. + this.getSpellAbility().addEffect(new CollectedConjuringEffect()); + } + + private CollectedConjuring(final CollectedConjuring card) { + super(card); + } + + @Override + public CollectedConjuring copy() { + return new CollectedConjuring(this); + } +} + +class CollectedConjuringEffect extends OneShotEffect { + + private static final FilterCard filter = new FilterCard("sorcery cards with converted mana cost 3 or less"); + + static { + filter.add(new CardTypePredicate(CardType.SORCERY)); + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 4)); + } + + CollectedConjuringEffect() { + super(Outcome.Benefit); + this.staticText = "Exile the top six cards of your library. " + + "You may cast up to two sorcery cards with converted mana costs 3 or less from among them " + + "without paying their mana cost. Put the exiled cards not cast this way " + + "on the bottom of your library in a random order."; + } + + private CollectedConjuringEffect(final CollectedConjuringEffect effect) { + super(effect); + } + + @Override + public CollectedConjuringEffect copy() { + return new CollectedConjuringEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (controller == null || sourceObject == null) { + return false; + } + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 6)); + controller.moveCards(cards, Zone.EXILED, source, game); + int cardsCast = 0; + while (!cards.getCards(filter, source.getSourceId(), source.getControllerId(), game).isEmpty() && cardsCast < 2) { + if (!controller.chooseUse(Outcome.PlayForFree, "Cast a card exiled with " + sourceObject.getLogName() + " without paying its mana cost?", source, game)) { + break; + } + TargetCard targetCard = new TargetCard(1, Zone.EXILED, new FilterCard("nonland card to cast for free")); + if (!controller.choose(Outcome.PlayForFree, cards, targetCard, game)) { + continue; + } + Card card = game.getCard(targetCard.getFirstTarget()); + if (card == null) { + continue; + } + if (controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game))) { + cards.remove(card); + cardsCast++; + } else { + game.informPlayer(controller, "You're not able to cast " + card.getIdName() + " or you canceled the casting."); + } + } + controller.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons.java b/Mage.Sets/src/mage/sets/ModernHorizons.java index 75395f07948..3da8faea4dd 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons.java @@ -20,7 +20,7 @@ public final class ModernHorizons extends ExpansionSet { this.blockName = "Modern Horizons"; this.hasBasicLands = true; this.hasBoosters = true; - this.numBoosterLands = 0; + this.numBoosterLands = 1; this.numBoosterCommon = 11; this.numBoosterUncommon = 3; this.numBoosterRare = 1; @@ -38,6 +38,7 @@ public final class ModernHorizons extends ExpansionSet { cards.add(new SetCardInfo("Chillerpillar", 43, Rarity.COMMON, mage.cards.c.Chillerpillar.class)); cards.add(new SetCardInfo("Choking Tethers", 44, Rarity.COMMON, mage.cards.c.ChokingTethers.class)); cards.add(new SetCardInfo("Cloudshredder Sliver", 195, Rarity.RARE, mage.cards.c.CloudshredderSliver.class)); + cards.add(new SetCardInfo("Collected Conjuring", 196, Rarity.RARE, mage.cards.c.CollectedConjuring.class)); cards.add(new SetCardInfo("Crypt Rats", 84, Rarity.UNCOMMON, mage.cards.c.CryptRats.class)); cards.add(new SetCardInfo("Deep Forest Hermit", 161, Rarity.RARE, mage.cards.d.DeepForestHermit.class)); cards.add(new SetCardInfo("Diabolic Edict", 87, Rarity.COMMON, mage.cards.d.DiabolicEdict.class));