From a7a4299c7f6d955cb2ade30bd6f6f99434a062c7 Mon Sep 17 00:00:00 2001 From: Vivian Greenslade Date: Wed, 30 Aug 2023 21:18:33 -0230 Subject: [PATCH] [WOC] Implement Knickknack Ouphe (#11070) --- .../src/mage/cards/k/KnickknackOuphe.java | 122 ++++++++++++++++++ .../mage/sets/WildsOfEldraineCommander.java | 1 + 2 files changed, 123 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/k/KnickknackOuphe.java diff --git a/Mage.Sets/src/mage/cards/k/KnickknackOuphe.java b/Mage.Sets/src/mage/cards/k/KnickknackOuphe.java new file mode 100644 index 00000000000..d954836c697 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KnickknackOuphe.java @@ -0,0 +1,122 @@ +package mage.cards.k; + +import java.util.UUID; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; +import mage.cards.Card; +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.PutCards; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.FilterCard; +import mage.filter.common.FilterEnchantmentCard; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +/** + * + * @author Xanderhall + */ +public final class KnickknackOuphe extends CardImpl { + + public KnickknackOuphe(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}"); + + this.subtype.add(SubType.OUPHE); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Knickknack Ouphe enters the battlefield with X +1/+1 counters on it. + this.addAbility(new EntersBattlefieldAbility(new EntersBattlefieldWithXCountersEffect(CounterType.P1P1.createInstance()))); + + // When Knickknack Ouphe enters the battlefield, reveal the top X cards of your library. You may put any number of Aura cards with mana value X or less from among them onto the battlefield. Then put all cards revealed this way that weren't put onto the battlefield on the bottom of your library in a random order. + this.addAbility(new EntersBattlefieldAbility(new KnickknackOuphePutOntoBattlefieldEffect())); + + } + + private KnickknackOuphe(final KnickknackOuphe card) { + super(card); + } + + @Override + public KnickknackOuphe copy() { + return new KnickknackOuphe(this); + } +} + +class KnickknackOuphePutOntoBattlefieldEffect extends OneShotEffect { + + public KnickknackOuphePutOntoBattlefieldEffect() { + super(Outcome.PutCardInPlay); + staticText = "reveal the top X cards of your library. " + + "You may put any number of Aura cards with mana value X or less from among them onto the battlefield. " + + "Then put all cards revealed this way that weren't put onto the battlefield on the bottom of your library in a random order"; + } + + public KnickknackOuphePutOntoBattlefieldEffect(final KnickknackOuphePutOntoBattlefieldEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + int count = ManacostVariableValue.ETB.calculate(game, source, null); + if (count > 0) { + Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, count)); + controller.revealCards(source, cards, game); + + FilterCard filter = new FilterEnchantmentCard("Aura cards with mana value " + count + " or less to put onto the battlefield"); + filter.add(SubType.AURA.getPredicate()); + filter.add(new ManaValuePredicate(ComparisonType.OR_LESS, count)); + + if (cards.count(filter, controller.getId(), source, game) > 0) { + TargetCard targetAuras = new TargetCard(0, count, Zone.LIBRARY, filter); + targetAuras.setRequired(false); + + if (controller.choose(Outcome.PutCardInPlay, cards, targetAuras, source, game)) { + targetAuras.getTargets().stream().forEach(t -> { + Card card = cards.get(t, game); + if (card != null) { + cards.remove(card); + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } + }); + + targetAuras.clearChosen(); + } else { + game.informPlayers(controller.getLogName() + " didn't choose anything"); + } + } else { + game.informPlayers("No Aura cards with mana value " + count + " or less to choose."); + } + + if (!cards.isEmpty()) { + PutCards.BOTTOM_RANDOM.moveCards(controller, cards, source, game); + } + } + return true; + } + return false; + } + + @Override + public KnickknackOuphePutOntoBattlefieldEffect copy() { + return new KnickknackOuphePutOntoBattlefieldEffect(this); + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/WildsOfEldraineCommander.java b/Mage.Sets/src/mage/sets/WildsOfEldraineCommander.java index 883c7e8ecf4..eb4f4a8e95b 100644 --- a/Mage.Sets/src/mage/sets/WildsOfEldraineCommander.java +++ b/Mage.Sets/src/mage/sets/WildsOfEldraineCommander.java @@ -77,6 +77,7 @@ public final class WildsOfEldraineCommander extends ExpansionSet { cards.add(new SetCardInfo("Keep Watch", 98, Rarity.COMMON, mage.cards.k.KeepWatch.class)); cards.add(new SetCardInfo("Kenrith's Transformation", 128, Rarity.UNCOMMON, mage.cards.k.KenrithsTransformation.class)); cards.add(new SetCardInfo("Kindred Dominance", 113, Rarity.RARE, mage.cards.k.KindredDominance.class)); + cards.add(new SetCardInfo("Knickknack Ouphe", 18, Rarity.RARE, mage.cards.k.KnickknackOuphe.class)); cards.add(new SetCardInfo("Kor Spiritdancer", 69, Rarity.RARE, mage.cards.k.KorSpiritdancer.class)); cards.add(new SetCardInfo("Krosan Verge", 163, Rarity.UNCOMMON, mage.cards.k.KrosanVerge.class)); cards.add(new SetCardInfo("Loamcrafter Faun", 19, Rarity.RARE, mage.cards.l.LoamcrafterFaun.class));