From e19abadee47ad67ff8d9209af42c600fddbb5d2b Mon Sep 17 00:00:00 2001 From: ciaccona007 Date: Wed, 15 Sep 2021 14:03:22 -0400 Subject: [PATCH] [MID] Implement Old Stickfingers --- .../src/mage/cards/o/OldStickfingers.java | 97 +++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + 2 files changed, 98 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/o/OldStickfingers.java diff --git a/Mage.Sets/src/mage/cards/o/OldStickfingers.java b/Mage.Sets/src/mage/cards/o/OldStickfingers.java new file mode 100644 index 0000000000..09c0cc178d --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OldStickfingers.java @@ -0,0 +1,97 @@ +package mage.cards.o; + +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CastSourceTriggeredAbility; +import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; +import mage.cards.*; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; + +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author ciaccona007 + */ +public final class OldStickfingers extends CardImpl { + + public OldStickfingers(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{B}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HORROR); + + // When you cast this spell, reveal cards from the top of your library until you reveal X creature cards. Put all the creature cards revealed this way into your graveyard and the rest on the bottom of your library in a random order. + this.addAbility(new CastSourceTriggeredAbility(new OldStickfingersEffect())); + + // Old Stickfingers' power and toughness are equal to the number of creature cards in your graveyard. + DynamicValue value = new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE); + this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(value, Duration.EndOfGame))); + } + + private OldStickfingers(final OldStickfingers card) { + super(card); + } + + @Override + public OldStickfingers copy() { + return new OldStickfingers(this); + } +} + +class OldStickfingersEffect extends OneShotEffect { + + public OldStickfingersEffect() { + super(Outcome.Discard); + this.staticText = "reveal cards from the top of your library until you reveal X creature cards. Put all the creature cards revealed this way into your graveyard and the rest on the bottom of your library in a random order"; + } + + public OldStickfingersEffect(final OldStickfingersEffect effect) { + super(effect); + } + + @Override + public OldStickfingersEffect copy() { + return new OldStickfingersEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY); + if (!(obj instanceof SpellAbility)) { + return false; + } + int xValue = ((SpellAbility) obj).getManaCostsToPay().getX(); + if (xValue < 1) { + return false; + } + Player controller = game.getPlayer(source.getControllerId()); + + Cards revealed = new CardsImpl(); + Cards otherCards = new CardsImpl(); + Set creatureCards = new LinkedHashSet<>(); + for (Card card : controller.getLibrary().getCards(game)) { + revealed.add(card); + if (card.isCreature(game)) { + creatureCards.add(card); + if(creatureCards.size() == xValue) { + break; + } + } else { + otherCards.add(card); + } + } + controller.revealCards(source, revealed, game); + controller.moveCards(creatureCards, Zone.GRAVEYARD, source, game); + controller.putCardsOnBottomOfLibrary(otherCards, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 523849b271..3ba34f84bf 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -218,6 +218,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Novice Occultist", 117, Rarity.COMMON, mage.cards.n.NoviceOccultist.class)); cards.add(new SetCardInfo("Obsessive Astronomer", 152, Rarity.UNCOMMON, mage.cards.o.ObsessiveAstronomer.class)); cards.add(new SetCardInfo("Odric's Outrider", 29, Rarity.UNCOMMON, mage.cards.o.OdricsOutrider.class)); + cards.add(new SetCardInfo("Old Stickfingers", 234, Rarity.RARE, mage.cards.o.OldStickfingers.class)); cards.add(new SetCardInfo("Olivia's Midnight Ambush", 118, Rarity.COMMON, mage.cards.o.OliviasMidnightAmbush.class)); cards.add(new SetCardInfo("Ominous Roost", 65, Rarity.UNCOMMON, mage.cards.o.OminousRoost.class)); cards.add(new SetCardInfo("Organ Hoarder", 66, Rarity.COMMON, mage.cards.o.OrganHoarder.class));